private static OGCPoint readPoint(BasicSliceInput input) { double x = input.readDouble(); double y = input.readDouble(); Point point; if (isNaN(x) || isNaN(y)) { point = new Point(); } else { point = new Point(x, y); } return new OGCPoint(point, null); }
result = transform.transform(new org.osgeo.proj4j.ProjCoordinate(pointGeom.X(), pointGeom.Y()), result); geomBytes = new com.esri.core.geometry.ogc.OGCPoint( new com.esri.core.geometry.Point(result.x, result.y), sr).asBinary(); } else { com.esri.core.geometry.Geometry esriGeom = geomSrc.getEsriGeometry();
if (point.isEmpty()) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Invalid input to ST_LineString: empty point at index %s", i + 1)); multipath.startPath(point.X(), point.Y()); if (point.Equals(previousPoint)) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Invalid input to ST_LineString: consecutive duplicate points at index %s", i + 1)); multipath.lineTo(point.X(), point.Y());
private void assertEnvelopeAsPts(String wkt, Point lowerLeftCorner, Point upperRightCorner) { assertFunction(format("transform(ST_EnvelopeAsPts(ST_GeometryFromText('%s')), x -> ST_AsText(x))", wkt), new ArrayType(VARCHAR), ImmutableList.of(new OGCPoint(lowerLeftCorner, null).asText(), new OGCPoint(upperRightCorner, null).asText())); }
public void eval() { double lon = lonParam.value; double lat = latParam.value; com.esri.core.geometry.ogc.OGCPoint point = new com.esri.core.geometry.ogc.OGCPoint( new com.esri.core.geometry.Point(lon, lat), com.esri.core.geometry.SpatialReference.create(4326)); java.nio.ByteBuffer pointBytes = point.asBinary(); out.buffer = buffer; out.start = 0; out.end = pointBytes.remaining(); buffer.setBytes(0, pointBytes); } }
@SqlNullable @Description("Returns a multi-point geometry formed from input points") @ScalarFunction("ST_MultiPoint") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stMultiPoint(@SqlType("array(" + GEOMETRY_TYPE_NAME + ")") Block input) { MultiPoint multipoint = new MultiPoint(); for (int i = 0; i < input.getPositionCount(); i++) { if (input.isNull(i)) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Invalid input to ST_MultiPoint: null at index %s", i + 1)); } Slice slice = GEOMETRY.getSlice(input, i); OGCGeometry geometry = deserialize(slice); if (!(geometry instanceof OGCPoint)) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Invalid input to ST_MultiPoint: geometry is not a point: %s at index %s", geometry.geometryType(), i + 1)); } OGCPoint point = (OGCPoint) geometry; if (point.isEmpty()) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Invalid input to ST_MultiPoint: empty point at index %s", i + 1)); } multipoint.add(point.X(), point.Y()); } if (multipoint.getPointCount() == 0) { return null; } return serialize(createFromEsriGeometry(multipoint, null, true)); }
public void drawESRIGeom(Graphics g, OGCGeometry geom, double xscale, double yscale) { if (geom instanceof OGCLineString) { OGCLineString linestring = (OGCLineString) geom; int[] xs = new int[linestring.numPoints()]; int[] ys = new int[linestring.numPoints()]; int n = 0; for (int i = 0; i < n; i++) { OGCPoint point = linestring.pointN(i); xs[n] = (int) Math.floor(point.X() * xscale); ys[n] = (int) Math.floor(point.Y() * yscale); // Increment number of point if this point is different than previous ones if (n == 0 || xs[n] != xs[n-1] || ys[n] != ys[n-1]) n++; } g.drawPolyline(xs, ys, n); } else { throw new RuntimeException("Cannot draw a shape of type "+geom.getClass()); } } }
public void eval() { com.esri.core.geometry.ogc.OGCGeometry geom; geom = com.esri.core.geometry.ogc.OGCGeometry .fromBinary(geomParam.buffer.nioBuffer(geomParam.start, geomParam.end - geomParam.start)); if (geom != null && geom.geometryType().equals("Point")) { out.value = ((com.esri.core.geometry.ogc.OGCPoint) geom).X(); } else { out.value = Double.NaN; } } }
public void eval() { com.esri.core.geometry.ogc.OGCGeometry geom; geom = com.esri.core.geometry.ogc.OGCGeometry .fromBinary(geomParam.buffer.nioBuffer(geomParam.start, geomParam.end - geomParam.start)); if (geom != null && geom.geometryType().equals("Point")) { out.value = ((com.esri.core.geometry.ogc.OGCPoint) geom).Y(); } else { out.value = Double.NaN; } } }
@Test(groups = "unit") public void should_accept_empty_shape() throws Exception { Point point = Point.fromWellKnownText("POINT EMPTY"); assertThat(point.getOgcGeometry().isEmpty()).isTrue(); }
@Override protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { if (geometry instanceof OGCPoint) { return ((OGCPoint) geometry).Z(); } else { throw new UnsupportedOperationException( "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); } }
@Override protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { if (geometry instanceof OGCPoint) { return ((OGCPoint) geometry).M(); } else { throw new UnsupportedOperationException( "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); } }
@SqlNullable @Description("Returns a multi-point geometry formed from input points") @ScalarFunction("ST_MultiPoint") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stMultiPoint(@SqlType("array(" + GEOMETRY_TYPE_NAME + ")") Block input) { MultiPoint multipoint = new MultiPoint(); for (int i = 0; i < input.getPositionCount(); i++) { if (input.isNull(i)) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Invalid input to ST_MultiPoint: null at index %s", i + 1)); } Slice slice = GEOMETRY.getSlice(input, i); OGCGeometry geometry = deserialize(slice); if (!(geometry instanceof OGCPoint)) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Invalid input to ST_MultiPoint: geometry is not a point: %s at index %s", geometry.geometryType(), i + 1)); } OGCPoint point = (OGCPoint) geometry; if (point.isEmpty()) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Invalid input to ST_MultiPoint: empty point at index %s", i + 1)); } multipoint.add(point.X(), point.Y()); } if (multipoint.getPointCount() == 0) { return null; } return serialize(createFromEsriGeometry(multipoint, null, true)); }
@Override public Object evaluate(DeferredObject[] args) throws HiveException { double binSize = PrimitiveObjectInspectorUtils.getDouble(args[0].get(), oiBinSize); if (!binSizeIsConstant || bins == null) { bins = new BinUtils(binSize); } OGCPoint point = geomHelper.getPoint(args); if (point == null) { return null; } return bins.getId(point.X(), point.Y()); }
@SqlNullable @Description("Return the X coordinate of the point") @ScalarFunction("ST_X") @SqlType(DOUBLE) public static Double stX(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_X", geometry, EnumSet.of(POINT)); if (geometry.isEmpty()) { return null; } return ((OGCPoint) geometry).X(); }
@SqlNullable @Description("Return the Y coordinate of the point") @ScalarFunction("ST_Y") @SqlType(DOUBLE) public static Double stY(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_Y", geometry, EnumSet.of(POINT)); if (geometry.isEmpty()) { return null; } return ((OGCPoint) geometry).Y(); }
private void assertEnvelopeAsPts(String wkt, Point lowerLeftCorner, Point upperRightCorner) { assertFunction(format("transform(ST_EnvelopeAsPts(ST_GeometryFromText('%s')), x -> ST_AsText(x))", wkt), new ArrayType(VARCHAR), ImmutableList.of(new OGCPoint(lowerLeftCorner, null).asText(), new OGCPoint(upperRightCorner, null).asText())); }
@Override public DataByteArray exec(Tuple input) throws IOException { if (input.size() != 2) throw new GeoException("MakePoint takes two numerical arguments"); double x = ESRIGeometryParser.parseDouble(input.get(0)); double y = ESRIGeometryParser.parseDouble(input.get(1)); Point point = new Point(x, y); OGCPoint ogc_point = new OGCPoint(point, SpatialReference.create(4326)); return new DataByteArray(ogc_point.asBinary().array()); } }
public DoubleWritable evaluate(BytesWritable geomref) { if (geomref == null || geomref.getLength() == 0) { LogUtils.Log_ArgumentsNull(LOG); return null; } OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref); if (ogcGeometry == null){ return null; } if (!ogcGeometry.is3D()) { LogUtils.Log_Not3D(LOG); return null; } switch(GeometryUtils.getType(geomref)) { case ST_POINT: OGCPoint pt = (OGCPoint)ogcGeometry; resultDouble.set(pt.Z()); return resultDouble; default: LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_POINT, GeometryUtils.getType(geomref)); return null; } }
public DoubleWritable evaluate(BytesWritable geomref) { if (geomref == null || geomref.getLength() == 0) { LogUtils.Log_ArgumentsNull(LOG); return null; } OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref); if (ogcGeometry == null){ return null; } if (!ogcGeometry.isMeasured()) { LogUtils.Log_NotMeasured(LOG); return null; } switch(GeometryUtils.getType(geomref)) { case ST_POINT: OGCPoint pt = (OGCPoint)ogcGeometry; resultDouble.set(pt.M()); return resultDouble; default: LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_POINT, GeometryUtils.getType(geomref)); return null; } }