Skip to content

A gem to interact with realtime transit data presented in the GTFS Realtime format (https://developers.google.com/transit/gtfs-realtime/).

License

Notifications You must be signed in to change notification settings

camsys/gtfs-realtime

 
 

Repository files navigation

gtfs-realtime

gfts-realtime is a gem to interact with realtime transit data presented in the GTFS Realtime format. It was built in order to interact with the RIPTA realtime data API for the public bus system in Providence, RI.

This gem has been forked by Cambridge Systematics and updated to archive realtime transit data rather than just getting the latest feed. It saves the data into a partitioned postgres database.

Installation

Add to your application's Gemfile:

gem 'bulk_data_methods', github: 'AirHelp/bulk_data_methods', branch: 'rails5'
gem 'partitioned', github: 'AirHelp/partitioned', branch: 'rails-5-1'
gem 'gtfs-realtime', path: '../gtfs-realtime'

gem 'crono'

Add your feeds:

GTFS::Realtime.configure([{name: 'feed_name', trip_updates_feed: 'xxx', vehicle_positions_feed: 'xxx', service_alerts_feed: 'xxx', interval_seconds: '###'}])

where you pass to configure an array of hashes for all your feeds

  • feed_name - some identifier of this feed such as "Subway", "Buses", "Elevators"
  • xxx - URL of feed
  • interval seconds - how often you ping the URL to pull latest feed data, in seconds

You can re-run configure as many times as you want to add new feeds. TODO: currently, you cannot delete feeds.

In your application, run

rails g gtfs_realtime:initialize

or

rails g gtf_realtime:initialize feed_name

Limitations

  • Assumes all feeds have a header gtfs_realtime_version of 1.0
  • Partitions are not configurable. All realtime tables are partitioned by feed, and a week of data.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/camsys/gtfs-realtime. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

About

A gem to interact with realtime transit data presented in the GTFS Realtime format (https://developers.google.com/transit/gtfs-realtime/).

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 99.8%
  • Shell 0.2%