Search in sources :

Example 61 with OGCGeometry

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

the class OGCGeometryToESRIShapeParser method ogcGeomToEsriShape.

public static byte[] ogcGeomToEsriShape(Object o) throws ExecException {
    ESRIGeometryParser parser = new ESRIGeometryParser();
    OGCGeometry geom = parser.parseGeom(o);
    int wkid = geom.SRID();
    int geomType = getGeometryType(geom);
    byte[] shape = GeometryEngine.geometryToEsriShape(geom.getEsriGeometry());
    byte[] shapeWithData = new byte[shape.length + SIZE_TYPE + SIZE_WKID];
    System.arraycopy(shape, 0, shapeWithData, SIZE_WKID + SIZE_TYPE, shape.length);
    System.arraycopy(intToBytes(wkid), 0, shapeWithData, 0, SIZE_WKID);
    shapeWithData[SIZE_WKID] = (byte) geomType;
    return shapeWithData;
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry)

Example 62 with OGCGeometry

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

the class GeometryFromText method exec.

@Override
public DataByteArray exec(Tuple input) throws IOException {
    if (input.size() != 1)
        throw new GeoException("GeometryFromText takes one bytearray argument");
    ESRIGeometryParser gp = new ESRIGeometryParser();
    OGCGeometry geom = gp.parseGeom(input.get(0).toString());
    return new DataByteArray(geom.asBinary().array());
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) DataByteArray(org.apache.pig.data.DataByteArray)

Example 63 with OGCGeometry

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

the class GeometryFromWKB method exec.

@Override
public DataByteArray exec(Tuple input) throws IOException {
    if (input.size() != 1)
        throw new GeoException("GeometryFromWKB takes one bytearray argument");
    ESRIGeometryParser gp = new ESRIGeometryParser();
    OGCGeometry geom = gp.parseGeom(input.get(0));
    return new DataByteArray(geom.asBinary().array());
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) DataByteArray(org.apache.pig.data.DataByteArray)

Example 64 with OGCGeometry

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

the class Intersection method exec.

@Override
public DataByteArray exec(Tuple input) throws IOException {
    OGCGeometry geom1 = null, geom2 = null;
    try {
        geom1 = geometryParser.parseGeom(input.get(0));
        geom2 = geometryParser.parseGeom(input.get(1));
        return new DataByteArray(geom1.intersection(geom2).asBinary().array());
    } catch (ExecException ee) {
        throw new GeoException(geom1, geom2, ee);
    }
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) ExecException(org.apache.pig.backend.executionengine.ExecException) DataByteArray(org.apache.pig.data.DataByteArray)

Example 65 with OGCGeometry

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

the class Intersects method exec.

@Override
public Boolean exec(Tuple input) throws IOException {
    OGCGeometry geom1 = null, geom2 = null;
    try {
        geom1 = geometryParser.parseGeom(input.get(0));
        geom2 = geometryParser.parseGeom(input.get(1));
        return geom1.intersects(geom2);
    } catch (ExecException ee) {
        throw new GeoException(geom1, geom2, ee);
    }
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) ExecException(org.apache.pig.backend.executionengine.ExecException)

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