trimetric

package module
v0.0.0-...-6501577 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2018 License: MIT Imports: 16 Imported by: 0

README

trimetric

Trimetric is a realtime visualization of the Trimet transit system in Portland, OR, using the GTFS feeds provided for developers by Trimet.

It downloads the static GTFS feeds periodically and ingests them into the local Postgres database, for querying later using PostGIS. Realtime GTFS data, such as vehicle position and trip updates, are polled and produced into Kafka, where it is consumed by other workers.

The front end is a responsive web app built in React and uses Mapbox and deck.gl for rendering the map and icon layers. When zoomed in, Trimetric shows you a dynamic list of the stops that are visible on screen, which you can click to see upcoming arrivals.

Demo

You can view Trimetric online at: https://trimetric.briand.co

Screenshots

Main View
Stop List View Arrival List View Mobile View

Running

You can run Trimetric locally using Docker Compose. You'll need:

Then run the following to get things up and running:

git clone https://github.com/bsdavidson/trimetric.git
cd trimetric
mkdir secrets
echo MAPBOX_ACCESS_TOKEN=<your_mapbox_token> > web/.env
echo <your_trimet_api_key> > secrets/trimet-api-key
echo example > secrets/postgres-password
echo INFLUXDB_USER_PASSWORD=example > secrets/influxdb.env
docker-compose up

You should see the logs from Docker Compose in the terminal. All the dependencies will be started automatically and the local directories will be mounted in the containers for easy development. The API and web app will be rebuilt automatically when you make changes. You can view the running web app in your browser by opening: http://localhost:8080

Testing

There are tests for both Go and JavaScript. The Go tests require Postgres, so make sure the Docker Compose environment is running (with docker-compose up). Then run this command locally to both Go and JavaScript tests:

make test

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MigrateDB

func MigrateDB(db *sql.DB, path string, migrate bool) error

MigrateDB applies any updates needed to the database to bring it up to the latest version of the schema. If migrate is false, then it won't modify the DB but will instead return an error if the database is not up-to-date.

func OpenDB

func OpenDB(url string) (*sql.DB, error)

OpenDB connects to the database.

func OpenInfluxDB

func OpenInfluxDB(host, username, password string) (client.Client, error)

OpenInfluxDB will open a connection and return an InfluxDB client

func Run

func Run(ctx context.Context, cancel context.CancelFunc, debug bool, addr, apiKey string, db *sql.DB, influxClient client.Client, kafkaAddr, redisAddr, webPath string) error

Run starts all the processes for Trimetric.

Types

This section is empty.

Directories

Path Synopsis
Package api provides handlers and methods to process HTTP API requests.
Package api provides handlers and methods to process HTTP API requests.
cmd
Package logic provides the business logic for Trimetric.
Package logic provides the business logic for Trimetric.
Package trimet provides methods to interact with the Trimet API.
Package trimet provides methods to interact with the Trimet API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL