use of io.prestosql.spi.function.Description in project hetu-core by openlookeng.
the class GeoFunctions method stEquals.
@SqlNullable
@Description("Returns TRUE if the given geometries represent the same geometry")
@ScalarFunction("ST_Equals")
@SqlType(BOOLEAN)
public static Boolean stEquals(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right) {
OGCGeometry leftGeometry = deserialize(left);
OGCGeometry rightGeometry = deserialize(right);
verifySameSpatialReference(leftGeometry, rightGeometry);
return leftGeometry.equals(rightGeometry);
}
use of io.prestosql.spi.function.Description in project hetu-core by openlookeng.
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) {
OGCGeometry geometry = deserialize(input);
validateType("ST_PointN", geometry, EnumSet.of(LINE_STRING));
OGCLineString linestring = (OGCLineString) geometry;
if (index < 1 || index > linestring.numPoints()) {
return null;
}
return serialize(linestring.pointN(toIntExact(index) - 1));
}
use of io.prestosql.spi.function.Description in project hetu-core by openlookeng.
the class GeoFunctions method stGeometryN.
@SqlNullable
@Description("Returns the geometry element at the specified index (indices started with 1)")
@ScalarFunction("ST_GeometryN")
@SqlType(GEOMETRY_TYPE_NAME)
public static Slice stGeometryN(@SqlType(GEOMETRY_TYPE_NAME) Slice input, @SqlType(INTEGER) long index) {
OGCGeometry geometry = deserialize(input);
if (geometry.isEmpty()) {
return null;
}
GeometryType type = GeometryType.getForEsriGeometryType(geometry.geometryType());
if (!type.isMultitype()) {
if (index == 1) {
return input;
}
return null;
}
OGCGeometryCollection geometryCollection = ((OGCGeometryCollection) geometry);
if (index < 1 || index > geometryCollection.numGeometries()) {
return null;
}
OGCGeometry ogcGeometry = geometryCollection.geometryN((int) index - 1);
return serialize(ogcGeometry);
}
use of io.prestosql.spi.function.Description 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);
}
use of io.prestosql.spi.function.Description 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);
}
Aggregations