Search in sources :

Example 6 with MultiLineString

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Point(org.locationtech.jts.geom.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint)

Example 7 with MultiLineString

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()));
}
Also used : GeometryUtils.wktFromJtsGeometry(com.facebook.presto.geospatial.GeometryUtils.wktFromJtsGeometry) OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) OGCGeometry.createFromEsriGeometry(com.esri.core.geometry.ogc.OGCGeometry.createFromEsriGeometry) Geometry(org.locationtech.jts.geom.Geometry) GeometryUtils.jsonFromJtsGeometry(com.facebook.presto.geospatial.GeometryUtils.jsonFromJtsGeometry) MultiLineString(org.locationtech.jts.geom.MultiLineString) GeometryUtils.createJtsEmptyLineString(com.facebook.presto.geospatial.GeometryUtils.createJtsEmptyLineString) GeometryUtils.createJtsLineString(com.facebook.presto.geospatial.GeometryUtils.createJtsLineString) MultiLineString(org.locationtech.jts.geom.MultiLineString) OGCLineString(com.esri.core.geometry.ogc.OGCLineString) LineString(org.locationtech.jts.geom.LineString) PrestoException(com.facebook.presto.spi.PrestoException) SqlNullable(com.facebook.presto.spi.function.SqlNullable) ScalarFunction(com.facebook.presto.spi.function.ScalarFunction) Description(com.facebook.presto.spi.function.Description) SqlType(com.facebook.presto.spi.function.SqlType)

Aggregations

MultiLineString (org.locationtech.jts.geom.MultiLineString)7 LineString (org.locationtech.jts.geom.LineString)5 MultiPoint (org.locationtech.jts.geom.MultiPoint)3 Point (org.locationtech.jts.geom.Point)3 Geometry (org.locationtech.jts.geom.Geometry)2 OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)1 OGCGeometry.createFromEsriGeometry (com.esri.core.geometry.ogc.OGCGeometry.createFromEsriGeometry)1 OGCLineString (com.esri.core.geometry.ogc.OGCLineString)1 GeometryUtils.createJtsEmptyLineString (com.facebook.presto.geospatial.GeometryUtils.createJtsEmptyLineString)1 GeometryUtils.createJtsLineString (com.facebook.presto.geospatial.GeometryUtils.createJtsLineString)1 GeometryUtils.jsonFromJtsGeometry (com.facebook.presto.geospatial.GeometryUtils.jsonFromJtsGeometry)1 GeometryUtils.wktFromJtsGeometry (com.facebook.presto.geospatial.GeometryUtils.wktFromJtsGeometry)1 PrestoException (com.facebook.presto.spi.PrestoException)1 Description (com.facebook.presto.spi.function.Description)1 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)1 SqlNullable (com.facebook.presto.spi.function.SqlNullable)1 SqlType (com.facebook.presto.spi.function.SqlType)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1