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);
}
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));
}
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());
}
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);
}
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);
}
Aggregations