private static OGCGeometry geomFromBinary(Slice input) { requireNonNull(input, "input is null"); OGCGeometry geometry; try { geometry = OGCGeometry.fromBinary(input.toByteBuffer().slice()); } catch (IllegalArgumentException | IndexOutOfBoundsException e) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid WKB", e); } geometry.setSpatialReference(null); return geometry; }
private static void assertGeometryEquals(OGCGeometry actual, OGCGeometry expected) { actual.setSpatialReference(null); expected.setSpatialReference(null); ensureEnvelopeLoaded(actual); ensureEnvelopeLoaded(expected); assertEquals(actual, expected); }
private static OGCGeometry geometryFromText(Slice input) { OGCGeometry geometry; try { geometry = OGCGeometry.fromText(input.toStringUtf8()); } catch (IllegalArgumentException e) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid WKT: " + input.toStringUtf8(), e); } geometry.setSpatialReference(null); return geometry; }
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); } }
@Override public void setSpatialReference(SpatialReference esriSR_) { esriSR = esriSR_; for (int i = 0, n = geometries.size(); i < n; i++) { if (geometries.get(i) != null) geometries.get(i).setSpatialReference(esriSR_); } }
@Override public void setSpatialReference(SpatialReference esriSR_) { esriSR = esriSR_; for (int i = 0, n = geometries.size(); i < n; i++) { if (geometries.get(i) != null) geometries.get(i).setSpatialReference(esriSR_); } }
public BytesWritable evaluate(BytesWritable wkb, int wkid) throws UDFArgumentException { try { SpatialReference spatialReference = null; if (wkid != GeometryUtils.WKID_UNKNOWN) { spatialReference = SpatialReference.create(wkid); } byte [] byteArr = wkb.getBytes(); ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length); byteBuf.put(byteArr); OGCGeometry ogcObj = OGCGeometry.fromBinary(byteBuf); ogcObj.setSpatialReference(spatialReference); return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj); } catch (Exception e) { // IllegalArgumentException, GeometryException LOG.error(e.getMessage()); return null; } }
private static OGCGeometry geomFromBinary(Slice input) { requireNonNull(input, "input is null"); OGCGeometry geometry; try { geometry = OGCGeometry.fromBinary(input.toByteBuffer().slice()); } catch (IllegalArgumentException | IndexOutOfBoundsException e) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid WKB", e); } geometry.setSpatialReference(null); return geometry; }
private static OGCGeometry geomFromBinary(Slice input) { requireNonNull(input, "input is null"); OGCGeometry geometry; try { geometry = OGCGeometry.fromBinary(input.toByteBuffer().slice()); } catch (IllegalArgumentException | IndexOutOfBoundsException e) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid WKB", e); } geometry.setSpatialReference(null); return geometry; }
private static void assertGeometryEquals(OGCGeometry actual, OGCGeometry expected) { actual.setSpatialReference(null); expected.setSpatialReference(null); ensureEnvelopeLoaded(actual); ensureEnvelopeLoaded(expected); assertEquals(actual, expected); }
private static void assertGeometryEquals(OGCGeometry actual, OGCGeometry expected) { actual.setSpatialReference(null); expected.setSpatialReference(null); ensureEnvelopeLoaded(actual); ensureEnvelopeLoaded(expected); assertEquals(actual, expected); }
public BytesWritable evaluate(Text wkwrap) throws UDFArgumentException { String wkt = wkwrap.toString(); try { OGCGeometry ogcObj = OGCGeometry.fromText(wkt); ogcObj.setSpatialReference(null); if (ogcObj.geometryType().equals("MultiPoint")) { return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj); } else { LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_MULTIPOINT, GeometryUtils.OGCType.UNKNOWN); return null; } } catch (Exception e) { // IllegalArgumentException, GeometryException LogUtils.Log_InvalidText(LOG, wkt); return null; } }
public BytesWritable evaluate(Text wkwrap, int wkid) throws UDFArgumentException { String wkt = wkwrap.toString(); try { SpatialReference spatialReference = null; if (wkid != GeometryUtils.WKID_UNKNOWN) { spatialReference = SpatialReference.create(wkid); } OGCGeometry ogcObj = OGCGeometry.fromText(wkt); ogcObj.setSpatialReference(spatialReference); return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj); } catch (Exception e) { // IllegalArgumentException, GeometryException LogUtils.Log_InvalidText(LOG, wkt); return null; } }
public BytesWritable evaluate(Text wkwrap) throws UDFArgumentException { String wkt = wkwrap.toString(); try { OGCGeometry ogcObj = OGCGeometry.fromText(wkt); ogcObj.setSpatialReference(null); if (ogcObj.geometryType().equals("MultiLineString")) { return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj); } else { LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_MULTILINESTRING, GeometryUtils.OGCType.UNKNOWN); return null; } } catch (Exception e) { // IllegalArgumentException, GeometryException LogUtils.Log_InvalidText(LOG, wkt); return null; } }
public BytesWritable evaluate(Text wkwrap) throws UDFArgumentException { String wkt = wkwrap.toString(); try { OGCGeometry ogcObj = OGCGeometry.fromText(wkt); ogcObj.setSpatialReference(null); if (ogcObj.geometryType().equals("MultiPolygon")) { return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj); } else { LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_MULTIPOLYGON, GeometryUtils.OGCType.UNKNOWN); return null; } } catch (Exception e) { // IllegalArgumentException, GeometryException LogUtils.Log_InvalidText(LOG, wkt); return null; } }
public BytesWritable evaluate(Text wkwrap) throws UDFArgumentException { String wkt = wkwrap.toString(); try { OGCGeometry ogcObj = OGCGeometry.fromText(wkt); ogcObj.setSpatialReference(null); if (ogcObj.geometryType().equals("LineString")) { return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj); } else { LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_LINESTRING, GeometryUtils.OGCType.UNKNOWN); return null; } } catch (Exception e) { // IllegalArgumentException, GeometryException LogUtils.Log_InvalidText(LOG, wkt); return null; } }
public BytesWritable evaluate(Text wkwrap) throws UDFArgumentException { String wkt = wkwrap.toString(); try { OGCGeometry ogcObj = OGCGeometry.fromText(wkt); ogcObj.setSpatialReference(null); if (ogcObj.geometryType().equals("Point")) { return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj); } else { LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_POINT, GeometryUtils.OGCType.UNKNOWN); return null; } } catch (Exception e) { // IllegalArgumentException, GeometryException LogUtils.Log_InvalidText(LOG, wkt); return null; } } }
public BytesWritable evaluate(Text wkwrap) throws UDFArgumentException { String wkt = wkwrap.toString(); try { OGCGeometry ogcObj = OGCGeometry.fromText(wkt); ogcObj.setSpatialReference(null); if (ogcObj.geometryType().equals("Polygon")) { return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj); } else { LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_POLYGON, GeometryUtils.OGCType.UNKNOWN); return null; } } catch (Exception e) { // IllegalArgumentException, GeometryException LogUtils.Log_InvalidText(LOG, wkt); return null; } } }
private static OGCGeometry geometryFromText(Slice input) { OGCGeometry geometry; try { geometry = OGCGeometry.fromText(input.toStringUtf8()); } catch (IllegalArgumentException e) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid WKT: " + input.toStringUtf8(), e); } geometry.setSpatialReference(null); return geometry; }
private static OGCGeometry geometryFromText(Slice input) { OGCGeometry geometry; try { geometry = OGCGeometry.fromText(input.toStringUtf8()); } catch (IllegalArgumentException e) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid WKT: " + input.toStringUtf8(), e); } geometry.setSpatialReference(null); return geometry; }