Skip to content

Use CapitalMetro's GTFS data to find minimum of 5-15 minute wait times when single bus transfer is required.

Notifications You must be signed in to change notification settings

dramanat/wait_times

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Purpose

Make your bus commute easier! Find routes that require only 5-15 minutes of wait time between transfers. (Only works for trips with just one transfer.)

This program can be used by any public transit system that publishes their transit data in GTFS (General Transit Feed Specification) format.

Explanation of code

This program uses the following GTFS data files:

  • trips.txt (with fields route_id, service_id, trip_id, direction_id), and
  • stop_times.txt (with fields trip_id, arrival_time, stop_id)

The following data structure is created :

  • first_bus[trip_id][pick_up_stop_id] = time_at_stop
  • first_bus[trip_id][drop_off_stop_id] = time_at_stop
  • second_bus[trip_id][pick_up_stop_id] = time_at_stop
  • second_bus[trip_id][drop_off_stop_id] = time_at_stop

Bus times are printed when :

  • (second_bus[trip_id][pick_up_stop_id] - first_bus[trip_id][drop_off_stop_id]) is greater than 5 or less than 15 minutes

Example

call_wait_times.rb finds bus times with 5-15 minutes wait for :

  • Bus #1 Southbound pick_up_stop_id 4029 and drop_off_stop_id 524, then
  • Bus #331 Westbound pick_up_stop_id 5674 and drop_off_stop_id 3360

Output from call_wait_times.rb

How to use program

  1. need to have trips.txt & stop_times.txt in wait_times directory

  2. Austin's Capital Metro GTFS feed can be downloaded from http://www.capmetro.org/gisdata/google_transit.zip

  3. GTFS feeds for other cities can be found at https://code.google.com/archive/p/googletransitdatafeed/wikis/PublicFeeds.wiki

  4. need to know bus information (bus #, stop_ids, direction, etc.)

  5. to print results, use call_wait_times.rb as an example to

  6. set up 2 Segment objects

  7. create WaitTimes object with Segment objects passed in as an array

  8. execute WaitTimes' generate_json method

Items to work on

  • create test for #find_wait_times
  • improve performance of #_find_wait_times
  • replace file processing with smarter_csv gem (file extensions need to be changed to CSV)
  • create test files in spec directory and write tests for #create_bus_hash and #populate_bus_hash
  • create Segment class to store bus information (will make program more scalable)

About

Use CapitalMetro's GTFS data to find minimum of 5-15 minute wait times when single bus transfer is required.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages