Search in sources :

Example 66 with OGCGeometry

use of com.esri.core.geometry.ogc.OGCGeometry in project pigeon by aseldawy.

the class Buffer method exec.

@Override
public DataByteArray exec(Tuple input) throws IOException {
    OGCGeometry geom = null;
    try {
        Object v = input.get(0);
        geom = geometryParser.parseGeom(v);
        double dist;
        Object distance = input.get(1);
        if (distance instanceof Double)
            dist = (Double) distance;
        else if (distance instanceof Float)
            dist = (Float) distance;
        else if (distance instanceof Integer)
            dist = (Integer) distance;
        else if (distance instanceof Long)
            dist = (Long) distance;
        else if (distance instanceof String)
            dist = Double.parseDouble((String) distance);
        else if (distance instanceof DataByteArray)
            dist = Double.parseDouble(new String(((DataByteArray) distance).get()));
        else
            throw new GeoException("Invalid second argument in call to Buffer. Expecting Double, Integer or Long");
        return new DataByteArray(geom.buffer(dist).asBinary().array());
    } catch (ExecException ee) {
        throw new GeoException(geom, ee);
    }
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) ExecException(org.apache.pig.backend.executionengine.ExecException) DataByteArray(org.apache.pig.data.DataByteArray)

Aggregations

OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)66 SqlType (com.facebook.presto.spi.function.SqlType)22 Description (com.facebook.presto.spi.function.Description)21 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)21 SqlNullable (com.facebook.presto.spi.function.SqlNullable)14 Point (com.esri.core.geometry.Point)12 ExecException (org.apache.pig.backend.executionengine.ExecException)12 DataByteArray (org.apache.pig.data.DataByteArray)8 Geometry (com.esri.core.geometry.Geometry)7 OGCPoint (com.esri.core.geometry.ogc.OGCPoint)7 Envelope (com.esri.core.geometry.Envelope)6 OGCConcreteGeometryCollection (com.esri.core.geometry.ogc.OGCConcreteGeometryCollection)6 OGCGeometryCollection (com.esri.core.geometry.ogc.OGCGeometryCollection)6 ArrayList (java.util.ArrayList)6 Slice (io.airlift.slice.Slice)5 GeometryCursor (com.esri.core.geometry.GeometryCursor)4 MultiPoint (com.esri.core.geometry.MultiPoint)4 OGCMultiPoint (com.esri.core.geometry.ogc.OGCMultiPoint)4 Tuple (org.apache.pig.data.Tuple)4 Page (com.facebook.presto.common.Page)3