Offline map matching on gpx files usage

Hello, I’ve made a little python code to try out the map matching api, using a test gps file made with the gpxpy library. To do this, I made a fairly large test .gps file that looks (with some points removed) like this:

<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1" creator="gpx.py -- https://github.com/tkrajina/gpxpy">
  <trk>
    <trkseg>
      <trkpt lat="46.484927" lon="6.351695">
        <ele>583.0606079101562</ele>
        <time>2018-01-08T08:11:59Z</time>
      </trkpt>
      <trkpt lat="46.484865" lon="6.351457">
        <ele>586.5311889648438</ele>
        <time>2018-01-08T08:12:00Z</time>
      </trkpt>
      <trkpt lat="46.484831" lon="6.351277">
        <ele>589.6990356445312</ele>
        <time>2018-01-08T08:12:01Z</time>
      </trkpt>
    </trkseg>
  </trk>
</gpx>

But when I try to use the API with this code :

    url = "http://localhost:8989/match?profile=car&type=json"
    headers = {"Content-Type": "application/gpx+xml"}
    data = open("data/test.gpx", "rb").read()
    response = requests.post(url, headers=headers, data=data)
    matched_data = response.json()
    print(matched_data)

I get : {‘message’: ‘Sequence is broken for submitted track at initial time step.’, ‘hints’: [{‘message’: ‘Sequence is broken for submitted track at initial time step.’, ‘details’: ‘java.lang.IllegalArgumentException’}]}

I’ve searched a bit and tried different GPS files but I still haven’t figured out how to solve the problem.

Can you try if it still occurs for different (bigger than default) gps_accuracy values? E.g. &gps_accuracy=30

Hello, yeah it is sadly the same, I tried with 30, 60, 100 and 200 but still the same error message.

code changed :

    url = "http://localhost:8989/match?profile=car&type=json&gps_accuracy=200"

Does planning a plain car route from 46.484927,6.351695 to 46.484831, 6.351277 work on your local Graphhopper instance ?

1 Like

I’m maybe a bit too new to fully understand what you mean by that, but when I try to put the two points on the localhost map instance i get :

The error (using gps file from web ressources) and is the command line :

java -jar graphhopper-web-*.jar match --file config-example.yml --profile car ../backendEstimateurPhysique/data/test1.gpx

I get :

2023-11-24 15:52:02.645 [main] INFO  c.g.routing.ch.CHPreparationHandler - There are no CHs to prepare
2023-11-24 15:52:02.647 [main] INFO  com.graphhopper.GraphHopper - version 8.0|2023-10-17T10:01:00Z (9,21,6,5,2,9)
2023-11-24 15:52:02.647 [main] INFO  com.graphhopper.GraphHopper - graph car|RAM_STORE|2D|no_turn_cost|nodes:9,edges:21,geometry:6,location_index:5,string_index:2,nodesCH:0,shortcuts:9, details:edges: 299,402(11MB), nodes: 269,446(4MB), bounds: 13.069778,13.7624957,52.327972,52.6796166, name:(1MB), geo:279,193(2MB)
Problem with file ../backendEstimateurPhysique/data/test1.gpx
java.lang.IllegalArgumentException: Sequence is broken for submitted track at initial time step.
	at com.graphhopper.matching.MapMatching.computeViterbiSequence(MapMatching.java:438)
	at com.graphhopper.matching.MapMatching.match(MapMatching.java:217)
	at com.graphhopper.application.cli.MatchCommand.run(MatchCommand.java:123)
	at com.graphhopper.application.cli.MatchCommand.run(MatchCommand.java:45)
	at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:98)
	at io.dropwizard.cli.Cli.run(Cli.java:78)
	at io.dropwizard.Application.run(Application.java:94)
	at com.graphhopper.application.GraphHopperApplication.main(GraphHopperApplication.java:38)
gps import took:0.03910448s, match took: 0.028638585

And on the log :

2023-11-24 15:52:02.645 [main] INFO  c.g.routing.ch.CHPreparationHandler - There are no CHs to prepare
2023-11-24 15:52:02.647 [main] INFO  com.graphhopper.GraphHopper - version 8.0|2023-10-17T10:01:00Z (9,21,6,5,2,9)
2023-11-24 15:52:02.647 [main] INFO  com.graphhopper.GraphHopper - graph car|RAM_STORE|2D|no_turn_cost|nodes:9,edges:21,geometry:6,location_index:5,string_index:2,nodesCH:0,shortcuts:9, details:edges: 299,402(11MB), nodes: 269,446(4MB), bounds: 13.069778,13.7624957,52.327972,52.6796166, name:(1MB), geo:279,193(2MB)