Getting map-matcher working

Hello,
I’m looking to get the map-matching functionality going to eventually use in my own application. I followed the instructions in the map-matching subfolder of the graphhopper repo, and after launching the 2.3 web app and trying to access http://localhost:8989/maps/map-matching/ I get a 404.

Next I checked out the repo and built all the modules from the root running mvn package -DskipTests. From here though I’m not sure how to use the functionality. The README of the archived map-matcher repo refers to matching-web/target/graphhopper-map-matching-web-3.0-SNAPSHOT.jar, which exists in the now Archived map-matching repo, but not in the main repo.

Substituting the matching web jar for the map-matching one in the command didn’t work either. Can someone shed some light on how to run it in the main repo map-matching version?

Ok, so with a bit of faffing around and digging into the source code I was able to get this working.

  1. Check out the https://github.com/graphhopper/graphhopper repo
  2. From the root of the project, build it: mvn package -DskipTests
  3. Run the server as per the install guide, except substitute the 2.3 jar from the web for the jar built in the web submodule e.g. graphhopper/web/target/graphhopper-web-3.0-SNAPSHOT.jar. The run command should look something like: java -Ddw.graphhopper.datareader.file=victoria-latest.osm.pbf -jar graphhopper-web-3.0-SNAPSHOT.jar server config-example.yml
  4. Now do a POST using a valid GPX file with a track in it: e.g. curl -XPOST -H "Content-Type: application/gpx+xml" -d @myfile.gpx "localhost:8989/match?vehicle=car&type=json"

I suspect that the updated repo for 3.0 hasn’t been ‘released’, nor the READMEs updated.

Thanks for figuring this out and sharing your solution. Yes, 3.0 has not been released and the latest release is 2.3. What information were you missing exactly in the main graphhopper repository (on master)?

What information were you missing exactly in the main graphhopper repository (on master)?

I think the main things are:

  • 2.3 version doesn’t contain the /match endpoint
  • 2.3 version doesn’t contain the /maps/map-matching/ GUI
  • To run the map-matching functionality in 3.0, you need to build the whole project and then invoke the /match endpoint
  • It’s still not clear how you can run the map-matching functionality from the command line in the main graphhopper project without running the web module and POSTing to it
2 Likes

Yes the map-matching repository was moved into the main repository after 2.3 and the main repository only contains map-matching starting with 3.0 or some of its pre-releases. You also need to build the whole project yes, otherwise e.g. the web UI won’t be available.

You can run map-matching without running the GH server and POSTing to it using the MatchCommand (see MatchCommand.java). But you are right this is not mentioned in the documentation of the main repository. @karussell is there a reason we did not document the match command?

I don’t think there is a reason. Probably got lost when moving the repo inside.

I updated the docs here: https://github.com/graphhopper/graphhopper/commit/c33aede00c76a4541d6b8e86a5f746604c9f4da9 Does this make it clear?

@easbar I am still a bit confused. Build from source, But getting 404 error on map-matching

You build from source for current master? What do you mean ‘getting 404 error on map-matching’? Are you talking about the UI or the server endpoint?

Okay, I got this. Sorry.

But now, I have a question.
I am map matching a gpx file, On UI, the distance is different from the CURL response.

I have attached the UI output.

Following is the curl response for same gpx file. What could be the reason for distance being different?

{"hints":{},"info":{"copyrights":["GraphHopper","OpenStreetMap contributors"],"took":0},"paths":[{"distance":1956.527,"weight":9.223372036854775E12,"time":204208,"transfers":0,"points_encoded":true,"bbox":[86.175213,22.788327,86.183492,22.796143],"points":"ibbjC{q_mO?yBhGCiGB?bD?tE?dO?fFZhFwF~@y@Jy@AeAMsBe@q@KwAV{Ad@s@n@Yd@qAPWHm@P[P_AV_APqBXm@CJKPu@C_@Eq@Dp@AY","instructions":[{"distance":62.506,"heading":89.83,"sign":0,"interval":[0,1],"text":"Continue","time":7499,"street_name":""},{"distance":147.909,"sign":2,"interval":[1,2],"text":"Turn right","time":17748,"street_name":""},{"distance":147.909,"sign":-3,"interval":[2,3],"text":"Turn sharp left","time":17748,"street_name":""},{"distance":83.883,"sign":-2,"interval":[3,4],"text":"Turn left","time":10064,"street_name":""},{"distance":110.272,"sign":7,"interval":[4,5],"text":"Keep right","time":13231,"street_name":""},{"distance":265.456,"sign":7,"interval":[5,6],"text":"Keep right","time":31853,"street_name":""},{"distance":119.209,"sign":7,"interval":[6,7],"text":"Keep right","time":14304,"street_name":""},{"distance":120.001,"sign":7,"interval":[7,8],"text":"Keep right","time":14399,"street_name":""},{"distance":341.521,"sign":2,"interval":[8,14],"text":"Turn right","time":20485,"street_name":""},{"distance":50.789,"sign":-7,"interval":[14,15],"text":"Keep left","time":3047,"street_name":""},{"distance":116.756,"sign":7,"interval":[15,18],"text":"Keep right","time":7002,"street_name":""},{"distance":60.735,"sign":7,"interval":[18,20],"text":"Keep right","time":7287,"street_name":""},{"distance":83.072,"sign":7,"interval":[20,23],"text":"Keep right","time":9966,"street_name":""},{"distance":36.553,"sign":7,"interval":[23,24],"text":"Keep right","time":4385,"street_name":""},{"distance":90.533,"sign":7,"interval":[24,26],"text":"Keep right","time":10862,"street_name":""},{"distance":55.211,"sign":3,"interval":[26,29],"text":"Turn sharp right","time":6624,"street_name":""},{"distance":25.513,"sign":7,"interval":[29,30],"text":"Keep right","time":3061,"street_name":""},{"distance":25.513,"sign":-3,"interval":[30,31],"text":"Turn sharp left","time":3061,"street_name":""},{"distance":13.185,"sign":-3,"interval":[31,32],"text":"Turn sharp left","time":1582,"street_name":""},{"distance":0.0,"sign":4,"last_heading":82.58613659015685,"interval":[32,32],"text":"Arrive at destination","time":0,"street_name":""}],"legs":[],"details":{},"ascend":0.0,"descend":0.0,"snapped_waypoints":""}],"map_matching":{"original_distance":3079.1457730875422,"distance":1956.5265587899803,"time":204208}}%