use of io.trino.geospatial.GeometryType in project trino by trinodb.
the class EncodedPolylineFunctions method toEncodedPolyline.
@Description("Encodes a linestring or multipoint geometry to a polyline")
@ScalarFunction("to_encoded_polyline")
@SqlType(StandardTypes.VARCHAR)
public static Slice toEncodedPolyline(@SqlType(GEOMETRY_TYPE_NAME) Slice input) {
OGCGeometry geometry = deserialize(input);
validateType("encode_polyline", geometry, EnumSet.of(LINE_STRING, MULTI_POINT));
GeometryType geometryType = GeometryType.getForEsriGeometryType(geometry.geometryType());
switch(geometryType) {
case LINE_STRING:
case MULTI_POINT:
return encodePolyline((MultiVertexGeometry) geometry.getEsriGeometry());
default:
throw new TrinoException(INVALID_FUNCTION_ARGUMENT, "Unexpected geometry type: " + geometryType);
}
}
use of io.trino.geospatial.GeometryType in project trino by trinodb.
the class GeoFunctions method stNumGeometries.
@Description("Returns the cardinality of the geometry collection")
@ScalarFunction("ST_NumGeometries")
@SqlType(INTEGER)
public static long stNumGeometries(@SqlType(GEOMETRY_TYPE_NAME) Slice input) {
OGCGeometry geometry = deserialize(input);
if (geometry.isEmpty()) {
return 0;
}
GeometryType type = GeometryType.getForEsriGeometryType(geometry.geometryType());
if (!type.isMultitype()) {
return 1;
}
return ((OGCGeometryCollection) geometry).numGeometries();
}
Aggregations