use of com.esri.core.geometry.Geometry in project sis by apache.
the class ESRI method tryGetEnvelope.
/**
* If the given object is an ESRI geometry and its envelope is non-empty, returns
* that envelope as an Apache SIS implementation. Otherwise returns {@code null}.
*
* @param geometry the geometry from which to get the envelope, or {@code null}.
* @return the envelope of the given object, or {@code null} if the object is not
* a recognized geometry or its envelope is empty.
*/
@Override
final GeneralEnvelope tryGetEnvelope(final Object geometry) {
if (geometry instanceof Geometry) {
final Envelope2D bounds = new Envelope2D();
((Geometry) geometry).queryEnvelope2D(bounds);
if (!bounds.isEmpty()) {
// Test if there is NaN values.
final GeneralEnvelope env = new GeneralEnvelope(2);
env.setRange(0, bounds.xmin, bounds.xmax);
env.setRange(1, bounds.ymin, bounds.ymax);
return env;
}
}
return null;
}
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("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode?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