Giter Site home page Giter Site logo

moxuanzhu / graphhopper-traffic-data-integration Goto Github PK

View Code? Open in Web Editor NEW

This project forked from karussell/graphhopper-traffic-data-integration

0.0 1.0 0.0 1.77 MB

[not maintained] Traffic data integration example for GraphHopper

Home Page: https://graphhopper.com/blog/2015/03/18/integrate-your-traffic-data-into-route-planning/

Java 0.63% CSS 0.54% HTML 0.17% JavaScript 98.65% Shell 0.01%

graphhopper-traffic-data-integration's Introduction

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

graphhopper-traffic-data-integration's People

Contributors

1kastner avatar karussell avatar leszekwisniewski avatar rap2363 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.