Search in sources :

Example 96 with ScalarFunction

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

the class GeoFunctions method stPolygon.

@Description("Returns a Geometry type Polygon object from Well-Known Text representation (WKT)")
@ScalarFunction("ST_Polygon")
@SqlType(GEOMETRY_TYPE_NAME)
public static Slice stPolygon(@SqlType(VARCHAR) Slice input) {
    OGCGeometry geometry = geometryFromText(input);
    validateType("ST_Polygon", geometry, EnumSet.of(POLYGON));
    return serialize(geometry);
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) ScalarFunction(io.prestosql.spi.function.ScalarFunction) Description(io.prestosql.spi.function.Description) SqlType(io.prestosql.spi.function.SqlType)

Example 97 with ScalarFunction

use of io.prestosql.spi.function.ScalarFunction 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

ScalarFunction (io.prestosql.spi.function.ScalarFunction)97 SqlType (io.prestosql.spi.function.SqlType)96 Description (io.prestosql.spi.function.Description)76 OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)40 SqlNullable (io.prestosql.spi.function.SqlNullable)40 LiteralParameters (io.prestosql.spi.function.LiteralParameters)20 Slice (io.airlift.slice.Slice)18 BlockBuilder (io.prestosql.spi.block.BlockBuilder)17 Constraint (io.prestosql.type.Constraint)16 Point (com.esri.core.geometry.Point)14 OGCPoint (com.esri.core.geometry.ogc.OGCPoint)14 MultiPoint (com.esri.core.geometry.MultiPoint)12 PrestoException (io.prestosql.spi.PrestoException)12 SliceUtf8.lengthOfCodePoint (io.airlift.slice.SliceUtf8.lengthOfCodePoint)8 SliceUtf8.offsetOfCodePoint (io.airlift.slice.SliceUtf8.offsetOfCodePoint)8 JsonParser (com.fasterxml.jackson.core.JsonParser)7 JsonUtil.createJsonParser (io.prestosql.util.JsonUtil.createJsonParser)7 IOException (java.io.IOException)7 JsonToken (com.fasterxml.jackson.core.JsonToken)6 GeometryType (io.prestosql.geospatial.GeometryType)6