Search in sources :

Example 96 with Description

use of com.facebook.presto.spi.function.Description in project presto by prestodb.

the class GeoFunctions method stIntersects.

@SqlNullable
@Description("Returns TRUE if the Geometries spatially intersect in 2D - (share any portion of space) and FALSE if they don't (they are Disjoint)")
@ScalarFunction("ST_Intersects")
@SqlType(BOOLEAN)
public static Boolean stIntersects(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right) {
    if (!envelopes(left, right, Envelope::intersect)) {
        return false;
    }
    OGCGeometry leftGeometry = EsriGeometrySerde.deserialize(left);
    OGCGeometry rightGeometry = EsriGeometrySerde.deserialize(right);
    verifySameSpatialReference(leftGeometry, rightGeometry);
    return leftGeometry.intersects(rightGeometry);
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) SqlNullable(com.facebook.presto.spi.function.SqlNullable) ScalarFunction(com.facebook.presto.spi.function.ScalarFunction) Description(com.facebook.presto.spi.function.Description) SqlType(com.facebook.presto.spi.function.SqlType)

Example 97 with Description

use of com.facebook.presto.spi.function.Description in project presto by prestodb.

the class GeoFunctions method stPointN.

@SqlNullable
@Description("Returns the vertex of a linestring at the specified index (indices started with 1) ")
@ScalarFunction("ST_PointN")
@SqlType(GEOMETRY_TYPE_NAME)
public static Slice stPointN(@SqlType(GEOMETRY_TYPE_NAME) Slice input, @SqlType(INTEGER) long index) {
    Geometry geometry = deserialize(input);
    validateType("ST_PointN", geometry, EnumSet.of(LINE_STRING));
    LineString linestring = (LineString) geometry;
    if (index < 1 || index > linestring.getNumPoints()) {
        return null;
    }
    return serialize(linestring.getPointN(toIntExact(index) - 1));
}
Also used : GeometryUtils.wktFromJtsGeometry(com.facebook.presto.geospatial.GeometryUtils.wktFromJtsGeometry) OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) OGCGeometry.createFromEsriGeometry(com.esri.core.geometry.ogc.OGCGeometry.createFromEsriGeometry) Geometry(org.locationtech.jts.geom.Geometry) GeometryUtils.jsonFromJtsGeometry(com.facebook.presto.geospatial.GeometryUtils.jsonFromJtsGeometry) GeometryUtils.createJtsEmptyLineString(com.facebook.presto.geospatial.GeometryUtils.createJtsEmptyLineString) GeometryUtils.createJtsLineString(com.facebook.presto.geospatial.GeometryUtils.createJtsLineString) MultiLineString(org.locationtech.jts.geom.MultiLineString) OGCLineString(com.esri.core.geometry.ogc.OGCLineString) LineString(org.locationtech.jts.geom.LineString) SqlNullable(com.facebook.presto.spi.function.SqlNullable) ScalarFunction(com.facebook.presto.spi.function.ScalarFunction) Description(com.facebook.presto.spi.function.Description) SqlType(com.facebook.presto.spi.function.SqlType)

Example 98 with Description

use of com.facebook.presto.spi.function.Description in project presto by prestodb.

the class GeoFunctions method stRelate.

@SqlNullable
@Description("Returns TRUE if this Geometry is spatially related to another Geometry")
@ScalarFunction("ST_Relate")
@SqlType(BOOLEAN)
public static Boolean stRelate(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right, @SqlType(VARCHAR) Slice relation) {
    OGCGeometry leftGeometry = EsriGeometrySerde.deserialize(left);
    OGCGeometry rightGeometry = EsriGeometrySerde.deserialize(right);
    verifySameSpatialReference(leftGeometry, rightGeometry);
    return leftGeometry.relate(rightGeometry, relation.toStringUtf8());
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) SqlNullable(com.facebook.presto.spi.function.SqlNullable) ScalarFunction(com.facebook.presto.spi.function.ScalarFunction) Description(com.facebook.presto.spi.function.Description) SqlType(com.facebook.presto.spi.function.SqlType)

Example 99 with Description

use of com.facebook.presto.spi.function.Description in project presto by prestodb.

the class GeoFunctions method stWithin.

@SqlNullable
@Description("Returns TRUE if the geometry A is completely inside geometry B")
@ScalarFunction("ST_Within")
@SqlType(BOOLEAN)
public static Boolean stWithin(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right) {
    if (!envelopes(right, left, Envelope::contains)) {
        return false;
    }
    OGCGeometry leftGeometry = EsriGeometrySerde.deserialize(left);
    OGCGeometry rightGeometry = EsriGeometrySerde.deserialize(right);
    verifySameSpatialReference(leftGeometry, rightGeometry);
    return leftGeometry.within(rightGeometry);
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) SqlNullable(com.facebook.presto.spi.function.SqlNullable) ScalarFunction(com.facebook.presto.spi.function.ScalarFunction) Description(com.facebook.presto.spi.function.Description) SqlType(com.facebook.presto.spi.function.SqlType)

Example 100 with Description

use of com.facebook.presto.spi.function.Description in project presto by prestodb.

the class GeoFunctions method stDisjoint.

@SqlNullable
@Description("Returns TRUE if the Geometries do not spatially intersect - if they do not share any space together")
@ScalarFunction("ST_Disjoint")
@SqlType(BOOLEAN)
public static Boolean stDisjoint(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right) {
    if (!envelopes(left, right, Envelope::intersect)) {
        return true;
    }
    OGCGeometry leftGeometry = EsriGeometrySerde.deserialize(left);
    OGCGeometry rightGeometry = EsriGeometrySerde.deserialize(right);
    verifySameSpatialReference(leftGeometry, rightGeometry);
    return leftGeometry.disjoint(rightGeometry);
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) SqlNullable(com.facebook.presto.spi.function.SqlNullable) ScalarFunction(com.facebook.presto.spi.function.ScalarFunction) Description(com.facebook.presto.spi.function.Description) SqlType(com.facebook.presto.spi.function.SqlType)

Aggregations

Description (com.facebook.presto.spi.function.Description)105 SqlType (com.facebook.presto.spi.function.SqlType)103 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)101 OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)41 SqlNullable (com.facebook.presto.spi.function.SqlNullable)37 OGCGeometry.createFromEsriGeometry (com.esri.core.geometry.ogc.OGCGeometry.createFromEsriGeometry)20 GeometryUtils.jsonFromJtsGeometry (com.facebook.presto.geospatial.GeometryUtils.jsonFromJtsGeometry)20 GeometryUtils.wktFromJtsGeometry (com.facebook.presto.geospatial.GeometryUtils.wktFromJtsGeometry)20 Geometry (org.locationtech.jts.geom.Geometry)20 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)19 PrestoException (com.facebook.presto.spi.PrestoException)18 LiteralParameters (com.facebook.presto.spi.function.LiteralParameters)15 Slice (io.airlift.slice.Slice)15 SqlScalarFunction (com.facebook.presto.metadata.SqlScalarFunction)14 Constraint (com.facebook.presto.type.Constraint)14 DecimalOperators.modulusScalarFunction (com.facebook.presto.type.DecimalOperators.modulusScalarFunction)13 Point (com.esri.core.geometry.Point)10 SliceUtf8.lengthOfCodePoint (io.airlift.slice.SliceUtf8.lengthOfCodePoint)7 SliceUtf8.offsetOfCodePoint (io.airlift.slice.SliceUtf8.offsetOfCodePoint)7 Envelope (com.esri.core.geometry.Envelope)6