• This repository has been archived on 02/Mar/2021
  • Stars
    star
    780
  • Rank 56,408 (Top 2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The map matching functionality is now located in the main repository https://github.com/graphhopper/graphhopper#map-matching

Map Matching based on GraphHopper

Build Status

Snaps GPX traces to the road using the GraphHopper routing engine.

Read more about the map matching problem at Wikipedia.

See the demo in action (black is GPS track, green is matched result):

map-matching-example

License

Apache License 2.0

Discussion

Our web forum is here.

Usage

Java 8 and Maven >=3.3 are required.

Build:

mvn package -DskipTests

Then you need to import an OSM map for the area you want to do map-matching on, e.g. the provided sample data:

java -jar matching-web/target/graphhopper-map-matching-web-3.0-SNAPSHOT.jar import map-data/leipzig_germany.osm.pbf

OpenStreetMap data in pbf or xml format are available from here.

The optional parameter --vehicle defines the routing profile like car, bike, motorcycle or foot. You can also provide a comma separated list. For all supported values see the variables in the FlagEncoderFactory of GraphHopper.

Before re-importing, you need to delete the graph-cache directory, which is created by the import.

Now you can match GPX traces against the map:

java -jar matching-web/target/graphhopper-map-matching-web-3.0-SNAPSHOT.jar match matching-web/src/test/resources/*.gpx

If you were using multiple vehicles for the import you can use --vehicle to select one of them, otherwise the first one will be used.

Web app

Start via:

java -jar matching-web/target/graphhopper-map-matching-web-3.0-SNAPSHOT.jar server config.yml

Access the simple UI via localhost:8989.

You can post GPX files and get back snapped results as GPX or as compatible GraphHopper JSON. An example curl request is:

curl -XPOST -H "Content-Type: application/gpx+xml" -d @matching-web/src/test/resources/test1.gpx "localhost:8989/match?vehicle=car&type=json"

Tools

Determine the bounding box of one or more GPX files:

java -jar matching-web/target/graphhopper-map-matching-web-3.0-SNAPSHOT.jar getbounds matching-web/src/test/resources/*.gpx

Java usage

Have a look at MapMatchingResource.java to see how the web service is implemented on top of library functions to get an idea how to use map matching in your own project.

Use this Maven dependency:

<dependency>
    <groupId>com.graphhopper</groupId>
    <artifactId>graphhopper-map-matching-core</artifactId>
    <version>3.0-SNAPSHOT</version>
</dependency>

Note

Note that the edge and node IDs from GraphHopper will change for different PBF files, like when updating the OSM data.

About

The map matching algorithm mainly follows the approach described in

Newson, Paul, and John Krumm. "Hidden Markov map matching through noise and sparseness." Proceedings of the 17th ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems. ACM, 2009.

This algorithm works as follows. For each input GPS position, a number of map matching candidates within a certain radius around the GPS position is computed. The Viterbi algorithm as provided by the hmm-lib is then used to compute the most likely sequence of map matching candidates. Thereby, the distances between GPS positions and map matching candidates as well as the routing distances between consecutive map matching candidates are taken into account. The GraphHopper routing engine is used to find candidates and to compute routing distances.

Before GraphHopper 0.8, this faster but more heuristic approach was used.

More Repositories

1

graphhopper

Open source routing engine for OpenStreetMap. Use it as Java library or standalone web server.
Java
4,727
star
2

jsprit

jsprit is a java based, open source toolkit for solving rich vehicle routing problems
Java
1,571
star
3

open-traffic-collection

Collection of open data resources for traffic information
375
star
4

directions-api-js-client

JavaScript client for the GraphHopper Directions API
JavaScript
103
star
5

graphhopper-navigation-example-legacy

GraphHopper Navigation as App
Java
91
star
6

graphhopper-maps

GraphHopper Maps - Open Source Route Planner UI
TypeScript
77
star
7

graphhopper-ios

iOS Port of the GraphHopper road routing engine
Objective-C
68
star
8

directions-api

Issues for the GraphHopper Directions API
60
star
9

directions-api-clients

API clients for various languages for the GraphHopper Directions API
C#
30
star
10

graphhopper-navigation

Provides a GraphHopper web service for navigation apps
Java
27
star
11

directions-api-java-client

Deprecated Repo for the Java and Android client for the GraphHopper Directions API
Java
27
star
12

timezone

Timezone project providing a simple way to turn location and unix timestamp into timezone and local time.
Java
23
star
13

jackson-datatype-jts

Jackson serializers for JTS Geometry objects
Java
11
star
14

graphhopper-navigation-example

GraphHopper Navigation Example using the Maplibre Android SDK
Kotlin
9
star
15

graphhopper-reader-shp

Read shapefiles e.g. from ESRI into GraphHopper
Java
9
star
16

geocoder-converter

Converts arbitrary geocoding responses to a GraphHopper response
Java
8
star
17

isochrone-experiments

Some experiments with isochrones
JavaScript
7
star
18

vehicle-charging-station-example

This example uses the GraphHopper Matrix API to pick a charging station for the overall fastest detour
JavaScript
5
star
19

graphhopper-experiments

[deprecated] Experiments with lucene, neo4j and road routing via GraphHopper
Java
2
star
20

custom-model-editor

Interactive text editor for creating GraphHopper's custom models
JavaScript
1
star
21

cheerpj-demo

GraphHopper running in the browser via CheerpยฎJ
JavaScript
1
star