Map Matching pure Java without WebInterface

Hi
i have tried the java snipped Java snipped with success
with

  • Windows
  • map-matching-web-0.7.0-jar-with-dependencies
  • 20160428_baden-wuerttemberg-latest.osm.pbf
  • Bike2WeightFlagEncoder encoder= new Bike2WeightFlagEncoder();

However, I get a lot of warnings like this:

2016-07-14 09:07:29,743 [main] WARN com.graphhopper.reader.osm.conditional.ConditionalTagsInspector - 27841603 - could not parse the conditional value:no @ (PH,SH) of tag:access:conditional. Exception:Unparseable date: “”
2016-07-14 09:07:31,476 [main] WARN com.graphhopper.reader.osm.conditional.ConditionalTagsInspector - 29981421 - could not parse the conditional value:no @ (air_traffic) of tag:access:conditional. Exception:Unparseable date: “air_traffic”
2016-07-14 09:07:38,554 [main] WARN com.graphhopper.reader.osm.conditional.ConditionalTagsInspector - 41748877 - could not parse the conditional value:no @ flooding of tag:access:conditional. Exception:Unparseable date: “flooding”
2016-07-14 09:07:38,564 [main] WARN com.graphhopper.reader.osm.conditional.ConditionalTagsInspector - 41779855 - could not parse the conditional value:no @ flooding of tag:access:conditional. Exception:Unparseable date: “flooding”
2016-07-14 09:07:46,764 [main] WARN com.graphhopper.reader.osm.conditional.ConditionalTagsInspector - 87255787 - could not parse the conditional value:no @ flooding of tag:access:conditional. Exception:Unparseable date: “flooding”
2016-07-14 09:07:46,765 [main] WARN com.graphhopper.reader.osm.conditional.ConditionalTagsInspector - 87255788 - could not parse the conditional value:no @ flooding of tag:access:conditional. Exception:Unparseable date: “flooding”

what am I doing wrong?

Another question:

Can I get a GPX track-string or file from MatchResult like in the Web without my own GPX generator (iterator over the resultset etc…)
If this is possible?
Can you help me and explain that for a silly?

Ok. I have found this

GPXFile gpxFile = new GPXFile(mr, null);
gpxFile.doExport("e:\\temp\\match.gpx");

How can i insert the “elevation” in the gpx MatchResult File?

The elevation is member of “gpxExtensions”


entry:48.9149644,8.7786561,265.87, 1462004507000, query distance:0.02934264632451015, gpxListIndex:9

Best regards
Achim

The warnings are no problem and we’ll disable this in the next release to avoid confusion. The conditional tag warnings just say that some conditional tags are not supported yet.

The GPX track can be created via:

ghResponse.getInstructions().createGPX(trackName, time, includeElevation, withRoute, withTrack, withWayPoints);

or if you prefer JSON:

routeSerializer.toJSON(rsp, true, pointsEncoded, enableElevation, enableInstructions);

See the MatchServlet for more details about this serialization

Elevation have to be enabled when you import the data, see the core docs https://github.com/graphhopper/graphhopper/blob/master/docs/core/elevation.md

…sure, but i have a pure Java Solution without the Web-Interface

// do the actual matching, get the GPX entries from a file or via stream

    List<GPXEntry> inputGPXEntries = new GPXFile().doImport("E:\\MyWorkDir\\zGPS\\testGPX\\2016-04-30 1211__20160430_1211.gpx").getEntries();
    MatchResult mr = mapMatching.doWork(inputGPXEntries);
    GPXFile gpxFile = new GPXFile(mr, null);
    gpxFile.doExport("e:\\temp\\match.gpx");

this generate a gpx file without elevation (lat,lon,time). The elevation is enabled and the values are in the “gpxExtensions”. I have not found a function to enable the “includeElevation:boolean” in the Class GPXFile…

I proposed a Java solution :slight_smile: no web-interface or also not the web-module required. Or what do you mean here?

I have not found a function to enable the “includeElevation:boolean” in the Class GPXFile…

Ah, yes. This is strange. Have added this to the master. Still you can just export the data at your wish.

mean you “MapMatchingMain”?
I have found this yesterday.
I should think you change the

       BBox bbox = BBox.createInverse(false);
        for (File gpxFile : files) {
            List<GPXEntry> inputGPXEntries = new GPXFile().doImport(gpxFile.getAbsolutePath()).getEntries();
            for (GPXEntry entry : inputGPXEntries) {
                if (entry.getLat() < bbox.minLat) {
                    bbox.minLat = entry.getLat();
                }
                if (entry.getLat() > bbox.maxLat) {
                    bbox.maxLat = entry.getLat();
                }
                if (entry.getLon() < bbox.minLon) {
                    bbox.minLon = entry.getLon();
                }
                if (entry.getLon() > bbox.maxLon) {
                    bbox.maxLon = entry.getLon();
                }
            }
        }

