public void eval() { String wktText = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(input.start, input.end, input.buffer); com.esri.core.geometry.ogc.OGCGeometry geom; geom = com.esri.core.geometry.ogc.OGCGeometry.fromText(wktText); java.nio.ByteBuffer pointBytes = geom.asBinary(); int outputSize = pointBytes.remaining(); buffer = out.buffer = buffer.reallocIfNeeded(outputSize); out.start = 0; out.end = outputSize; buffer.setBytes(0, pointBytes); } }
public void eval() { double bufferRadius = bufferRadiusParam.value; com.esri.core.geometry.ogc.OGCGeometry geom1 = com.esri.core.geometry.ogc.OGCGeometry .fromBinary(geom1Param.buffer.nioBuffer(geom1Param.start, geom1Param.end - geom1Param.start)); com.esri.core.geometry.ogc.OGCGeometry bufferedGeom = geom1.buffer(bufferRadius); java.nio.ByteBuffer bufferedGeomBytes = bufferedGeom.asBinary(); int outputSize = bufferedGeomBytes.remaining(); buffer = out.buffer = buffer.reallocIfNeeded(outputSize); out.start = 0; out.end = outputSize; buffer.setBytes(0, bufferedGeomBytes); } }
@Description("Returns the Well-Known Binary (WKB) representation of the geometry") @ScalarFunction("ST_AsBinary") @SqlType(VARBINARY) public static Slice stAsBinary(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { return wrappedBuffer(deserialize(input).asBinary()); }
@Override public void output() { if (nonNullCount.value > 0) { out.isSet = 1; java.util.List<com.esri.core.geometry.Geometry> tmp = (java.util.ArrayList<com.esri.core.geometry.Geometry>) value.obj; com.esri.core.geometry.SpatialReference spatialRef = null; if (srid.value != 0){ spatialRef = com.esri.core.geometry.SpatialReference.create(4326); } com.esri.core.geometry.Geometry[] geomArr = (com.esri.core.geometry.Geometry[]) tmp.toArray(new com.esri.core.geometry.Geometry[0]); com.esri.core.geometry.Geometry geom = com.esri.core.geometry.GeometryEngine.union(geomArr, spatialRef); com.esri.core.geometry.ogc.OGCGeometry unionGeom = com.esri.core.geometry.ogc.OGCGeometry.createFromEsriGeometry(geom, spatialRef); java.nio.ByteBuffer unionGeomBytes = unionGeom.asBinary(); int outputSize = unionGeomBytes.remaining(); buf = out.buffer = buf.reallocIfNeeded(outputSize); out.start = 0; out.end = outputSize; buf.setBytes(0, unionGeomBytes); } else { out.isSet = 0; } }
public void eval() { com.esri.core.geometry.ogc.OGCGeometry geom1; geom1 = com.esri.core.geometry.ogc.OGCGeometry .fromBinary(geom1Param.buffer.nioBuffer(geom1Param.start, geom1Param.end - geom1Param.start)); com.esri.core.geometry.ogc.OGCGeometry envelopeGeom; if (geom1.geometryType().equals("Point")) { envelopeGeom = geom1; } else { envelopeGeom = geom1.envelope(); } java.nio.ByteBuffer envelopeGeomBytes = envelopeGeom.asBinary(); int outputSize = envelopeGeomBytes.remaining(); buffer = out.buffer = buffer.reallocIfNeeded(outputSize); out.start = 0; out.end = outputSize; buffer.setBytes(0, envelopeGeomBytes); } }
public void eval() { int srid = sridParam.value; String wktText = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(input.start, input.end, input.buffer); com.esri.core.geometry.ogc.OGCGeometry geom; geom = com.esri.core.geometry.ogc.OGCGeometry.fromText(wktText); geom.setSpatialReference(com.esri.core.geometry.SpatialReference.create(srid)); java.nio.ByteBuffer pointBytes = geom.asBinary(); int outputSize = pointBytes.remaining(); buffer = out.buffer = buffer.reallocIfNeeded(outputSize); out.start = 0; out.end = outputSize; buffer.setBytes(0, pointBytes); } }
public void eval() { com.esri.core.geometry.ogc.OGCGeometry geom1; com.esri.core.geometry.ogc.OGCGeometry geom2; geom1 = com.esri.core.geometry.ogc.OGCGeometry .fromBinary(geom1Param.buffer.nioBuffer(geom1Param.start, geom1Param.end - geom1Param.start)); geom2 = com.esri.core.geometry.ogc.OGCGeometry .fromBinary(geom2Param.buffer.nioBuffer(geom2Param.start, geom2Param.end - geom2Param.start)); com.esri.core.geometry.ogc.OGCGeometry unionGeom = geom1.union(geom2); java.nio.ByteBuffer bufferedGeomBytes = unionGeom.asBinary(); int outputSize = bufferedGeomBytes.remaining(); buffer = out.buffer = buffer.reallocIfNeeded(outputSize); out.start = 0; out.end = outputSize; buffer.setBytes(0, bufferedGeomBytes); } }
public void eval() { com.esri.core.geometry.ogc.OGCGeometry geom1; com.esri.core.geometry.ogc.OGCGeometry geom2; geom1 = com.esri.core.geometry.ogc.OGCGeometry .fromBinary(geom1Param.buffer.nioBuffer(geom1Param.start, geom1Param.end - geom1Param.start)); geom2 = com.esri.core.geometry.ogc.OGCGeometry .fromBinary(geom2Param.buffer.nioBuffer(geom2Param.start, geom2Param.end - geom2Param.start)); com.esri.core.geometry.ogc.OGCGeometry diffGeom = geom1.difference(geom2); java.nio.ByteBuffer bufferedGeomBytes = diffGeom.asBinary(); int outputSize = bufferedGeomBytes.remaining(); buffer = out.buffer = buffer.reallocIfNeeded(outputSize); out.start = 0; out.end = outputSize; buffer.setBytes(0, bufferedGeomBytes); } }
geomBytes = tGeom.asBinary();
@Override public void write(DataOutput out) throws IOException { byte[] bytes = geom.asBinary().array(); out.writeInt(bytes.length); out.write(bytes); }
@Override public DataByteArray exec(Tuple input) throws IOException { return new DataByteArray(convexHull(input).asBinary().array()); } }
@Override public DataByteArray exec(Tuple input) throws IOException { return new DataByteArray(union(input).asBinary().array()); } }
@Override public DataByteArray exec(Tuple input) throws IOException { return new DataByteArray(extent(input).asBinary().array()); } }
@Override public Tuple exec(Tuple input) throws IOException { return TupleFactory.getInstance().newTuple( new DataByteArray(convexHull(input).asBinary().array())); } }
@Override public Tuple exec(Tuple input) throws IOException { return TupleFactory.getInstance().newTuple( new DataByteArray(union(input).asBinary().array())); } }
@Override public String exec(Tuple t) throws IOException { if (t.size() != 1) throw new GeoException("AsHex expects one geometry argument"); OGCGeometry geom = geometryParser.parseGeom(t.get(0)); return ESRIGeometryParser.bytesToHex(geom.asBinary().array()); }
@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()); } }
@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); } }
@Description("Returns the Well-Known Binary (WKB) representation of the geometry") @ScalarFunction("ST_AsBinary") @SqlType(VARBINARY) public static Slice stAsBinary(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { return wrappedBuffer(deserialize(input).asBinary()); }
@Description("Returns the Well-Known Binary (WKB) representation of the geometry") @ScalarFunction("ST_AsBinary") @SqlType(VARBINARY) public static Slice stAsBinary(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { return wrappedBuffer(deserialize(input).asBinary()); }