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; } } }
@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(); }
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)); if (geom1.geometryType().equals("Point")) { out.value = ((com.esri.core.geometry.ogc.OGCPoint) geom1).X(); } else { com.esri.core.geometry.Envelope envelope = new com.esri.core.geometry.Envelope(); geom1.getEsriGeometry().queryEnvelope(envelope); out.value = envelope.getXMax(); } } }
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)); if (geom1.geometryType().equals("Point")) { out.value = ((com.esri.core.geometry.ogc.OGCPoint) geom1).X(); } else { com.esri.core.geometry.Envelope envelope = new com.esri.core.geometry.Envelope(); geom1.getEsriGeometry().queryEnvelope(envelope); out.value = envelope.getXMin(); } } }
@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)); }
result = transform.transform(new org.osgeo.proj4j.ProjCoordinate(pointGeom.X(), pointGeom.Y()), result);
@Override protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { if (geometry instanceof OGCPoint) { return ((OGCPoint) geometry).X(); } else { throw new UnsupportedOperationException( "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); } }
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()); } } }
@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 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(); }
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; } switch(GeometryUtils.getType(geomref)) { case ST_POINT: OGCPoint pt = (OGCPoint)ogcGeometry; resultDouble.set(pt.X()); return resultDouble; default: LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_POINT, GeometryUtils.getType(geomref)); return null; } }
@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)); }
@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)); }
Assert.assertTrue(((AGeometry) point).getGeometry() instanceof OGCPoint); OGCPoint p = (OGCPoint) ((AGeometry) point).getGeometry(); Assert.assertEquals(3.0, p.X(), 1E-5); Assert.assertEquals(4.0, p.Y(), 1E-5); } catch (IOException e) {
bins.queryEnvelope(point.X(), point.Y(), env);