use of com.facebook.presto.spi.function.Description in project presto by prestodb.
the class GeoFunctions method stPoints.
@SqlNullable
@Description("Returns an array of points in a geometry")
@ScalarFunction("ST_Points")
@SqlType("array(" + GEOMETRY_TYPE_NAME + ")")
public static Block stPoints(@SqlType(GEOMETRY_TYPE_NAME) Slice input) {
Geometry geometry = deserialize(input);
if (geometry.isEmpty()) {
return null;
}
BlockBuilder blockBuilder = GEOMETRY.createBlockBuilder(null, geometry.getNumPoints());
buildPointsBlock(geometry, blockBuilder);
return blockBuilder.build();
}
use of com.facebook.presto.spi.function.Description in project presto by prestodb.
the class GeoFunctions method stCentroid.
@Description("Returns the Point value that is the mathematical centroid of a Geometry")
@ScalarFunction("ST_Centroid")
@SqlType(GEOMETRY_TYPE_NAME)
public static Slice stCentroid(@SqlType(GEOMETRY_TYPE_NAME) Slice input) {
Geometry geometry = deserialize(input);
validateType("ST_Centroid", geometry, EnumSet.of(POINT, MULTI_POINT, LINE_STRING, MULTI_LINE_STRING, POLYGON, MULTI_POLYGON));
GeometryType geometryType = GeometryType.getForJtsGeometryType(geometry.getGeometryType());
if (geometryType == GeometryType.POINT) {
return input;
}
if (geometry.getNumPoints() == 0) {
return serialize(createJtsEmptyPoint());
}
return serialize(geometry.getCentroid());
}
use of com.facebook.presto.spi.function.Description in project presto by prestodb.
the class GeoFunctions method stDifference.
@Description("Returns the Geometry value that represents the point set difference of two geometries")
@ScalarFunction("ST_Difference")
@SqlType(GEOMETRY_TYPE_NAME)
public static Slice stDifference(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right) {
OGCGeometry leftGeometry = EsriGeometrySerde.deserialize(left);
OGCGeometry rightGeometry = EsriGeometrySerde.deserialize(right);
verifySameSpatialReference(leftGeometry, rightGeometry);
return EsriGeometrySerde.serialize(leftGeometry.difference(rightGeometry));
}
use of com.facebook.presto.spi.function.Description in project presto by prestodb.
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) {
Geometry geometry = deserialize(input);
validateType("ST_EndPoint", geometry, EnumSet.of(LINE_STRING));
if (geometry.isEmpty()) {
return null;
}
return serialize(((LineString) geometry).getEndPoint());
}
use of com.facebook.presto.spi.function.Description in project presto by prestodb.
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) {
Geometry geometry = jtsGeometryFromWkt(input.toStringUtf8());
validateType("ST_Polygon", geometry, EnumSet.of(POLYGON));
return serialize(geometry);
}
Aggregations