![]() This appears to be the information used on the subway platform countdown clocks. The stop_time_updates table includes, for each observed train, a list of its upcoming stops and their estimated arrival/departure times. Also note that the MTA has a list of scheduled trips-populated in the scheduled_trips table-but the actual trips that show up in the realtime_trips table usually do not share IDs with the scheduled_trips records. Note that at analysis time, I attempted to merge duplicate records in the realtime_trips table, see analysis/merge_trips.sql. The MTA GTFS-realtime reference provides guidance on determining unique trains, but I used my own logic in the RealtimeFeedObservation#find_or_create_realtime_trip_from_entity method. In practice it probably overcounts trains, as the data is generally unreliable, trains don't have canonical IDs, and the various identifiers they do have sometimes change from minute to minute. Realtime_trips is supposed to contain one row for each unique train. When a realtime observation is "processed", it is broken out into the realtime_trips, stop_time_updates, and vehicle_positions tables. The API responses are stored as JSON in the realtime_feed_observations table. You can also run a single Foreman process with bundle exec foreman start -f Procfile.clockplusworker, which works on a $7 per month Heroku hobby dyno. The clock process queues up jobs every minute to ping the MTA's feeds, and the worker process makes the API requests and does the data processing. You need to run 2 processes to record data: This is recommended in development, but you might not want to do it in production as it will cause your database's size to grow very quickly. env file if you want to process observations automatically after they are created. ![]() Optionally, add PROCESS_OBSERVATIONS_AFTER_CREATE=true to the. bundle exec rake db:setup will create a database and populate it with the MTA's static GTFS data, which is downloaded automatically from.env in the project root, and edit it to set the MTA_KEY to the key you just obtained Additional SQL and R analysis scripts/instructions are included in the analysis/ subfolder.Ĭode used in support of the post Using Countdown Clock Data to Understand the New York City Subway SetupĪssumes Ruby, Rails, and PostgreSQL are all installed ![]() A Rails app to collect data from the MTA's real-time data feeds. ![]()
0 Comments
Leave a Reply. |