Map Matching (Pillow) Nodes Missing in MatchResult

Hello everyone,

I am using the MapMatch library for map matching. The matching itself based on GPS samples works like a charm in principle. Afterwards I plot the resulting trajectory on an OSM map. Here I noticed, that some nodes are not contained in the resulting route, but in the original map (which is not graphhopper-processed).

See image: red = raw gps, gray = map match result, green = connected map match recult nodes

// inputGPXEntries = red markers
MatchResult mr = mapMatching.doWork(inputGPXEntries);
List<EdgeMatch> matches = mr.getEdgeMatches();
matches.forEach(m -> {
	m.getEdgeState().fetchWayGeometry(3).forEach(p -> {
		MapNode node = map.addMarker((float) p.getLat(), (float) p.getLon()); // gray marker
		markerMgr.addMarker(MapMarkerMgr.MarkerType.Route, node);
		track.add(new DefaultMapNode(0, (float) p.getLat(), (float) p.getLon()));
	});
});

// draw track (green)

Both maps have the same OSM map source (a local OSM file).
I played around with disabling the CH, setting the minimum network size, etc. but I get always the same results.

I am using graphhopper-map-matching-core 0.10.0.

Does anyone have an idea?

Best
Christian

We are doing a minor “douglas peucker” point reduction on import:

You could disable that via providing a custom OSMReader.

And if you are using the web service (I guess you are not) we do a second simplification step to reduce the geometry overhead: https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/GraphHopper.java#L229

1 Like

Thank you very much for the quick reply and the hint. I inherited the OSMReader and disabled the simplification. Maybe would be good to provide a setter for it in future?

Do you have measures with and without simplification in terms of performance and possibly quality?

Edit:
Just realized: Setting setWayPointMaxDistance(0) disables the simplification, too.

Hi @karussell,

after some tesing I figured out, that by setting doSimplify = false in the OSMReader as well as simplifyResponse = false in the GraphHopper, the map matching result int roundabout in the upper picture matches the map data almost perfectly:

But I figured out that there are still some simplifications / optimizations done like shown here:

Do you have any idea why?

Strange. Hopefully no rounding issues. How do you create the GraphHopper object?

Hi @karussell,

I create it as follows:

GraphHopperOSM hopper = new GraphHopperOSM() {
	@Override
	protected DataReader createReader(GraphHopperStorage ghStorage) {
		DataReader reader = initDataReader(new OSMReader(ghStorage));
		reader.setWayPointMaxDistance(0);
		return reader;
	}
};
hopper.forDesktop();
hopper.setWayPointMaxDistance(0);

// import OpenStreetMap data
CarFlagEncoder encoder = new CarFlagEncoder();
hopper.setDataReaderFile(entry.getMapFilePath());
hopper.setGraphHopperLocation(entry.getCacheDirPath());
hopper.setEncodingManager(new EncodingManager(encoder));
hopper.getCHFactoryDecorator().setEnabled(false);
hopper.importOrLoad();

String algorithm = com.graphhopper.util.Parameters.Algorithms.DIJKSTRA_BI;
Weighting weighting = new FastestWeighting(encoder);
AlgorithmOptions algoOptions = new AlgorithmOptions(algorithm, weighting);
mapMatching = new MapMatching(hopper, algoOptions);
MatchResult mr = mapMatching.doWork(inputGPXEntries);