use of org.codice.ddf.spatial.geocoder.GeoResult in project ddf by codice.
the class TestGeoNamesLocalIndex method testWithNoResults.
@Test
public void testWithNoResults() throws GeoEntryQueryException {
final List<GeoEntry> noResults = Collections.emptyList();
doReturn(noResults).when(geoEntryQueryable).query("Tempe", 1);
final GeoResult geoResult = geoNamesLocalIndex.getLocation("Tempe");
assertThat(geoResult, is(nullValue()));
}
use of org.codice.ddf.spatial.geocoder.GeoResult in project ddf by codice.
the class GeoCoderServiceImpl method doQuery.
JSONObject doQuery(String query) {
GeoCoder geoCoder = geoCoderFactory.getService();
GeoResult geoResult = null;
if (geoCoder != null) {
geoResult = geoCoder.getLocation(query);
}
JSONObject jsonObject = new JSONObject();
JSONArray resourceSets = new JSONArray();
JSONObject resourceSet = new JSONObject();
jsonObject.put("resourceSets", resourceSets);
resourceSets.add(resourceSet);
JSONArray resources = new JSONArray();
resourceSet.put("resources", resources);
if (geoResult != null) {
transformGeoResult(geoResult, resources);
}
return jsonObject;
}
use of org.codice.ddf.spatial.geocoder.GeoResult in project ddf by codice.
the class TestGeoNamesLocalIndex method testExceptionInQuery.
@Test
public void testExceptionInQuery() throws GeoEntryQueryException {
doThrow(GeoEntryQueryException.class).when(geoEntryQueryable).query("Arizona", 1);
final GeoResult geoResult = geoNamesLocalIndex.getLocation("Arizona");
assertThat(geoResult, is(nullValue()));
}
use of org.codice.ddf.spatial.geocoder.GeoResult in project ddf by codice.
the class TestGeoNamesWebService method testGetLocation.
@Test
public void testGetLocation() throws IOException {
String response = IOUtils.toString(TestGeoNamesWebService.class.getClassLoader().getResourceAsStream("getLocationTestResponse.json"));
prepareWebClient(response);
GeoResult result = webServiceSpy.getLocation("Phoenix");
assertThat(result.getFullName(), is("Phoenix"));
}
use of org.codice.ddf.spatial.geocoder.GeoResult in project ddf by codice.
the class GeoCoderEndpoint method doQuery.
JSONObject doQuery(String query) {
GeoCoder geoCoder = geoCoderFactory.getService();
GeoResult geoResult = null;
if (geoCoder != null) {
geoResult = geoCoder.getLocation(query);
}
JSONObject jsonObject = new JSONObject();
JSONArray resourceSets = new JSONArray();
JSONObject resourceSet = new JSONObject();
jsonObject.put("resourceSets", resourceSets);
resourceSets.add(resourceSet);
JSONArray resources = new JSONArray();
resourceSet.put("resources", resources);
if (geoResult != null) {
transformGeoResult(geoResult, resources);
}
return jsonObject;
}
Aggregations