private static void accelerateGeometry(OGCGeometry ogcGeometry, Operator relateOperator) { // Recurse into GeometryCollections GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor(); while (true) { com.esri.core.geometry.Geometry esriGeometry = cursor.next(); if (esriGeometry == null) { break; } relateOperator.accelerateGeometry(esriGeometry, null, Geometry.GeometryAccelerationDegree.enumMild); } }
public static boolean disjoint(Envelope envelope, OGCGeometry ogcGeometry) { GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor(); while (true) { Geometry geometry = cursor.next(); if (geometry == null) { return true; } if (!GeometryEngine.disjoint(geometry, envelope, null)) { return false; } } }
public static boolean contains(OGCGeometry ogcGeometry, Envelope envelope) { GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor(); while (true) { Geometry geometry = cursor.next(); if (geometry == null) { return false; } if (GeometryEngine.contains(geometry, envelope, null)) { return true; } } }
public static int getPointCount(OGCGeometry ogcGeometry) { GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor(); int points = 0; while (true) { com.esri.core.geometry.Geometry geometry = cursor.next(); if (geometry == null) { return points; } if (geometry.isEmpty()) { continue; } if (geometry instanceof Point) { points++; } else { points += ((MultiVertexGeometry) geometry).getPointCount(); } } }
public static Envelope getEnvelope(OGCGeometry ogcGeometry) { GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor(); Envelope overallEnvelope = new Envelope(); while (true) { Geometry geometry = cursor.next(); if (geometry == null) { return overallEnvelope; } Envelope envelope = new Envelope(); geometry.queryEnvelope(envelope); overallEnvelope.merge(envelope); } }
@Description("Returns true if the input geometry is well formed") @ScalarFunction("ST_IsValid") @SqlType(BOOLEAN) public static boolean stIsValid(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { GeometryCursor cursor = deserialize(input).getEsriGeometryCursor(); while (true) { com.esri.core.geometry.Geometry geometry = cursor.next(); if (geometry == null) { return true; } if (!OperatorSimplifyOGC.local().isSimpleOGC(geometry, null, true, null, null)) { return false; } } }
@Description("Returns the 2D Euclidean area of a geometry") @ScalarFunction("ST_Area") @SqlType(DOUBLE) public static double stArea(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); // The Esri geometry library does not support area for geometry collections. We compute the area // of collections by summing the area of the individual components. GeometryType type = GeometryType.getForEsriGeometryType(geometry.geometryType()); if (type == GeometryType.GEOMETRY_COLLECTION) { double area = 0.0; GeometryCursor cursor = geometry.getEsriGeometryCursor(); while (true) { com.esri.core.geometry.Geometry esriGeometry = cursor.next(); if (esriGeometry == null) { return area; } area += esriGeometry.calculateArea2D(); } } return geometry.getEsriGeometry().calculateArea2D(); }
public static Slice invalidReason(@SqlType(GEOMETRY_TYPE_NAME) Slice input) GeometryCursor cursor = deserialize(input).getEsriGeometryCursor(); NonSimpleResult result = new NonSimpleResult(); while (true) {
@Description("Converts a Geometry object to a SphericalGeography object") @ScalarFunction("to_spherical_geography") @SqlType(SPHERICAL_GEOGRAPHY_TYPE_NAME) public static Slice toSphericalGeography(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { // "every point in input is in range" <=> "the envelope of input is in range" Envelope envelope = deserializeEnvelope(input); if (envelope != null) { checkLatitude(envelope.getYMin()); checkLatitude(envelope.getYMax()); checkLongitude(envelope.getXMin()); checkLongitude(envelope.getXMax()); } OGCGeometry geometry = deserialize(input); if (geometry.is3D()) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Cannot convert 3D geometry to a spherical geography"); } GeometryCursor cursor = geometry.getEsriGeometryCursor(); while (true) { com.esri.core.geometry.Geometry subGeometry = cursor.next(); if (subGeometry == null) { break; } if (!GEOMETRY_TYPES_FOR_SPHERICAL_GEOGRAPHY.contains(subGeometry.getType())) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Cannot convert geometry of this type to spherical geography: " + subGeometry.getType()); } } return input; }
/** * Resolves topological issues in this geometry and makes it Simple according to OGC specification. * * @return Returns simplified geometry. * * Note: isSimple and isSimpleRelaxed should return true after this operation. */ public OGCGeometry makeSimple() { return simplifyBunch_(getEsriGeometryCursor()); }
/** * Resolves topological issues in this geometry and makes it Simple according to OGC specification. * * @return Returns simplified geometry. * * Note: isSimple and isSimpleRelaxed should return true after this operation. */ public OGCGeometry makeSimple() { return simplifyBunch_(getEsriGeometryCursor()); }
private static void accelerateGeometry(OGCGeometry ogcGeometry, Operator relateOperator) { // Recurse into GeometryCollections GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor(); while (true) { com.esri.core.geometry.Geometry esriGeometry = cursor.next(); if (esriGeometry == null) { break; } relateOperator.accelerateGeometry(esriGeometry, null, Geometry.GeometryAccelerationDegree.enumMild); } }
public static boolean contains(OGCGeometry ogcGeometry, Envelope envelope) { GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor(); while (true) { Geometry geometry = cursor.next(); if (geometry == null) { return false; } if (GeometryEngine.contains(geometry, envelope, null)) { return true; } } }
public static boolean disjoint(Envelope envelope, OGCGeometry ogcGeometry) { GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor(); while (true) { Geometry geometry = cursor.next(); if (geometry == null) { return true; } if (!GeometryEngine.disjoint(geometry, envelope, null)) { return false; } } }
private static void accelerateGeometry(OGCGeometry ogcGeometry, Operator relateOperator) { // Recurse into GeometryCollections GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor(); while (true) { com.esri.core.geometry.Geometry esriGeometry = cursor.next(); if (esriGeometry == null) { break; } relateOperator.accelerateGeometry(esriGeometry, null, Geometry.GeometryAccelerationDegree.enumMild); } }
public OGCGeometry convexHull() { com.esri.core.geometry.GeometryCursor cursor = OperatorConvexHull.local().execute( getEsriGeometryCursor(), false, null); return OGCGeometry.createFromEsriCursor(cursor, esriSR); }
public OGCGeometry convexHull() { com.esri.core.geometry.GeometryCursor cursor = OperatorConvexHull.local().execute( getEsriGeometryCursor(), false, null); return OGCGeometry.createFromEsriCursor(cursor, esriSR); }
public OGCGeometry intersection(OGCGeometry another) { if (another.geometryType() == OGCConcreteGeometryCollection.TYPE) { return (new OGCConcreteGeometryCollection(this, esriSR)).intersection(another); } com.esri.core.geometry.OperatorIntersection op = (OperatorIntersection) OperatorFactoryLocal .getInstance().getOperator(Operator.Type.Intersection); com.esri.core.geometry.GeometryCursor cursor = op.execute( getEsriGeometryCursor(), another.getEsriGeometryCursor(), getEsriSpatialReference(), null, 7); return OGCGeometry.createFromEsriCursor(cursor, esriSR, true); }
public OGCGeometry intersection(OGCGeometry another) { if (another.geometryType() == OGCConcreteGeometryCollection.TYPE) { return (new OGCConcreteGeometryCollection(this, esriSR)).intersection(another); } com.esri.core.geometry.OperatorIntersection op = (OperatorIntersection) OperatorFactoryLocal .getInstance().getOperator(Operator.Type.Intersection); com.esri.core.geometry.GeometryCursor cursor = op.execute( getEsriGeometryCursor(), another.getEsriGeometryCursor(), getEsriSpatialReference(), null, 7); return OGCGeometry.createFromEsriCursor(cursor, esriSR, true); }
public OGCGeometry buffer(double distance) { OperatorBuffer op = (OperatorBuffer) OperatorFactoryLocal.getInstance() .getOperator(Operator.Type.Buffer); if (distance == 0) {// when distance is 0, return self (maybe we should // create a copy instead). return this; } double d[] = { distance }; com.esri.core.geometry.GeometryCursor cursor = op.execute( getEsriGeometryCursor(), getEsriSpatialReference(), d, true, null); return OGCGeometry.createFromEsriGeometry(cursor.next(), esriSR); }