use of org.locationtech.jts.geom.LineString in project graphhopper by graphhopper.
the class MapMatchingResourceTurnCostsTest method runCar.
private void runCar(String urlParams) {
final Response response = app.client().target("http://localhost:8080/match?" + urlParams).request().buildPost(Entity.xml(getClass().getResourceAsStream("another-tour-with-loop.gpx"))).invoke();
JsonNode json = response.readEntity(JsonNode.class);
assertFalse(json.has("message"), json.toString());
assertEquals(200, response.getStatus());
JsonNode path = json.get("paths").get(0);
LineString expectedGeometry = readWktLineString("LINESTRING (12.3607 51.34365, 12.36418 51.34443, 12.36379 51.34538, 12.36082 51.34471, 12.36188 51.34278)");
LineString actualGeometry = ResponsePathDeserializer.decodePolyline(path.get("points").asText(), 10, false).toLineString(false);
assertEquals(DiscreteHausdorffDistance.distance(expectedGeometry, actualGeometry), 0.0, 1E-4);
assertEquals(106.15, path.get("time").asLong() / 1000f, 0.1);
assertEquals(106.15, json.get("map_matching").get("time").asLong() / 1000f, 0.1);
assertEquals(811.56, path.get("distance").asDouble(), 1);
assertEquals(811.56, json.get("map_matching").get("distance").asDouble(), 1);
}
use of org.locationtech.jts.geom.LineString in project graphhopper by graphhopper.
the class MapMatchingResourceTurnCostsTest method readWktLineString.
private LineString readWktLineString(String wkt) {
WKTReader wktReader = new WKTReader();
LineString expectedGeometry = null;
try {
expectedGeometry = (LineString) wktReader.read(wkt);
} catch (ParseException e) {
e.printStackTrace();
}
return expectedGeometry;
}
use of org.locationtech.jts.geom.LineString in project graphhopper by graphhopper.
the class MapMatchingResourceTurnCostsTest method runBike.
private void runBike(String urlParams) {
final Response response = app.client().target("http://localhost:8080/match?" + urlParams).request().buildPost(Entity.xml(getClass().getResourceAsStream("another-tour-with-loop.gpx"))).invoke();
JsonNode json = response.readEntity(JsonNode.class);
assertFalse(json.has("message"), json.toString());
assertEquals(200, response.getStatus());
JsonNode path = json.get("paths").get(0);
LineString expectedGeometry = readWktLineString("LINESTRING (12.3607 51.34365, 12.36418 51.34443, 12.36379 51.34538, 12.36082 51.34471, 12.36188 51.34278)");
LineString actualGeometry = ResponsePathDeserializer.decodePolyline(path.get("points").asText(), 10, false).toLineString(false);
assertEquals(DiscreteHausdorffDistance.distance(expectedGeometry, actualGeometry), 0.0, 1E-4);
assertEquals(162.31, path.get("time").asLong() / 1000f, 0.1);
assertEquals(162.31, json.get("map_matching").get("time").asLong() / 1000f, 0.1);
assertEquals(811.56, path.get("distance").asDouble(), 1);
assertEquals(811.56, json.get("map_matching").get("distance").asDouble(), 1);
}
use of org.locationtech.jts.geom.LineString in project graphhopper by graphhopper.
the class MapMatchingResourceTest method testGPX.
@Test
public void testGPX() {
final Response response = app.client().target("http://localhost:8080/match?profile=fast_car").request().buildPost(Entity.xml(getClass().getResourceAsStream("/tour2-with-loop.gpx"))).invoke();
assertEquals(200, response.getStatus());
JsonNode json = response.readEntity(JsonNode.class);
JsonNode path = json.get("paths").get(0);
LineString expectedGeometry = readWktLineString("LINESTRING (12.3607 51.34365, 12.36418 51.34443, 12.36379 51.34538, 12.36082 51.34471, 12.36188 51.34278)");
LineString actualGeometry = ResponsePathDeserializer.decodePolyline(path.get("points").asText(), 10, false).toLineString(false);
assertEquals(DiscreteHausdorffDistance.distance(expectedGeometry, actualGeometry), 0.0, 1E-4);
assertEquals(106.15, path.get("time").asLong() / 1000f, 0.1);
assertEquals(106.15, json.get("map_matching").get("time").asLong() / 1000f, 0.1);
assertEquals(811.56, path.get("distance").asDouble(), 1);
assertEquals(811.56, json.get("map_matching").get("distance").asDouble(), 1);
}
use of org.locationtech.jts.geom.LineString in project graphhopper by graphhopper.
the class MapMatchingResourceTest method readWktLineString.
private LineString readWktLineString(String wkt) {
WKTReader wktReader = new WKTReader();
LineString expectedGeometry = null;
try {
expectedGeometry = (LineString) wktReader.read(wkt);
} catch (ParseException e) {
e.printStackTrace();
}
return expectedGeometry;
}
Aggregations