use of com.esri.core.geometry.Geometry in project calcite by apache.
the class GeoFunctions method ST_Union.
/**
* Computes the union of the geometries in {@code geomCollection}.
*/
@SemiStrict
public static Geom ST_Union(Geom geomCollection) {
SpatialReference sr = geomCollection.sr();
final Geometry g = GeometryEngine.union(new Geometry[] { geomCollection.g() }, sr);
return bind(g, sr);
}
use of com.esri.core.geometry.Geometry in project calcite by apache.
the class GeoFunctions method ST_Intersects.
/**
* Returns whether {@code geom1} intersects {@code geom2}.
*/
public static boolean ST_Intersects(Geom geom1, Geom geom2) {
final Geometry g1 = geom1.g();
final Geometry g2 = geom2.g();
final SpatialReference sr = geom1.sr();
return intersects(g1, g2, sr);
}
use of com.esri.core.geometry.Geometry in project calcite by apache.
the class GeoFunctions method ST_EnvelopesIntersect.
/**
* Returns whether the envelope of {@code geom1} intersects the envelope of
* {@code geom2}.
*/
public static boolean ST_EnvelopesIntersect(Geom geom1, Geom geom2) {
final Geometry e1 = envelope(geom1.g());
final Geometry e2 = envelope(geom2.g());
return intersects(e1, e2, geom1.sr());
}
use of com.esri.core.geometry.Geometry in project calcite by apache.
the class GeoFunctions method ST_Boundary.
/**
* Returns the boundary of {@code geom}.
*/
public static Geom ST_Boundary(Geom geom) {
OperatorBoundary op = OperatorBoundary.local();
Geometry result = op.execute(geom.g(), null);
return geom.wrap(result);
}
use of com.esri.core.geometry.Geometry in project presto by prestodb.
the class SphericalGeoFunctions method toSphericalGeography.
@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.isEmpty()) {
checkLatitude(envelope.getYMin());
checkLatitude(envelope.getYMax());
checkLongitude(envelope.getXMin());
checkLongitude(envelope.getXMax());
}
OGCGeometry geometry = EsriGeometrySerde.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;
}
Aggregations