Search in sources :

Example 21 with ExecException

use of org.apache.pig.backend.executionengine.ExecException in project pigeon by aseldawy.

the class IsValid method exec.

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

Example 22 with ExecException

use of org.apache.pig.backend.executionengine.ExecException in project pigeon by aseldawy.

the class IsEmpty method exec.

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

Example 23 with ExecException

use of org.apache.pig.backend.executionengine.ExecException in project pigeon by aseldawy.

the class Overlaps 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.overlaps(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 24 with ExecException

use of org.apache.pig.backend.executionengine.ExecException in project pigeon by aseldawy.

the class Touches 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.touches(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 25 with ExecException

use of org.apache.pig.backend.executionengine.ExecException in project pigeon by aseldawy.

the class XMin method exec.

@Override
public Double exec(Tuple input) throws IOException {
    Object v = input.get(0);
    Geometry geom = geometryParser.parseGeom(v);
    Coordinate[] coords = geom.getEnvelope().getCoordinates();
    if (coords.length == 0)
        throw new ExecException("XMin cannot work on empty geometires");
    if (coords.length == 1)
        return coords[0].x;
    if (coords.length == 2)
        return Math.min(coords[0].x, coords[1].x);
    return Math.min(coords[0].x, coords[2].x);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Coordinate(org.locationtech.jts.geom.Coordinate) ExecException(org.apache.pig.backend.executionengine.ExecException)

Aggregations

ExecException (org.apache.pig.backend.executionengine.ExecException)58 Tuple (org.apache.pig.data.Tuple)33 DataBag (org.apache.pig.data.DataBag)17 OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)13 DataByteArray (org.apache.pig.data.DataByteArray)11 IOException (java.io.IOException)9 Geometry (org.locationtech.jts.geom.Geometry)9 Test (org.testng.annotations.Test)6 Coordinate (org.locationtech.jts.geom.Coordinate)4 Field (com.twitter.elephantbird.thrift.TStructDescriptor.Field)3 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)2 Builder (com.google.protobuf.Message.Builder)2 VarOptItemsSamples (com.yahoo.sketches.sampling.VarOptItemsSamples)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 VarOptItemsSamples (org.apache.datasketches.sampling.VarOptItemsSamples)2 PhoenixRecordWritable (org.apache.phoenix.mapreduce.PhoenixRecordWritable)2 Line (com.esri.core.geometry.Line)1 MultiPath (com.esri.core.geometry.MultiPath)1 Point (com.esri.core.geometry.Point)1