use of com.graphhopper.matching.MapMatching in project graphhopper by graphhopper.
the class MapMatching2Test method testIssue13.
@Test
public void testIssue13() throws IOException {
GraphHopper hopper = new GraphHopper();
hopper.setOSMFile("../map-matching/files/map-issue13.osm.gz");
hopper.setGraphHopperLocation(GH_LOCATION);
hopper.setProfiles(new Profile("my_profile").setVehicle("car").setWeighting("fastest"));
hopper.getLMPreparationHandler().setLMProfiles(new LMProfile("my_profile"));
hopper.importOrLoad();
MapMatching mapMatching = new MapMatching(hopper, new PMap().putObject("profile", "my_profile"));
Gpx gpx = xmlMapper.readValue(getClass().getResourceAsStream("/issue-13.gpx"), Gpx.class);
MatchResult mr = mapMatching.match(GpxConversions.getEntries(gpx.trk.get(0)));
// make sure no virtual edges are returned
int edgeCount = hopper.getGraphHopperStorage().getAllEdges().length();
for (EdgeMatch em : mr.getEdgeMatches()) {
assertTrue(em.getEdgeState().getEdge() < edgeCount, "result contains virtual edges:" + em.getEdgeState().toString());
validateEdgeMatch(em);
}
assertEquals(mr.getGpxEntriesLength(), mr.getMatchLength(), 2.5);
assertEquals(28790, mr.getMatchMillis(), 50);
}
use of com.graphhopper.matching.MapMatching in project graphhopper by graphhopper.
the class MapMatching2Test method testIssue70.
@Test
public void testIssue70() throws IOException {
GraphHopper hopper = new GraphHopper();
hopper.setOSMFile("../map-matching/files/issue-70.osm.gz");
hopper.setGraphHopperLocation(GH_LOCATION);
hopper.setProfiles(new Profile("my_profile").setVehicle("car").setWeighting("fastest"));
hopper.getLMPreparationHandler().setLMProfiles(new LMProfile("my_profile"));
hopper.importOrLoad();
MapMatching mapMatching = new MapMatching(hopper, new PMap().putObject("profile", "my_profile"));
Gpx gpx = xmlMapper.readValue(getClass().getResourceAsStream("/issue-70.gpx"), Gpx.class);
MatchResult mr = mapMatching.match(GpxConversions.getEntries(gpx.trk.get(0)));
assertEquals(Arrays.asList("Милана Видака", "Бранка Радичевића", "Здравка Челара"), fetchStreets(mr.getEdgeMatches()));
for (EdgeMatch edgeMatch : mr.getEdgeMatches()) {
validateEdgeMatch(edgeMatch);
}
}
use of com.graphhopper.matching.MapMatching in project graphhopper by graphhopper.
the class MapMatching2Test method testIssue127.
@Test
public void testIssue127() throws IOException {
GraphHopper hopper = new GraphHopper();
hopper.setOSMFile("../map-matching/files/map-issue13.osm.gz");
hopper.setGraphHopperLocation(GH_LOCATION);
hopper.setProfiles(new Profile("my_profile").setVehicle("car").setWeighting("fastest"));
hopper.getLMPreparationHandler().setLMProfiles(new LMProfile("my_profile"));
hopper.importOrLoad();
MapMatching mapMatching = new MapMatching(hopper, new PMap().putObject("profile", "my_profile"));
// query with two identical points
Gpx gpx = xmlMapper.readValue(getClass().getResourceAsStream("/issue-127.gpx"), Gpx.class);
MatchResult mr = mapMatching.match(GpxConversions.getEntries(gpx.trk.get(0)));
// make sure no virtual edges are returned
int edgeCount = hopper.getGraphHopperStorage().getAllEdges().length();
for (EdgeMatch em : mr.getEdgeMatches()) {
assertTrue(em.getEdgeState().getEdge() < edgeCount, "result contains virtual edges:" + em.getEdgeState().toString());
validateEdgeMatch(em);
}
assertEquals(0, mr.getMatchMillis(), 50);
}
use of com.graphhopper.matching.MapMatching in project graphhopper by graphhopper.
the class MapMatchingTest method testClosePoints.
/**
* This test is to check behavior over short tracks. GPX input:
* https://graphhopper.com/maps/?point=51.342422%2C12.3613358&point=51.3423281%2C12.3613358&layer=Lyrk
*/
@ParameterizedTest
@ArgumentsSource(FixtureProvider.class)
public void testClosePoints(PMap hints) {
MapMatching mapMatching = new MapMatching(graphHopper, hints);
ResponsePath route = graphHopper.route(new GHRequest(new GHPoint(51.342422, 12.3613358), new GHPoint(51.342328, 12.3613358)).setProfile("my_profile")).getBest();
List<Observation> inputGPXEntries = createRandomGPXEntriesAlongRoute(route);
MatchResult mr = mapMatching.match(inputGPXEntries);
assertFalse(mr.getEdgeMatches().isEmpty());
assertEquals(3, mr.getMatchLength(), 1);
// GraphHopper travel times aren't exactly additive
assertThat(Math.abs(route.getTime() - mr.getMatchMillis()), is(lessThan(1000L)));
}
use of com.graphhopper.matching.MapMatching 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);
}
Aggregations