gtfs-sequelize
A model of the static GTFS using sequelize.js.
Currently works only with PostgreSQL (including PostGIS), MySQL (with spatial capabilities) and sqlite (but NOT spatialite).
Table of Contents
Installation
In order to use this library, you must also install the additional libraries in your project depending on the database that you use.
PostgreSQL
npm install pg --save
npm install pg-copy-streams --save
npm install pg-hstore --save
With pg and node v0.10.x
You must also install the package promise-polyfill
and write additional code. See here for more details.
MySQL
npm install mysql --save
npm install streamsql --save
SQLite
npm install sqlite3 --save
npm install streamsql --save
Usage with SQLite requires that sqlite is installed and is available via a unix command line.
Usage:
Downloading the GTFS File:
var GTFS = require('gtfs-sequelize');
var downloadConfig = {
gtfsUrl: 'http://feed.rvtd.org/googleFeeds/static/google_transit.zip',
downloadsDir: 'downloads'
};
var gtfs = GTFS(downloadConfig);
gtfs.downloadGtfs(function() {
});
Loading GTFS into Database:
var GTFS = require('gtfs-sequelize');
var pgConfig = {
database: 'postgres://gtfs_sequelize:gtfs_sequelize@localhost:5432/gtfs-sequelize-test',
downloadsDir: 'downloads',
gtfsFilename: 'google_transit.zip',
sequelizeOptions: {
logging: false
}
}
var gtfs = GTFS(pgConfig);
gtfs.loadGtfs(function() {
});
Loading into a DB with PostGIS installed:
var GTFS = require('gtfs-sequelize');
var pgConfig = {
database: 'postgres://gtfs_sequelize:gtfs_sequelize@localhost:5432/gtfs-sequelize-test',
downloadsDir: 'downloads',
gtfsFilename: 'google_transit.zip',
spatial: true,
sequelizeOptions: {
logging: false
}
}
var gtfs = GTFS(pgConfig);
gtfs.loadGtfs(function() {
});
Querying a specific schema within a DB:
var GTFS = require('gtfs-sequelize');
var pgConfig = {
database: 'postgres://gtfs_sequelize:gtfs_sequelize@localhost:5432/gtfs-sequelize-test',
downloadsDir: 'downloads',
gtfsFilename: 'google_transit.zip',
spatial: true,
sequelizeOptions: {
logging: false,
schema: 'test_schema'
}
}
var gtfs = GTFS(pgConfig);
gtfs.loadGtfs(function() {
});