codefordurham / BikeSafety

Show common areas of bike accidents to help prevent future accidents
http://bikesafety.codefordurham.com/
11 stars 6 forks source link

Overview

Isidro Razo, 49, was the latest bike rider to die on his way to work in Durham on May 25th on Angier Avenue. That makes four bike-related victims in the past 6 months in Durham. Despite deadly and risky biking conditions in Durham, the transition to a more bike-friendly community is slow and infrastructure budgets are not being accelerated. Policy makers need good data to know where to prioritize new bike plan infrastructure to make roadways safer. Bikers and would-be bikers need to know the safest routes and danger zones as they begin to bike more often to more places.

The goal of the application is to create color-coded bike routes based on relative risk of accidents, number of crashes, time of day, etc. using the NC bike crash database and bike reported incidents. The application will also highlight troublesome intersections.

A snapshot of the master branch is on heroku. This has been continuous integration server setup with Heroku - ping @dsummersl if its not working for you!

TODO

Stories in Ready

Overview

The project uses Angular and Express for the frontend and backend respectively.

The project uses NPM to manage server side dependences and bower for angular dependencies. The npm install will install both of these dependencies for you.

Frontend

Angular works directly with Firebase. The Angular App uses Leaflet as the mapping system. Firebase is used to store the NCDOT bicycle accident data. Jade template renders the html pages.

Main Controllers

Server

The server is an [express server] (expressjs.com). It serves static content (i.e. the static angular files) and (converts the Jade templates into HTML??).

Database: The database is hosted on Firebase. Our Database is this link.

Run

You only need Node.js to develop this platform. Install that:

npm install
npm start

npm start will open a server on port 3000 of your computer. Go there to view the app.

Test

npm test

Under development you might want to rerun tests when files change:

npm run-script start-test

Data

Map Data

The frontend application uses TopoJSON to render paths. If the source geojson is updated then the topojson needs to be updated too.

To convert the geojson file to topojson:

./node_modules/.bin/topojson -p BIKE_FACIL --id-property OBJECTID_12 html/src/data/durham-bike-lanes.geojson > html/src/data/durham-bike-lanes.topojson

Crash Data

Data is read from Code for America Socrata, supplied by the NCDOT bi-annually. We migrate and clean the data. If the data changes or the cleanup process changes, one should download the new CSV data and import it:

  1. Data is stored in the data/ directory.
  2. Start the server with Firebase credentials:
# export both NCDOT and user-submitted bicyclist crashes to local JSON files
npm run export-bicyclist-crashes

# export both NCDOT and user-submitted pedestrian crashes to local JSON files
npm run export-pedestrian-crashes

# export NCDOT and user-submitted bicyclist and pedestrian crashes to local JSON files
npm run export-all-crashes

# recreate crashes database from NCDOT data.
npm run create-firebase

# replace Firebase table with contents of local JSON file:
npm run import-firebase -- <table name> <local file>

# delete a table from Firebase
npm run delete-firebase -- <table name>