Search in sources :

Example 11 with MatchResult

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

the class MapMatchingTest method testSmallSeparatedSearchDistance.

/**
 * This test is to check what happens when two GPX entries are on one edge
 * which is longer than 'separatedSearchDistance' - which is always 66m. GPX
 * input:
 * https://graphhopper.com/maps/?point=51.359723%2C12.360108&point=51.358748%2C12.358798&point=51.358001%2C12.357597&point=51.358709%2C12.356511&layer=Lyrk
 */
@ParameterizedTest
@ArgumentsSource(FixtureProvider.class)
public void testSmallSeparatedSearchDistance(PMap hints) throws IOException {
    Gpx gpx = xmlMapper.readValue(getClass().getResourceAsStream("/tour3-with-long-edge.gpx"), Gpx.class);
    MapMatching mapMatching = new MapMatching(graphHopper, hints);
    mapMatching.setMeasurementErrorSigma(20);
    MatchResult mr = mapMatching.match(GpxConversions.getEntries(gpx.trk.get(0)));
    assertEquals(Arrays.asList("Weinligstraße", "Fechnerstraße"), fetchStreets(mr.getEdgeMatches()));
    // TODO: this should be around 300m according to Google ... need to check
    assertEquals(mr.getGpxEntriesLength(), mr.getMatchLength(), 11);
}
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)

Example 12 with MatchResult

use of com.graphhopper.matching.MatchResult 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

MatchResult (com.graphhopper.matching.MatchResult)12 MapMatching (com.graphhopper.matching.MapMatching)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 Test (org.junit.jupiter.api.Test)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 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 XmlMapper (com.fasterxml.jackson.dataformat.xml.XmlMapper)1 GraphHopperConfig (com.graphhopper.GraphHopperConfig)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1