i have changed this to

           BBox bbox = BBox.createInverse(true);

                for (GPXEntry entry : inputGPXEntries) {
                    bbox.update(entry.getLat(), entry.getLon(),entry.getEle()); }

I have not found the change in the GPXFile

I have changed this in the source and it fulfilled my wishes. Thanks for the integration. Where is it?

Exist a download from the actual changed packages with depency?

One big missing missing feature for me is the possibility to take the timestamps entrys of the input gpx and set tis in the match gpx correspondingly.

Another nice to have feature is to store the lat,lon on the max/min elevation (maxlat,maxlon,maxele…minlat,minlat,minele)

What do you think about?

I meant MatchServlet, where you can look at how serialization can be done (I didn’t mean to import the web module)

I have not found the change in the GPXFile

Now I have pushed :wink:

Exist a download from the actual changed packages with depency?

The snapshots will be available soonish in the snapshot repository or build the master locally

One big missing missing feature for me is the possibility to take the timestamps entrys of the input gpx and set tis in the match gpx correspondingly.

Yes, this is important. I think there is already an issue for this. If not, please create one.

i have changed this to

What do you mean here?

Another nice to have feature is to store the lat,lon on the max/min elevation

Why not calculate it from the list?

i mean you can simplify the search of minLat and maxLat…etc. in “MapMatchingMain” with your function in the BBox

… bbox.update(entry.getLat(), entry.getLon(),entry.getEle());

1 Like

ich habe die Änderung gesehen…geht aber nur wenn elevation enabled (bisher war das nur 2D)

Sollte man unterscheiden 2D/3D… thanks for the response

Indeed this won’t work. But here we do not need elevation here, so I just changed it to https://github.com/graphhopper/map-matching/commit/3268fb9a3353651026e450872051aa0142fcfa29

If I match my Track I have many,many “Dead Branches”…Is that normal, or can I configure to remove this?

Are you trying the latest master? For this try a different gps accuracy … otherwise it can be more tuning effort.

I have tried this with “graphhopper-web-0.7.0-with-dep.jar”

Exist “latest master”-with-dep.jar ?

Yes. In the snapshot repo

Sorry, exist a map-matching-web Snapshot with depency?

Not of the master yet. Will do probably at some point.

I think is the same result e.g.

Without any data I cannot really help. Also for the master you can reduce gps accuracy which should improve it

You can download my (big) test gpx file from BT747 Datalogger fromhere

i have set
mapMatching.setMeasurementErrorSigma(2);

not working for < 2

Exeptionjava.lang.RuntimeException: Sequence is broken for GPX with 13198 points resulting in 6446 time steps

Thanks for this, will look into it at some point. Lower than 5m probably does not make sense as it is then too strict and won’t find close roads anymore.

Would you mind to export the wrong matching part above to make it easier debuggable for me?

If this brings something, I like to help. But that need not be, if it does not serve the causal thing.
However, it is intended not only to increase employment.
Yoe can split the original track easy with GPS Prune

Now eg Bereich_1


Bereich_2

Download the Gpx
Original Logger track Bereich_1 hier
Match hier

If it further helps to create very like other areas

As written, there are data loggers with significant deviations.

Input: >>>>E:\MyWorkDir\zGPS\matchGPX\input\Bereich_1.gpx<<<<<<
max bounds: 8.7896095,8.7931582,48.8774418,48.9025076,293.062744140625,465.491027832031
export results to:E:\MyWorkDir\zGPS\matchGPX\output\Bereich_1.gpx.match.gpx
matches: 42, gps entries:296
gpx length: 2988.288 vs 7999.0723
gpx time: 590.0 vs 2596.77
Output: >>>>E:\MyWorkDir\zGPS\matchGPX\output\Bereich_1.gpx.match.gpx<<<<<<

Bereich_2
org hier
match hier

Input: >>>>E:\MyWorkDir\zGPS\matchGPX\input\Bereich2.gpx<<<<<<
max bounds: 8.9503978,8.9815632,48.9147024,48.9320946,192.94815063,245.31054688
export results to:E:\MyWorkDir\zGPS\matchGPX\output\Bereich2.gpx.match.gpx
matches: 158, gps entries:417
gpx length: 4384.4155 vs 15973.547
gpx time: 832.0 vs 6157.294
Output: >>>>E:\MyWorkDir\zGPS\matchGPX\output\Bereich2.gpx.match.gpx<<<<<<

1 Like