Map Matching -> get back surface and street-type informations

Hey there,
I am using Graphhopper and I did build my own endpoint for map-matching (I have a different coordinate layout)
Everything basically works fine, but what I am missing is any kind of surface or street-type information.
On a regular routing request, I can setPathDetails and specify that I want those values. But I just can’t find that on MapMatching?!?

This is how I instantiate my MapMatching.
Would be amazing if somebody could point me in the right direction :slight_smile:

        val observations = points.map { Observation(it) }
        val hints = PMap()
        hints.putObject("profile", profile)

        val mapMatching = MapMatching.fromGraphHopper(graphHopper, hints)
        val mapMatchingResult = mapMatching.match(observations)

You could try something like this:

  MatchResult mr = mapMatching.match(measurements);
                EnumEncodedValue<Surface> surfaceEnc = hopper.getEncodingManager().getEnumEncodedValue(Surface.KEY, Surface.class);
                List<Surface> surfaces = new ArrayList<>();
                mr.getMergedPath().forEveryEdge(new Path.EdgeVisitor() {
                    @Override
                    public void next(EdgeIteratorState edge, int index, int prevEdgeId) {
                        surfaces.add(edge.get(surfaceEnc));
                    }

                    @Override
                    public void finish() {

                    }
                });

Or, for a higher level API take a look at PathDetailsFromEdges.java. You should be able to extract the path details for the map-matched path in a similar way it is done for regular routing.

1 Like

Awesome! That helps a lot! Thank you!