Search in sources :

Example 56 with OGCGeometry

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

the class TestGeometryParser method testShouldParseWKTEncodedInBinary.

public void testShouldParseWKTEncodedInBinary() throws Exception {
    String wkt = polygon.asText();
    DataByteArray barray = new DataByteArray(wkt);
    OGCGeometry parsed = geometry_parser.parseGeom(barray);
    assertTrue(polygon.equals(parsed));
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) DataByteArray(org.apache.pig.data.DataByteArray)

Example 57 with OGCGeometry

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

the class TestGeometryParser method testShouldParseHexString.

public void testShouldParseHexString() throws Exception {
    byte[] binary = polygon.asBinary().array();
    String hex = ESRIGeometryParser.bytesToHex(binary);
    OGCGeometry parsed = geometry_parser.parseGeom(hex);
    assertTrue(polygon.equals(parsed));
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry)

Example 58 with OGCGeometry

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

the class Within 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.within(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)

Example 59 with OGCGeometry

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

the class ConvexHull method convexHull.

protected static OGCGeometry convexHull(Tuple input) throws ExecException {
    DataBag values = (DataBag) input.get(0);
    if (values.size() == 0)
        return null;
    ArrayList<OGCGeometry> all_geoms = new ArrayList<OGCGeometry>();
    for (Tuple one_geom : values) {
        OGCGeometry parsedGeom = geometryParser.parseGeom(one_geom.get(0));
        all_geoms.add(parsedGeom);
    }
    // Do a convex null of all_geometries
    OGCGeometryCollection geom_collection = new OGCConcreteGeometryCollection(all_geoms, all_geoms.get(0).getEsriSpatialReference());
    return geom_collection.convexHull();
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) DataBag(org.apache.pig.data.DataBag) OGCGeometryCollection(com.esri.core.geometry.ogc.OGCGeometryCollection) ArrayList(java.util.ArrayList) OGCConcreteGeometryCollection(com.esri.core.geometry.ogc.OGCConcreteGeometryCollection) Tuple(org.apache.pig.data.Tuple)

Example 60 with OGCGeometry

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

the class Difference 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.difference(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)

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