Search in sources :

Example 6 with EdgeMatch

use of com.graphhopper.matching.EdgeMatch in project graphhopper by graphhopper.

the class MapMatchingTest method fetchStreets.

static List<String> fetchStreets(List<EdgeMatch> emList) {
    List<String> list = new ArrayList<>();
    int prevNode = -1;
    List<String> errors = new ArrayList<>();
    for (EdgeMatch em : emList) {
        // + ":" + em.getEdgeState().getBaseNode() +
        String str = em.getEdgeState().getName();
        // "->" + em.getEdgeState().getAdjNode();
        if (list.size() == 0 || !list.get(list.size() - 1).equals(str))
            list.add(str);
        if (prevNode >= 0) {
            if (em.getEdgeState().getBaseNode() != prevNode) {
                errors.add(str);
            }
        }
        prevNode = em.getEdgeState().getAdjNode();
    }
    if (!errors.isEmpty()) {
        throw new IllegalStateException("Errors:" + errors);
    }
    return list;
}
Also used : EdgeMatch(com.graphhopper.matching.EdgeMatch) ArrayList(java.util.ArrayList) GHPoint(com.graphhopper.util.shapes.GHPoint)

Aggregations

EdgeMatch (com.graphhopper.matching.EdgeMatch)6 MapMatching (com.graphhopper.matching.MapMatching)4 MatchResult (com.graphhopper.matching.MatchResult)4 GraphHopper (com.graphhopper.GraphHopper)3 LMProfile (com.graphhopper.config.LMProfile)3 Profile (com.graphhopper.config.Profile)3 Gpx (com.graphhopper.jackson.Gpx)3 PMap (com.graphhopper.util.PMap)3 Test (org.junit.jupiter.api.Test)3 GHPoint (com.graphhopper.util.shapes.GHPoint)2 ArrayList (java.util.ArrayList)2 GHRequest (com.graphhopper.GHRequest)1 ResponsePath (com.graphhopper.ResponsePath)1 Observation (com.graphhopper.matching.Observation)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)1