Search in sources :

Example 46 with ExecException

use of org.apache.pig.backend.executionengine.ExecException 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 47 with ExecException

use of org.apache.pig.backend.executionengine.ExecException 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)

Example 48 with ExecException

use of org.apache.pig.backend.executionengine.ExecException 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

ExecException (org.apache.pig.backend.executionengine.ExecException)48 Tuple (org.apache.pig.data.Tuple)24 OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)13 DataBag (org.apache.pig.data.DataBag)11 Geometry (com.vividsolutions.jts.geom.Geometry)9 DataByteArray (org.apache.pig.data.DataByteArray)9 IOException (java.io.IOException)6 Coordinate (com.vividsolutions.jts.geom.Coordinate)5 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 Test (org.testng.annotations.Test)2 Line (com.esri.core.geometry.Line)1 MultiPath (com.esri.core.geometry.MultiPath)1 Point (com.esri.core.geometry.Point)1 Polygon (com.esri.core.geometry.Polygon)1 Polyline (com.esri.core.geometry.Polyline)1