Skip to content
This repository has been archived by the owner on Jan 21, 2021. It is now read-only.

Latest commit

 

History

History
71 lines (47 loc) · 2.54 KB

File metadata and controls

71 lines (47 loc) · 2.54 KB

GraphHopper Traffic Data Integration

This project makes traffic information integration into GraphHopper possible. In the example we are using real time traffic from Cologne and update every ~2 minutes, the UI will update too. The web UI is basically a slightly changed GraphHopper Maps UI with the traffic data in a separate HTML5 canvas layer:

traffic info preview

The nice thing is that the routing changes immediately after recieving the traffic data, i.e. in real time.

Note: When using the speed mode (prepare.chWeighting=fastest) real time is not possible for large areas as you'll have to prepare the data again after new data arrived which will take roughly 9 minutes for Germany. So only near-real-time.

Start for example area Cologne

Three simple steps:

  • wget http://download.geofabrik.de/europe/germany/nordrhein-westfalen/koeln-regbez-latest.osm.pbf
  • ./td.sh datasource=koeln-regbez-latest.osm.pbf
  • visit http://localhost:8989 to try routing in the UI and see traffic infos

There is an endpoint to fetch all roads with changes which is used for the traffic info:

Start for any area

Disable the update for Cologne in the source, pick your location and start the server for your area:

Now feed some data to '/datafeed':

curl -H "Content-Type: application/json" --data @traffic.json http://localhost:8989/datafeed

... and try routing again. Note, in order to use the provided example traffic.json you'll have to use the specific area, get it here

Traffic influenced routing

Data Format

The data format is very generic and can be used for other information influencing routing:

[{
   "id": "1",
   "points": [[6.827273, 51.190264]],
   "value": 10,
   "value_type": "speed",
   "mode": "REPLACE"
}, {
   "id": "somethingelse",
   "points": ...
}
]

Note, the point list is in geo json and therefor use lon,lat instead of the more common lat,lon order

License

This code stands under the Apache License 2.0

User Interface

The user interface can be modified via npm, then do:

npm install
npm run watch

The traffic information is rendered in map.js via fetching all roads from the /roads endpoint