Search in sources :

Example 1 with Geometry

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);
}
Also used : Geometry(com.esri.core.geometry.Geometry) MapGeometry(com.esri.core.geometry.MapGeometry) SpatialReference(com.esri.core.geometry.SpatialReference) SemiStrict(org.apache.calcite.linq4j.function.SemiStrict)

Example 2 with Geometry

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);
}
Also used : Geometry(com.esri.core.geometry.Geometry) MapGeometry(com.esri.core.geometry.MapGeometry) SpatialReference(com.esri.core.geometry.SpatialReference)

Example 3 with Geometry

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());
}
Also used : Geometry(com.esri.core.geometry.Geometry) MapGeometry(com.esri.core.geometry.MapGeometry)

Example 4 with Geometry

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);
}
Also used : Geometry(com.esri.core.geometry.Geometry) MapGeometry(com.esri.core.geometry.MapGeometry) OperatorBoundary(com.esri.core.geometry.OperatorBoundary)

Example 5 with Geometry

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;
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) GeometryCursor(com.esri.core.geometry.GeometryCursor) PrestoException(com.facebook.presto.spi.PrestoException) Geometry(com.esri.core.geometry.Geometry) EsriGeometrySerde.deserializeEnvelope(com.facebook.presto.geospatial.serde.EsriGeometrySerde.deserializeEnvelope) Envelope(com.esri.core.geometry.Envelope) ScalarFunction(com.facebook.presto.spi.function.ScalarFunction) Description(com.facebook.presto.spi.function.Description) SqlType(com.facebook.presto.spi.function.SqlType)

Aggregations

Geometry (com.esri.core.geometry.Geometry)16 OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)8 Point (com.esri.core.geometry.Point)5 GeometryCursor (com.esri.core.geometry.GeometryCursor)4 MapGeometry (com.esri.core.geometry.MapGeometry)4 Envelope (com.esri.core.geometry.Envelope)3 OGCPoint (com.esri.core.geometry.ogc.OGCPoint)3 MultiPoint (com.esri.core.geometry.MultiPoint)2 MultiVertexGeometry (com.esri.core.geometry.MultiVertexGeometry)2 SpatialReference (com.esri.core.geometry.SpatialReference)2 OGCMultiPoint (com.esri.core.geometry.ogc.OGCMultiPoint)2 PrestoException (com.facebook.presto.spi.PrestoException)2 SqlType (com.facebook.presto.spi.function.SqlType)2 Envelope2D (com.esri.core.geometry.Envelope2D)1 OperatorBoundary (com.esri.core.geometry.OperatorBoundary)1 OperatorIntersects (com.esri.core.geometry.OperatorIntersects)1 GeoEvent (com.esri.ges.core.geoevent.GeoEvent)1 StandardTypes (com.facebook.presto.common.type.StandardTypes)1 GeometryUtils.accelerateGeometry (com.facebook.presto.geospatial.GeometryUtils.accelerateGeometry)1 GeometryUtils.getEnvelope (com.facebook.presto.geospatial.GeometryUtils.getEnvelope)1