Search in sources :

Example 6 with GeoCoder

use of org.codice.ddf.spatial.geocoder.GeoCoder in project ddf by codice.

the class GeoCoderServiceImpl method getNearbyCities.

@Override
public String getNearbyCities(String wkt) throws GeoEntryQueryException {
    GeoCoder geoCoder = geoCoderFactory.getService();
    NearbyLocation nearbyLocation = geoCoder.getNearbyCity(wkt);
    if (nearbyLocation != null) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("direction", nearbyLocation.getCardinalDirection());
        jsonObject.put("distance", nearbyLocation.getDistance());
        jsonObject.put("name", nearbyLocation.getName());
        return jsonObject.toJSONString();
    } else {
        return null;
    }
}
Also used : GeoCoder(org.codice.ddf.spatial.geocoder.GeoCoder) JSONObject(net.minidev.json.JSONObject) NearbyLocation(org.codice.ddf.spatial.geocoding.context.NearbyLocation)

Aggregations

GeoCoder (org.codice.ddf.spatial.geocoder.GeoCoder)6 JSONObject (net.minidev.json.JSONObject)4 JSONArray (net.minidev.json.JSONArray)2 GeoResult (org.codice.ddf.spatial.geocoder.GeoResult)2 NearbyLocation (org.codice.ddf.spatial.geocoding.context.NearbyLocation)2 PluginExecutionException (ddf.catalog.plugin.PluginExecutionException)1 StopProcessingException (ddf.catalog.plugin.StopProcessingException)1 Map (java.util.Map)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 GeoEntryQueryException (org.codice.ddf.spatial.geocoding.GeoEntryQueryException)1