I am using map-matching to snap gps tracks onto OSM ways.
Everything worked well with the v0.5 release, but since it is a bit old (and since I have problems reading one very dirty GPS file with v0.5) I want to switch to v0.8.2
Most of the changes were not hard to do, but when it comes to the public API of the map matching class, things are a bit different… maxSearchMultiplier and forceRepair, but these options are gone in v0.8.2.
The new release is not able to match all my gps data, so I get some IllegalStateExceptions when calling the mapMatching.doWork method.
My test cases look like this:
@BeforeClass
public void setup() throws IOException {
final CmdArgs cmdArgs = CmdArgs.readFromConfig(DEFAULT_CONFIG, "-Dgraphhopper.config");
cmdArgs.put("datareader.file", TestHelper.OSM_PBF); // this references northern italy -> nord-est-latest.odm.pbf (downloaded from geofabrik on 12.12.2016)
cmdArgs.put("graph.flag_encoders", FLAG_ENCODER); // "car"
hopper = new GraphHopperOSM();
hopper.init(cmdArgs);
hopper.importOrLoad();
}
@Test
public void testMatchingFromEntries6() {
final List<GPXEntry> gpxEntries = new ArrayList<>(8);
// CHECKSTYLE:OFF MagicNumber
gpxEntries.add(new GPXEntry(46.5512487944, 11.5802821890, 1240.24, 1435593069000L));
gpxEntries.add(new GPXEntry(46.5509882849, 11.5804614779, 1243.12, 1435593083000L));
gpxEntries.add(new GPXEntry(46.5507211536, 11.5805916488, 1246.01, 1435593097000L));
gpxEntries.add(new GPXEntry(46.5504538547, 11.5807677526, 1249.37, 1435593112000L));
gpxEntries.add(new GPXEntry(46.5502403677, 11.5810426790, 1252.25, 1435593127000L));
gpxEntries.add(new GPXEntry(46.5501144715, 11.5813252330, 1254.66, 1435593139000L));
gpxEntries.add(new GPXEntry(46.5499776788, 11.5817076992, 1258.02, 1435593155000L));
gpxEntries.add(new GPXEntry(46.5498498548, 11.5820614994, 1260.43, 1435593170000L));
// CHECKSTYLE:ON MagicNumber
final FlagEncoder encoder = hopper.getEncodingManager().getEncoder(FLAG_ENCODER);
final AlgorithmOptions opt = AlgorithmOptions.start().weighting(new ShortestWeighting(encoder)).build();
final MapMatching mapMatching = new MapMatching(hopper, opt);
mapMatching.setDistanceCalc(Helper.DIST_EARTH);
// mapMatching.setMeasurementErrorSigma(500d);
int nrFound = 0;
int nrSkipped = 0;
try {
final MatchResult mr = mapMatching.doWork(gpxEntries);
final List<EdgeMatch> edgeMatches = mr.getEdgeMatches();
nrFound += edgeMatches.size();
} catch (final IllegalArgumentException | IllegalStateException e) {
// Skip track parts, which could not be matched to an edge in OSM}
nrSkipped++;
}
Assert.assertEquals(nrSkipped, 0, "No edge was found during mapMatching");
Assert.assertEquals(nrFound, 1, "Number of found edges is invalid (multiple edges found?)");
}
As a result I get one skipped edge and therefore “No edge was found during mapMatching”.
If I print my points on a map then it looks like it could be matched easily. I also tried to increase measurementErrorSigma really high (which helped for some other gpxEntryLists, but not the one referenced above).
Could someone please explain to me, why this map matching does not work (and why it did work with v0.5).
Cheers,
Niko