graphhopper / map-matching

The map matching functionality is now located in the main repository https://github.com/graphhopper/graphhopper#map-matching
https://www.graphhopper.com/open-source/
Apache License 2.0
785 stars 273 forks source link

Results are quite bad #140

Closed anonym24 closed 5 years ago

anonym24 commented 5 years ago

1 screenshot - Raw GPS Data (Green polyline):

image

2 screenshot - Raw GPS Data (Green polyline) + GraphHopper MapMatching (Blue polyline):

Such a weird result (it just turned to a completely different side, and some lines are not even on the road)

image

3 screenshot - Raw GPS Data (Green polyline) + Project-OSRM match feature (Yellow polyline):

This yellow matching map route I got from online test service Project-OSRM: http://router.project-osrm.org/match/v1/driving/[YOUR_POINTS]?overview=false&steps=true&timestamps=[YOUR_TIMES] As you see it works very good (I didn't even change/add any parameters, just tested it once and worked ok)

image

So what could be wrong with GraphHopper Map Matching method? Why did it give so bad result?

Code:

    private final static double TRANSITION_PROBABILITY_BETA = 2;
    private final static int GPS_ACCURACY = 40;
    private final static String INSTRUCTIONS = "";
    private final static int MAX_VISITED_NODES = 1000;

    public void match(GraphHopper hopper, List<GPXEntry> measurements) {
        FlagEncoder firstEncoder = hopper.getEncodingManager().fetchEdgeEncoders().get(0);

        AlgorithmOptions opts = AlgorithmOptions.start()
                .algorithm(Parameters.Algorithms.DIJKSTRA_BI)
                .traversalMode(hopper.getTraversalMode())
                .weighting(new FastestWeighting(firstEncoder))
                .maxVisitedNodes(MAX_VISITED_NODES)
                .hints(new HintsMap()
                        .put("weighting", "fastest")
                        .put("vehicle", firstEncoder.toString()))
                .build();

        MapMatching mapMatching = new MapMatching(hopper, opts);
        mapMatching.setTransitionProbabilityBeta(TRANSITION_PROBABILITY_BETA);
        mapMatching.setMeasurementErrorSigma(GPS_ACCURACY);

        MatchResult mr = mapMatching.doWork(measurements);

        Translation tr = new TranslationMap().doImport().getWithFallBack(Helper.getLocale(INSTRUCTIONS));
        PathWrapper pathWrapper = new PathWrapper();
        new PathMerger().doWork(pathWrapper, Collections.singletonList(mr.getMergedPath()), tr);

        List<GPXEntry> matchedList = pathWrapper.getInstructions().createGPXList();
    }

I tried to play with all of the constants and Parameters.Algorithms but nothing of that helped

boldtrn commented 5 years ago

To me this looks like GraphHopper thinks the road in the south west is not passable. Please use the forum for questions. Please also add a gpx file or at least coordinates of the route so that we can replicate this situation.

anonym24 commented 5 years ago

Yes, actually that road isn't passable for cars. Then I'll ask the question on the forum tomorrow about setting "foot" as "vehicle" (how to make it work), because now it only works with "car" - when I set others it fails