Coder Social home page Coder Social logo

gtfs-multiroute-schedule's Introduction

gtfs-multiroute-schedule

View a consolidated schedule for multiple routes based on GTFS (General Transit Feed Specification) data.

Reference docs

Using SQLite for data storage

Schema

	CREATE TABLE routes (route_id, agency_id, route_short_name, route_long_name, route_desc, route_type, route_url, route_color, route_text_color);
	CREATE TABLE stop_times (trip_id,arrival_time,departure_time,stop_id,stop_sequence,stop_headsign,pickup_type,drop_off_type,shape_dist_traveled);
	CREATE TABLE stops (stop_id,stop_code,stop_name,stop_desc,stop_lat,stop_lon,zone_id,stop_url,location_type,parent_station);
	CREATE TABLE trips (route_id,service_id,trip_id,trip_headsign,direction_id,block_id,shape_id);
	CREATE TABLE calendar (service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date);
	CREATE UNIQUE INDEX routes_route_id ON routes(route_id ASC);
	CREATE INDEX stop_times_stop_id ON stop_times(stop_id ASC);
	CREATE INDEX stop_times_trip_id ON stop_times(trip_id ASC);
	CREATE UNIQUE INDEX stops_stop_id ON stops(stop_id ASC);
	CREATE INDEX trips_route_id ON trips(route_id ASC);
	CREATE UNIQUE INDEX trips_trip_id ON trips(trip_id ASC);
	CREATE UNIQUE INDEX calendar_service_id ON calendar(service_id ASC);

Importing data

	.separator ","
	.import routes.txt routes
	.import stop_times.txt stop_times
	.import stops.txt stops
	.import trips.txt trips
	.import calendar.txt calendar
	-- make times usable by sqlite (doesn't like single digit hours)
	update stop_times set departure_time = "0"||departure_time where length(departure_time) = 7;
	update stop_times set arrival_time = "0"||arrival_time where length(arrival_time) = 7;

Retrieving data

.headers on
.mode column

--
-- generic select with all the joins in place
-- st = stop_times, s = stops, t = trips, r = routes, c = calendar
--
select ... from stop_times as st join stops as s on (st.stop_id=s.stop_id) join trips as t on (st.trip_id=t.trip_id) join routes as r on (t.route_id=r.route_id) join calendar as c on (c.service_id=t.service_id) where ...;

ToDo

gtfs-multiroute-schedule's People

Contributors

jbrown123 avatar

Watchers

 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.