https://github.com/codeforboston/gtfs-performance
https://github.com/codeforboston/gtfs-performance
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/codeforboston/gtfs-performance
- Owner: codeforboston
- Created: 2016-10-19T14:38:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-15T03:39:46.000Z (about 9 years ago)
- Last Synced: 2025-10-08T18:50:54.084Z (8 months ago)
- Language: Clojure
- Size: 177 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* Purpose
Fills in some gaps in the current MBTA API.
* Usage
** Requirements
- Java 8 (for the ~java.time~ package)
- [[http://leiningen.org][Leiningen 2]] - a package management and build tool for Clojure
- [[https://www.mongodb.com][MongoDB]] version 3.2 or higher (for certain aggregation operators and zip
archives)
** Running
*** Interactive Development
I recommend using [[http://cider.readthedocs.io/en/latest/][Cider]] or [[https://cursive-ide.com][Cursive]] and jacking in. By default, the REPL
starts in the ~mbta-xtras.repl~ namespace. Run ~(system/start)~ to start the
application. Run ~(start-mongo)~ to just start Mongo, and
~mbta-xtras.repl/db~ will be bound to the database for convenience.
~(stop-mongo)~ will close the connection.
*** Noninteractive
Use ~lein trampoline run~. If you want to be able to connect a REPL to the
running server, set the ~NREPL_SERVER_PORT~ environment variable. For
example:
#+BEGIN_SRC bash
NREPL_SERVER_PORT=12345 lein trampoline run
#+END_SRC
You can then use ~cider-connect~
** Environment Variables
Configuration of the application is done entirely through environment
variables and/or Java system properties.
- MONGO_URI :: This should be a URI of the form ~mongodb:///db~.
Specify a username and password with: ~mongodb://username:password@host/db~.
- HTTP_PORT :: Alternative port on which to start the web service
- MANIFEST_URL :: The URL where the GTFS zip manifest lives
- MANIFEST_DOWNLOAD_TO :: The path where the zip manifest should be saved
- MBTA_API_KEY :: An MBTA-specific setting, used when communicating with the
[[http://realtime.mbta.com/Portal/Home/Documents][Realtime API]].
- TRIP_UPDATES_URL :: Specify a URL to poll for Trip Updates
- GTFS_ZONE :: A valid time zone ID (default: America/New_York)
- POSTPROCESS_INTERVAL :: For the moment, the system performs necessary
post-processing on the trip-stops collection in order to make certain
performance queries respond quickly. Set this variable to the number of
seconds between post-processing runs.
- NREPL_SERVER_PORT :: Set to a number to bind an [[https://github.com/clojure/tools.nrepl][nREPL server]] to the
specified port. Allows you to use ~cider-connect~ in emacs, etc.
You can also set these as Java system properties on start up. The system
properties are the same as the environment variales, except downcased and
with periods replacing underscores. To set MONGO_URI, for instance, set the
~mongo.uri~ system property.
** Building
- ~lein uberjar~
This will create two new .jar files in your ~target~ directory. Run the
standalone jar with ~java -jar target/mbta-xtras--standalone.jar~.
* Data Dumps
Since others might be interested in using the raw "trip-stops" data without
having to run a server, gzipped mongodb dumps of the collection will be
automatically posted daily and will be available at URLs with the format:
http://mbta-static.apptic.xyz/mbtafyi/trip-stops_*YYYY_mm*.gz
To view a listing, in XML format, of the available files, see:
http://mbta-static.apptic.xyz/mbtafyi?restype=container&comp=list
Each file will contain _only_ the trip stops recorded during the month
indicated by the file name. Import them using the ~mongorestore~
utility. For example:
#+BEGIN_SRC bash
mongorestore --db=mbta --collection=trip-stops --gzip --archive=trip-stops_2016_10.gz
#+END_SRC