Skip to content
This repository has been archived by the owner on Mar 12, 2023. It is now read-only.

abrobston/mspbus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

omgtransit.com

Screenshot

Setup

Installation

  1. Download and install ElasticSearch
  2. Install Ruby 1.9.3
  3. Install Rails
  • Be sure that Rails is not trying to use Ruby 1.8, it will not work
  1. Install postgresql
  2. Install PostGIS (sudo apt-get install postgresql-9.1-postgis)
  3. Install Bundle
  4. Install Redis (sudo apt-get install redis-server)
  5. Run bundle
  • May need sudo apt-get install libpq-dev
  1. Start Elastic Search with sudo service elasticsearch start
  2. Set up the configuration variables in app/assets/javascripts/config.js
  3. Set your own config.google_maps_api_key inside development.rb, production.rb and test.rb located in config/environments

Database Setup

  1. Create a PostGRES database
  2. Log in to the server using sudo -u postgres psql
  3. CREATE USER user WITH PASSWORD 'password';
  4. CREATE DATABASE omgtransit;
  5. GRANT ALL PRIVILEGES ON DATABASE omgtransit TO user;
  6. Load the PostGIS extension
  7. sudo -u postgres createlang plpgsql omgtransit;
  8. sudo -u postgres psql -d omgtransit -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
  9. sudo -u postgres psql -d omgtransit -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
  10. Run sudo mkdir -p /etc/nubic/db
  11. Create the file /etc/nubic/db/omgtransit.yml
  12. Set up /etc/nubic/db/omgtransit.yml according to Setting up Database Credentials

GTFS Data Acquisition

We get the location of stops and route paths from General Transit Feed Specification (GTFS) files. More information on these files is available here.

GTFS data is available at the GTFS Exchange.

Download these data files and put them in appropriately named folders in setup/.

For instance, you can download the Minneapolis Metro Transit feed from here. And unzip this into the folder setup/msp_gtfs.

Loading the Database

  1. Run rake db:migrate
  2. Run rake db:seed
  3. Run rake omgtransit:load_msp_gtfs (Or what have you, this draws from the setup/ folders).
  • Run rake omgtransit:load_mn_bikes
  • Run rake omgtransit:load_umn_stops
  1. Repeat Step 3 as needed
  2. Run rake omgtransit:reset_stops
  3. Index GeoData rake environment tire:import CLASS='Stop' FORCE=true
  • Occasionally, it may useful to force the environment with rake environment tire:import CLASS='Stop' FORCE=true RAILS_ENV=production

Start the Server

  1. Run rails s in the project's base directory to start the server

Setting Up Database Credentials

Database credentials are not part of the distribution for obvious reasons. The included config/database.yml uses the bcdatabase package to retrieve the credentials from elsewhere on your Rails server. The credentials are store in /etc/nubic/db/omgtransit.yml.

This file may look something like the following.

defaults:
  adapter: postgresql
  encoding: utf8
  host: localhost
development:
  database: omgtransit-dev
  username: yourdevusername
  password: yourdevpassword
test:
  database: omgtransit-test
  username: yourtestusername
  password: yourtestpassword
prod:
  database: omgtransit
  username: yourprodusername
  password: yourprodpassword

You should secure omgtransit.yml so that it can only be read by the server. You can optionally encrypt the file as well. For more information, see the bcdatabase project.

Database Stops Table

       Column        |          Type          | Modifiers 
---------------------+------------------------+-----------
 stop_id             | character varying(500) | not null
 stop_code           | character varying(500) | 
 stop_name           | character varying(500) | not null
 stop_desc           | character varying(500) | 
 stop_lat            | numeric(9,6)           | not null
 stop_lon            | numeric(9,6)           | not null
 zone_id             | character varying(100) | 
 stop_url            | character varying(500) | 
 location_type       | integer                | 
 parent_station      | character varying(500) | 
 stop_timezone       | character varying(500) | 
 wheelchair_boarding | integer                | 
 stop_street         | character varying(500) | 
 stop_city           | character varying(500) | 
 stop_region         | character varying(500) | 
 stop_postcode       | character varying(50)  | 
 stop_country        | character varying(100) | 
Indexes:
    "stops_pkey" PRIMARY KEY, btree (stop_id)

Example output

 1000    |           | 50 St W & Upton Av S        | Near side E   | 44.912365 | -93.315178 |         | http://www.metrotransit.org/NexTripBadge.aspx?stopnumber=1000  |               |                |               |                   1 | 50 St W     | MINNEAPOLIS         |             |               | 
 10000   |           | Carmen Av & Claude Way E #2 | Across from S | 44.857449 | -93.040977 |         | http://www.metrotransit.org/NexTripBadge.aspx?stopnumber=10000 |               |                |               |                   1 | Carmen Av   | INVER GROVE HEIGHTS |             |               | 
 10001   |           | Carmen Av & 65 St E         | Far side S    | 44.855103 | -93.042496 |         | http://www.metrotransit.org/NexTripBadge.aspx?stopnumber=10001 |               |                |               |                   1 | Carmen Av   | INVER GROVE HEIGHTS |             |               |

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published