Search in sources :

Example 1 with GHGeocodingResponse

use of com.graphhopper.api.model.GHGeocodingResponse in project graphhopper by graphhopper.

the class GraphHopperGeocodingIT method testReverseGeocoding.

@Test
public void testReverseGeocoding() {
    GHGeocodingResponse response = geocoding.geocode(new GHGeocodingRequest(52.5170365, 13.3888599, "en", 5));
    assertEquals(5, response.getHits().size());
    GHGeocodingEntry entry = response.getHits().get(0);
    assertTrue(entry.getName().contains("Berlin"));
    assertEquals("place", entry.getOsmKey());
    assertEquals(0, entry.getExtent().length);
}
Also used : GHGeocodingRequest(com.graphhopper.api.model.GHGeocodingRequest) GHGeocodingEntry(com.graphhopper.api.model.GHGeocodingEntry) GHGeocodingResponse(com.graphhopper.api.model.GHGeocodingResponse) Test(org.junit.Test)

Example 2 with GHGeocodingResponse

use of com.graphhopper.api.model.GHGeocodingResponse in project graphhopper by graphhopper.

the class GraphHopperGeocodingIT method testExtent.

@Test
public void testExtent() {
    GHGeocodingResponse response = geocoding.geocode(new GHGeocodingRequest("new york", "en", 7));
    BBox extent = response.getHits().get(0).getExtendBBox();
    assertTrue(extent.isValid());
    assertTrue(extent.minLon < -79);
    assertTrue(extent.maxLon > -72);
    assertTrue(extent.minLat < 40.5);
    assertTrue(extent.maxLat > 45);
}
Also used : BBox(com.graphhopper.util.shapes.BBox) GHGeocodingRequest(com.graphhopper.api.model.GHGeocodingRequest) GHGeocodingResponse(com.graphhopper.api.model.GHGeocodingResponse) Test(org.junit.Test)

Example 3 with GHGeocodingResponse

use of com.graphhopper.api.model.GHGeocodingResponse in project graphhopper by graphhopper.

the class GraphHopperGeocodingIT method testForwardGeocoding.

@Test
public void testForwardGeocoding() {
    GHGeocodingResponse response = geocoding.geocode(new GHGeocodingRequest("Berlin", "en", 7));
    assertEquals(7, response.getHits().size());
    assertTrue(response.getHits().get(0).getName().contains("Berlin"));
}
Also used : GHGeocodingRequest(com.graphhopper.api.model.GHGeocodingRequest) GHGeocodingResponse(com.graphhopper.api.model.GHGeocodingResponse) Test(org.junit.Test)

Example 4 with GHGeocodingResponse

use of com.graphhopper.api.model.GHGeocodingResponse in project graphhopper by graphhopper.

the class GraphHopperGeocodingIT method testForwardGeocodingNominatim.

@Test
public void testForwardGeocodingNominatim() {
    GHGeocodingResponse response = geocoding.geocode(new GHGeocodingRequest(false, null, "Berlin", "en", 5, "nominatim", 5000));
    assertEquals(5, response.getHits().size());
    assertTrue(response.getHits().get(0).getName().contains("Berlin"));
}
Also used : GHGeocodingRequest(com.graphhopper.api.model.GHGeocodingRequest) GHGeocodingResponse(com.graphhopper.api.model.GHGeocodingResponse) Test(org.junit.Test)

Aggregations

GHGeocodingRequest (com.graphhopper.api.model.GHGeocodingRequest)4 GHGeocodingResponse (com.graphhopper.api.model.GHGeocodingResponse)4 Test (org.junit.Test)4 GHGeocodingEntry (com.graphhopper.api.model.GHGeocodingEntry)1 BBox (com.graphhopper.util.shapes.BBox)1