Search in sources :

Example 11 with MapMatching

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

the class MapMatchingTest method testLoop2.

/**
 * This test is to check that loops are maintained. GPX input:
 * https://graphhopper.com/maps/?point=51.342439%2C12.361615&point=51.343719%2C12.362784&point=51.343933%2C12.361781&point=51.342325%2C12.362607&layer=Lyrk
 */
@ParameterizedTest
@ArgumentsSource(FixtureProvider.class)
public void testLoop2(PMap hints) throws IOException {
    MapMatching mapMatching = new MapMatching(graphHopper, hints);
    // TODO smaller sigma like 40m leads to U-turn at Tschaikowskistraße
    mapMatching.setMeasurementErrorSigma(50);
    Gpx gpx = xmlMapper.readValue(getClass().getResourceAsStream("/tour-with-loop.gpx"), Gpx.class);
    MatchResult mr = mapMatching.match(GpxConversions.getEntries(gpx.trk.get(0)));
    assertEquals(Arrays.asList("Jahnallee, B 87, B 181", "Funkenburgstraße", "Gustav-Adolf-Straße", "Tschaikowskistraße", "Jahnallee, B 87, B 181", "Lessingstraße"), fetchStreets(mr.getEdgeMatches()));
}
Also used : MapMatching(com.graphhopper.matching.MapMatching) MatchResult(com.graphhopper.matching.MatchResult) Gpx(com.graphhopper.jackson.Gpx) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Aggregations

MapMatching (com.graphhopper.matching.MapMatching)11 MatchResult (com.graphhopper.matching.MatchResult)11 Gpx (com.graphhopper.jackson.Gpx)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)7 PMap (com.graphhopper.util.PMap)5 GraphHopper (com.graphhopper.GraphHopper)4 ResponsePath (com.graphhopper.ResponsePath)4 EdgeMatch (com.graphhopper.matching.EdgeMatch)4 Observation (com.graphhopper.matching.Observation)4 GHRequest (com.graphhopper.GHRequest)3 LMProfile (com.graphhopper.config.LMProfile)3 Profile (com.graphhopper.config.Profile)3 GHPoint (com.graphhopper.util.shapes.GHPoint)3 Test (org.junit.jupiter.api.Test)3 XmlMapper (com.fasterxml.jackson.dataformat.xml.XmlMapper)1 GraphHopperConfig (com.graphhopper.GraphHopperConfig)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1