use of com.graphhopper.matching.Observation in project graphhopper by graphhopper.
the class TrkTest method test2NoMillis.
@Test
public void test2NoMillis() throws IOException {
Gpx gpx = xmlMapper.readValue(getClass().getResourceAsStream("/test2_no_millis.gpx"), Gpx.class);
List<Observation> gpxEntries = GpxConversions.getEntries(gpx.trk.get(0));
assertEquals(3, gpxEntries.size());
assertEquals(51.377719, gpxEntries.get(0).getPoint().lat, 0.0);
assertEquals(12.338217, gpxEntries.get(0).getPoint().lon, 0.0);
}
use of com.graphhopper.matching.Observation in project graphhopper by graphhopper.
the class ExtendedJsonResponseTest method getGpxExtension.
private List<State> getGpxExtension() {
List<State> list = new ArrayList<>();
Snap snap1 = new Snap(-3.4445, -38.9990) {
@Override
public GHPoint3D getSnappedPoint() {
return new GHPoint3D(-3.4446, -38.9996, 0);
}
};
Snap snap2 = new Snap(-3.4445, -38.9990) {
@Override
public GHPoint3D getSnappedPoint() {
return new GHPoint3D(-3.4449, -38.9999, 0);
}
};
list.add(new State(new Observation(new GHPoint(-3.4446, -38.9996)), snap1));
list.add(new State(new Observation(new GHPoint(-3.4448, -38.9999)), snap2));
return list;
}
use of com.graphhopper.matching.Observation 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)));
}
Aggregations