Code Monkey home page Code Monkey logo

gtfs-to-html's Introduction

GTFS to HTML

Generate HTML transit timetables in from GTFS.

Setup

Install dependencies

npm install

Configure

Copy config-sample.js to config.js.

cp config-sample.js config.js

Before you can use gtfs-to-html you must specify the transit agencies you'd like to use.

You can specify agencies using a url to the GTFS file or a local path.

To find an agency's GTFS URL, visit transitfeeds.com. You can use the direct URL from the agency or you can use a URL generated from the transitfeeds.com API along with your API token.

  • Specify a download URL:
{
    agency_key: 'county-connection',
    url: 'http://cccta.org/GTFS/google_transit.zip'
}
  • Specify a path to a zipped GTFS file:
{
    agency_key: 'localAgency',
    path: '/path/to/the/gtfs.zip'
}
  • Specify a path to an unzipped GTFS file:
{
    agency_key: 'localAgency',
    path: '/path/to/the/unzipped/gtfs/'
}

The mongodb URI should also be configured in config.js. The default database URI is: mongodb://localhost:27017/gtfs

Formatting Options

The following items can be added to the configuration object:

effectiveDate

{String} This is printed at the top of the timetable.

    effectiveDate: 'July 8, 2015'
noServiceSymbol

{String} The symbol to be used when a specific trip does not serve a specified stop.

    noServiceSymbol: '—'
requestStopSymbol

{String} The symbol to be used to indicate that riders must request a stop.

    requestStopSymbol: '***'
showMap

{Boolean} Whether or not to show a map of the route on the timetable.

    showMap: false

Build timetables.txt

This project requires that an additional file timetables.txt be added to an agencies GTFS. This file specifies which HTML timetables should be built.

An example of this file is located in examples/timetables.txt. The format of this file is:

column name description
timetable_id A unique ID for the timetable
route_id The ID of the route the timetable is for from routes.txt.
direction_id The direction_id from trips.txt for the timetable. This can be blank.
start_date The start date for this timetable in YYYY-MM-DD format.
end_date The end date for this timetable in YYYY-MM-DD format.
monday A binary value that indicates whether this timetable should include service on Mondays. Valid options are 0 and 1.
tuesday A binary value that indicates whether this timetable should include service on Tuesdays. Valid options are 0 and 1.
wednesday A binary value that indicates whether this timetable should include service on Wednesdays. Valid options are 0 and 1.
thursday A binary value that indicates whether this timetable should include service on Thursdays. Valid options are 0 and 1.
friday A binary value that indicates whether this timetable should include service on Fridays. Valid options are 0 and 1.
saturday A binary value that indicates whether this timetable should include service on Saturdays. Valid options are 0 and 1.
sunday A binary value that indicates whether this timetable should include service on Sundays. Valid options are 0 and 1.
route_label A short text label describing the route, for instance "4".
service_notes Text shown on the timetable about the service represented, for instance "Mon-Fri".

Running

Ensure than mongodb is running locally.

mongod

To generate HTML timetables, run the 'gtfs-to-html' script.

npm run gtfs-to-html

This will download the GTFS file specified in config.js . Then, it will build the HTML timetables and save them in html/:agency_key.

Options

Note the use of two sets of -- when running commands with arguments from npm.

nohead

npm run gtfs-to-html -- --nohead

This will generate embeddable HTML without an <html>, <head> or <body> tag.

Testing

After an initial run of the gtfs-to-html script, the GTFS data will be downloaded and loaded into mongo.

You can view an individual route HTML on demand by running the included express app:

DEBUG=gtfs-to-html npm start

With this running, you can open http://localhost:3000 in your browser and view all timetables. Note that this only works after GTFS has been imported to mongodb and mongodb is running locally.

gtfs-to-html's People

Contributors

brendannee avatar

Watchers

Mikko Välimäki avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.