Search in sources :

Example 11 with JsonFeatureCollection

use of com.graphhopper.util.JsonFeatureCollection in project graphhopper by graphhopper.

the class IsochroneResourceTest method requestWithShortest.

@Test
public void requestWithShortest() {
    Response rsp = clientTarget(app, "/isochrone").queryParam("profile", "short_car").queryParam("point", "42.509644,1.540554").queryParam("time_limit", 130).queryParam("buckets", 1).queryParam("type", "geojson").request().buildGet().invoke();
    JsonFeatureCollection featureCollection = rsp.readEntity(JsonFeatureCollection.class);
    assertEquals(1, featureCollection.getFeatures().size());
    Geometry polygon0 = featureCollection.getFeatures().get(0).getGeometry();
    assertIs2D(polygon0);
    assertTrue(polygon0.contains(geometryFactory.createPoint(new Coordinate(1.527057, 42.507145))));
    assertFalse(polygon0.contains(geometryFactory.createPoint(new Coordinate(1.525404, 42.507081))));
}
Also used : Response(javax.ws.rs.core.Response) Geometry(org.locationtech.jts.geom.Geometry) Coordinate(org.locationtech.jts.geom.Coordinate) JsonFeatureCollection(com.graphhopper.util.JsonFeatureCollection) Test(org.junit.jupiter.api.Test)

Example 12 with JsonFeatureCollection

use of com.graphhopper.util.JsonFeatureCollection in project graphhopper by graphhopper.

the class IsochroneResourceTest method requestByTimeLimit.

@Test
public void requestByTimeLimit() {
    Response rsp = clientTarget(app, "/isochrone").queryParam("profile", "fast_car").queryParam("point", "42.531073,1.573792").queryParam("time_limit", 5 * 60).queryParam("buckets", 2).queryParam("type", "geojson").request().buildGet().invoke();
    JsonFeatureCollection featureCollection = rsp.readEntity(JsonFeatureCollection.class);
    assertEquals(2, featureCollection.getFeatures().size());
    Geometry polygon0 = featureCollection.getFeatures().get(0).getGeometry();
    Geometry polygon1 = featureCollection.getFeatures().get(1).getGeometry();
    assertTrue(polygon0.contains(geometryFactory.createPoint(new Coordinate(1.587224, 42.5386))));
    assertFalse(polygon0.contains(geometryFactory.createPoint(new Coordinate(1.589756, 42.558012))));
    assertTrue(polygon1.contains(geometryFactory.createPoint(new Coordinate(1.589756, 42.558012))));
    assertFalse(polygon1.contains(geometryFactory.createPoint(new Coordinate(1.635246, 42.53841))));
}
Also used : Response(javax.ws.rs.core.Response) Geometry(org.locationtech.jts.geom.Geometry) Coordinate(org.locationtech.jts.geom.Coordinate) JsonFeatureCollection(com.graphhopper.util.JsonFeatureCollection) Test(org.junit.jupiter.api.Test)

Aggregations

JsonFeatureCollection (com.graphhopper.util.JsonFeatureCollection)12 Test (org.junit.jupiter.api.Test)10 Response (javax.ws.rs.core.Response)8 Coordinate (org.locationtech.jts.geom.Coordinate)8 Geometry (org.locationtech.jts.geom.Geometry)7 JsonFeature (com.graphhopper.util.JsonFeature)2 JtsModule (com.bedatadriven.jackson.datatype.jts.JtsModule)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 WebTarget (javax.ws.rs.client.WebTarget)1 Envelope (org.locationtech.jts.geom.Envelope)1 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)1 LineString (org.locationtech.jts.geom.LineString)1