use of com.esri.core.geometry.Geometry in project reverse-geocoder-for-geoevent by Esri.
the class ReverseGeocoderProcessor method processGeoEvent.
private GeoEvent processGeoEvent(GeoEvent geoEvent) throws MalformedURLException, JSONException, ConfigurationException, GeoEventDefinitionManagerException, FieldException {
if (geoEvent.getTrackId() == null || geoEvent.getGeometry() == null) {
LOGGER.warn("NULL_ERROR: TrackID and/or Geometry is NULL.");
return null;
}
Geometry geom = geoEvent.getGeometry().getGeometry();
if (geom.isEmpty())
return geoEvent;
if (!Geometry.isPoint(geom.getType().value()))
return geoEvent;
if (Geometry.isMultiVertex(geom.getType().value()))
return geoEvent;
Point point = (Point) geom;
double lon = point.getX();
double lat = point.getY();
int wkid = geoEvent.getGeometry().getSpatialReference().getID();
// fetch nearest street address (reverse geocode) via ArcGIS Online World GeoCode service
// The response format. Values: html | json | kmz
// The default response format is html.
agolSearchFormat = "json";
URL agolURL = new URL(geocodeServiceUrl + "?location=" + Double.toString(lon) + "," + Double.toString(lat) + "&distance=" + Integer.toString(agolSearchDistance) + "&outSR=" + Integer.toString(wkid) + "&f=" + agolSearchFormat);
String addressJson = getReverseGeocode(agolURL);
GeoEvent agolStreetAddress = augmentGeoEventWithAddress(geoEvent, addressJson);
return agolStreetAddress;
}
Aggregations