Search in sources :

Example 51 with SqlNullable

use of io.prestosql.spi.function.SqlNullable in project hetu-core by openlookeng.

the class GeoFunctions method stOverlaps.

@SqlNullable
@Description("Returns TRUE if the Geometries share space, are of the same dimension, but are not completely contained by each other")
@ScalarFunction("ST_Overlaps")
@SqlType(BOOLEAN)
public static Boolean stOverlaps(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right) {
    if (!envelopes(left, right, Envelope::intersect)) {
        return false;
    }
    OGCGeometry leftGeometry = deserialize(left);
    OGCGeometry rightGeometry = deserialize(right);
    verifySameSpatialReference(leftGeometry, rightGeometry);
    return leftGeometry.overlaps(rightGeometry);
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) SqlNullable(io.prestosql.spi.function.SqlNullable) ScalarFunction(io.prestosql.spi.function.ScalarFunction) Description(io.prestosql.spi.function.Description) SqlType(io.prestosql.spi.function.SqlType)

Example 52 with SqlNullable

use of io.prestosql.spi.function.SqlNullable in project hetu-core by openlookeng.

the class GeoFunctions method stEndPoint.

@SqlNullable
@Description("Returns the last point of a LINESTRING geometry as a Point")
@ScalarFunction("ST_EndPoint")
@SqlType(GEOMETRY_TYPE_NAME)
public static Slice stEndPoint(@SqlType(GEOMETRY_TYPE_NAME) Slice input) {
    OGCGeometry geometry = deserialize(input);
    validateType("ST_EndPoint", geometry, EnumSet.of(LINE_STRING));
    if (geometry.isEmpty()) {
        return null;
    }
    MultiPath lines = (MultiPath) geometry.getEsriGeometry();
    SpatialReference reference = geometry.getEsriSpatialReference();
    return serialize(createFromEsriGeometry(lines.getPoint(lines.getPointCount() - 1), reference));
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) MultiPath(com.esri.core.geometry.MultiPath) SpatialReference(com.esri.core.geometry.SpatialReference) SqlNullable(io.prestosql.spi.function.SqlNullable) ScalarFunction(io.prestosql.spi.function.ScalarFunction) Description(io.prestosql.spi.function.Description) SqlType(io.prestosql.spi.function.SqlType)

Aggregations

SqlNullable (io.prestosql.spi.function.SqlNullable)52 SqlType (io.prestosql.spi.function.SqlType)52 ScalarFunction (io.prestosql.spi.function.ScalarFunction)40 Description (io.prestosql.spi.function.Description)34 OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)28 JsonParser (com.fasterxml.jackson.core.JsonParser)14 PrestoException (io.prestosql.spi.PrestoException)14 JsonUtil.createJsonParser (io.prestosql.util.JsonUtil.createJsonParser)14 IOException (java.io.IOException)14 OGCPoint (com.esri.core.geometry.ogc.OGCPoint)11 MultiPoint (com.esri.core.geometry.MultiPoint)9 Point (com.esri.core.geometry.Point)9 BlockBuilder (io.prestosql.spi.block.BlockBuilder)8 ScalarOperator (io.prestosql.spi.function.ScalarOperator)8 JsonCastException (io.prestosql.util.JsonCastException)8 LiteralParameters (io.prestosql.spi.function.LiteralParameters)7 JsonToken (com.fasterxml.jackson.core.JsonToken)6 Slice (io.airlift.slice.Slice)6 MultiPath (com.esri.core.geometry.MultiPath)4 Block (io.prestosql.spi.block.Block)4