use of org.locationtech.jts.geom.MultiLineString in project arctic-sea by 52North.
the class GeoJSONEncoder method encode.
protected ObjectNode encode(MultiLineString geometry, int parentSrid) {
Preconditions.checkNotNull(geometry);
ObjectNode json = jsonFactory.objectNode();
ArrayNode list = json.put(JSONConstants.TYPE, JSONConstants.MULTI_LINE_STRING).putArray(JSONConstants.COORDINATES);
for (int i = 0; i < geometry.getNumGeometries(); ++i) {
list.add(encodeCoordinates((LineString) geometry.getGeometryN(i)));
}
encodeCRS(json, geometry, parentSrid);
return json;
}
use of org.locationtech.jts.geom.MultiLineString in project presto by prestodb.
the class GeoFunctions method stIsClosed.
@SqlNullable
@Description("Returns TRUE if the LineString or Multi-LineString's start and end points are coincident")
@ScalarFunction("ST_IsClosed")
@SqlType(BOOLEAN)
public static Boolean stIsClosed(@SqlType(GEOMETRY_TYPE_NAME) Slice input) {
Geometry geometry = deserialize(input);
validateType("ST_IsClosed", geometry, EnumSet.of(LINE_STRING, MULTI_LINE_STRING));
if (geometry instanceof LineString) {
return ((LineString) geometry).isClosed();
} else if (geometry instanceof MultiLineString) {
return ((MultiLineString) geometry).isClosed();
}
// This would be handled in validateType, but for completeness.
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Invalid type for isClosed: %s", geometry.getGeometryType()));
}
Aggregations