| Forum | GitHub | Maps | Blog

Snapping very innacurate data


I’m looking to attempt to snap some very innacurate position estimates to a route. I’ve replicated Trang’s modification to the GPX filtering described at Map MatchResult to GPXEntry
and have used a low value for GPX filter threshold (50m), and a high value for the “GPS accuracy” (4000m). As an example, the input picture needs to map as close as possible to the true position.
Yet when I use GraphHopper I get the following output from the GPXExtensions of the MatchResult:
which seems to imply that the input points are not actually being moved very much despite the setting of measurementErrorSigma in MapMatching to 4000m. Is this expected behaviour? The longest “discontinuity” in the plot is about 2.5km (!)

My code is basically:

CarFlagEncoder encoder = new CarFlagEncoder();
AlgorithmOptions chOpts = AlgorithmOptions.start().maxVisitedNodes(1000)
    .hints(new PMap().put(Parameters.CH.DISABLE, false))
GraphHopper hopper = new GraphHopperOSM();
hopper.setEncodingManager(new EncodingManager(encoder));
MapMatching mm = new MapMatching(hopper, chOpts);
mm.setMeasurementErrorSigma(POSITION_ACCURACY_METRES);    //4000.0
mm.setGPXFilterThreshold(GPX_FILTER_METRES);  //50.0
MatchResult mr = mm.doWork(inputGPXEntries);

The final plot is obtained via:

for(EdgeMatch match : matches){
    for(GPXExtension ge : match.getGpxExtensions()){
        // plot ge.getEntry().getLat()/.getLon()

Lastly, I’m attempting to add a 1-1 mapping of GH outputs to my input GPX, and so I’m looking at the edgeState within the matches in the matchResult. Would the following be the correct way to build the route in Lat/Lon space? If so, how do I get the timestamps for each point?

final List<EdgeMatch> matches = mr.getEdgeMatches();
List<Coordinate> wayPoints = new ArrayList<>();   //Coordinate is basically (lon,lat)
for (final EdgeMatch match : matches) {
    final EdgeIteratorState s = match.getEdgeState();
    PointList pl = s.fetchWayGeometry(1);
    for (GHPoint3D p : pl){
        wayPoints.add(new Coordinate(p));