/traffic-example

An example application of traffic-engine.

Primary LanguageJava

traffic-example

An example application of traffic-engine.

prereqs

build

$ mvn clean compile assembly:single

usage

using App.java

  1. Grab a city extact, like https://s3.amazonaws.com/metro-extracts.mapzen.com/manila_phillipines.osm.pbf. Save it in $PROJECT_ROOT/data.
  2. Get yourself a CSV containing GPS records in the form time,vehicle_id,lon,lat. For example: 2015-01-01 00:00:00.07018+08,43736,121.123456,14.123456. Save it to $PROJECT_ROOT/data. You'll need about a million records before the results are any good.
  3. Import the project to Eclipse.
  4. Edit the PBF_IN and CSV_IN fields in App.java to reflect your input PBF and CSV files.
  5. Run App.java
  6. A mapdb database (defined by the HISTOGRAM_DB field) will be written to disk.

using InspectHistogram.java

  1. Open 'InspectHistogram.java'
  2. Edit the HISTOGRAM_FILENAME and CSV_OUT_FILENAME static variables.
  3. Run InspectHistogram.java
  4. A CSV with rows in the form (way_seg_id,mean_speed) will be written to disk.

putting it all together

  1. Open the shapefile output by App.csv in QGIS.
  2. Open the output speed CSV (defined by the CSV_OUT_FILENAME field) in QGIS. Specify that the CSV has no geometry.
  3. Open the properties of the shapefile in QGIS. Click the 'Joins' tab.
  4. Click the little green 'plus' button. The join field is 'waysegid' and the target field is 'name'.
  5. Click on the 'Style' tab. Select the 'Spectral' color ramp for the column "manila_speeds_mean". Use the 'Quantile' mode, with enough classes to show an even gradient. 30 works fine.
  6. Click 'OK'. The resulting image should be pretty.