@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; }
private static OGCGeometry createFromEsriGeometry(Geometry geometry, boolean multiType) Geometry.Type type = geometry.getType(); switch (type) { case Polygon: {
@Override public void copyTo(Geometry dst) { if (getType() != dst.getType()) throw new IllegalArgumentException(); m_impl.copyTo((Geometry) dst._getImpl()); }
@Override public void copyTo(Geometry dst) { if (getType() != dst.getType()) throw new IllegalArgumentException(); m_impl.copyTo((Geometry) dst._getImpl()); }
public static void testPointsInArea2D(Geometry polygon, double[] xyStreamBuffer, int count, double tolerance, PiPResult[] testResults) { if (polygon.getType() == Geometry.Type.Polygon) testPointsInPolygon2D((Polygon) polygon, xyStreamBuffer, count, tolerance, testResults); else if (polygon.getType() == Geometry.Type.Envelope) { Envelope2D env2D = new Envelope2D(); ((Envelope) polygon).queryEnvelope2D(env2D); _testPointsInEnvelope2D(env2D, xyStreamBuffer, count, tolerance, testResults); } else throw new GeometryException("invalid_call");// GEOMTHROW(invalid_call); }
int addGeometry(Geometry geometry) { Geometry.Type gt = geometry.getType(); if (Geometry.isMultiPath(gt.value())) return addMultiPath_((MultiPath) geometry); if (gt == Geometry.Type.MultiPoint) return addMultiPoint_((MultiPoint) geometry); throw GeometryException.GeometryInternalError(); }
static void testPointsOnLine2D(Geometry line, Point2D[] input_points, int count, double tolerance, PolygonUtils.PiPResult[] test_results) { Geometry.Type gt = line.getType(); if (gt == Geometry.Type.Polyline) testPointsOnPolyline2D_((Polyline) line, input_points, count, tolerance, test_results); else if (Geometry.isSegment(gt.value())) { testPointsOnSegment_((Segment) line, input_points, count, tolerance, test_results); } else throw new GeometryException("Invalid call."); }
int addGeometry(Geometry geometry) { Geometry.Type gt = geometry.getType(); if (Geometry.isMultiPath(gt.value())) return addMultiPath_((MultiPath) geometry); if (gt == Geometry.Type.MultiPoint) return addMultiPoint_((MultiPoint) geometry); throw GeometryException.GeometryInternalError(); }
static void testPointsOnLine2D(Geometry line, Point2D[] input_points, int count, double tolerance, PolygonUtils.PiPResult[] test_results) { Geometry.Type gt = line.getType(); if (gt == Geometry.Type.Polyline) testPointsOnPolyline2D_((Polyline) line, input_points, count, tolerance, test_results); else if (Geometry.isSegment(gt.value())) { testPointsOnSegment_((Segment) line, input_points, count, tolerance, test_results); } else throw new GeometryException("Invalid call."); }
private static int get_vertex_count_(Geometry geom) { int gt = geom.getType().value(); if (Geometry.isMultiVertex(gt)) { return ((MultiVertexGeometry) geom).getPointCount(); } else if (gt == Geometry.GeometryType.Point) { return 1; } else if (gt == Geometry.GeometryType.Envelope) { return 4; } else if (Geometry.isSegment(gt)) { return 2; } else { throw GeometryException.GeometryInternalError(); } }
void appendGeometry(int dstGeometry, Geometry srcGeometry) { Geometry.Type gt = srcGeometry.getType(); if (Geometry.isMultiPath(gt.value())) { appendMultiPath_(dstGeometry, (MultiPath) srcGeometry); return; } else if (gt.value() == Geometry.GeometryType.MultiPoint) { appendMultiPoint_(dstGeometry, (MultiPoint) srcGeometry); return; } throw GeometryException.GeometryInternalError(); }
void appendGeometry(int dstGeometry, Geometry srcGeometry) { Geometry.Type gt = srcGeometry.getType(); if (Geometry.isMultiPath(gt.value())) { appendMultiPath_(dstGeometry, (MultiPath) srcGeometry); return; } else if (gt.value() == Geometry.GeometryType.MultiPoint) { appendMultiPoint_(dstGeometry, (MultiPoint) srcGeometry); return; } throw GeometryException.GeometryInternalError(); }