Search in sources :

Example 16 with Geometry

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;
}
Also used : Geometry(com.esri.core.geometry.Geometry) Point(com.esri.core.geometry.Point) Point(com.esri.core.geometry.Point) URL(java.net.URL) GeoEvent(com.esri.ges.core.geoevent.GeoEvent)

Aggregations

Geometry (com.esri.core.geometry.Geometry)16 OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)8 Point (com.esri.core.geometry.Point)5 GeometryCursor (com.esri.core.geometry.GeometryCursor)4 MapGeometry (com.esri.core.geometry.MapGeometry)4 Envelope (com.esri.core.geometry.Envelope)3 OGCPoint (com.esri.core.geometry.ogc.OGCPoint)3 MultiPoint (com.esri.core.geometry.MultiPoint)2 MultiVertexGeometry (com.esri.core.geometry.MultiVertexGeometry)2 SpatialReference (com.esri.core.geometry.SpatialReference)2 OGCMultiPoint (com.esri.core.geometry.ogc.OGCMultiPoint)2 PrestoException (com.facebook.presto.spi.PrestoException)2 SqlType (com.facebook.presto.spi.function.SqlType)2 Envelope2D (com.esri.core.geometry.Envelope2D)1 OperatorBoundary (com.esri.core.geometry.OperatorBoundary)1 OperatorIntersects (com.esri.core.geometry.OperatorIntersects)1 GeoEvent (com.esri.ges.core.geoevent.GeoEvent)1 StandardTypes (com.facebook.presto.common.type.StandardTypes)1 GeometryUtils.accelerateGeometry (com.facebook.presto.geospatial.GeometryUtils.accelerateGeometry)1 GeometryUtils.getEnvelope (com.facebook.presto.geospatial.GeometryUtils.getEnvelope)1