##Preview
Subway Info is a Dashing widget which displays information on trains in New York City. Information includes train line, direction, station and arrival time. You can customize it to include any combination of lines and stations. This may also be used in other cities as well if you have the appropriate GTFS files.
##Dependencies
Add the following gem to the Gemfile:
gem 'gtfs'
and run bundle install
.
##Usage
To use the widget, copy mta.rb
to the /jobs
folder. Create a folder called mta
under /widgets
. Copy mta.coffee
, mta.html
and mta.scss
into /widgets/mta
.
Add the following code snippet to your dashboard .erb
file under /dashboards
:
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="mta" data-view="Mta"></div>
</li>
##Settings
This widget allows you to specify the stops and lines of interest to you. Specify these as strings in the arrays target_stops
and target_lines
. Please limit the number of stops and lines. For example, this widget was tested with 2 stations with 2 lines each.
You can also specify the refresh time for the display, the interval between data updates and how far in the future to look for incoming trains.
Look at the comments at the beginning of the job mta.rb
to learn more about customizing the widget.
Note: The widget may be used with other GTFS files too. This is not restricted to New York City. Keep in mind that this has only been tested with GTFS data from the MTA.
To use your own GTFS file, replace the URL to the zip file in the following line:
$source = GTFS::Source.build('http://www.mta.info/developers/data/nyct/subway/google_transit.zip')
Add your desired URL instead.
####Note:
If you would like to use the train line images instead of numbers, use the following mta.coffee and mta.html. Also download the images (1, 2, 3, 4, 5, 6, A, C, E, N, Q, R) from here into the folder /public
.
##Warnings
This widget takes around one minute to load on startup. Be patient. Once it starts, the widget is quick and responsive. The job must download and parse a GTFS file from the MTA. The file can be found at the MTA Developer downloads page. To access, click New York City Transit Subway under static data feeds. The GTFS files are updated by the MTA every so often. This widget checks for an update every 24 hours or every time the dashboard's host server starts Dashing.
I had this working perfectly with MARTAs GTFS file. All of a sudden it will not work, even after a clean install.
Does anyone have any ideas?
scheduler caught exception: No such file or directory - /tmp/d20131216-12947-u2xra8/gtfs_Dec13/agency.txt /var/lib/gems/1.9.1/gems/gtfs-0.2.1/lib/gtfs/url_source.rb:18:in `rescue in load_archive' /var/lib/gems/1.9.1/gems/gtfs-0.2.1/lib/gtfs/url_source.rb:8:in`load_archive' /var/lib/gems/1.9.1/gems/gtfs-0.2.1/lib/gtfs/source.rb:25:in `initialize' /var/lib/gems/1.9.1/gems/gtfs-0.2.1/lib/gtfs/source.rb:48:in`new' /var/lib/gems/1.9.1/gems/gtfs-0.2.1/lib/gtfs/source.rb:48:in `build' /home/dash/dashboard/jobs/mta.rb:37:in`block in ' /var/lib/gems/1.9.1/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:230:in `call' /var/lib/gems/1.9.1/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:230:in`trigger_block' /var/lib/gems/1.9.1/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:204:in `block in trigger' /var/lib/gems/1.9.1/gems/rufus-scheduler-2.0.24/lib/rufus/sc/scheduler.rb:430:in`call' /var/lib/gems/1.9.1/gems/rufus-scheduler-2.0.24/lib/rufus/sc/scheduler.rb:430:in `block in trigger_job'