use of org.locationtech.jts.geom.GeometryCollection in project arctic-sea by 52North.
the class GeoJSONTest method randomGeometryCollection.
private GeometryCollection randomGeometryCollection(int srid) {
GeometryCollection geometry = geometryFactory.createGeometryCollection(new Geometry[] { randomPoint(srid), randomMultiPoint(srid), randomLineString(srid), randomMultiLineString(srid), randomPolygon(srid), randomMultiPolygon(srid) });
geometry.setSRID(srid);
return geometry;
}
use of org.locationtech.jts.geom.GeometryCollection in project presto by prestodb.
the class GeoFunctions method stGeometries.
@SqlNullable
@Description("Returns an array of geometries in the specified collection")
@ScalarFunction("ST_Geometries")
@SqlType("array(" + GEOMETRY_TYPE_NAME + ")")
public static Block stGeometries(@SqlType(GEOMETRY_TYPE_NAME) Slice input) {
Geometry geometry = deserialize(input);
if (geometry.isEmpty()) {
return null;
}
GeometryType type = GeometryType.getForJtsGeometryType(geometry.getGeometryType());
if (!type.isMultitype()) {
BlockBuilder blockBuilder = GEOMETRY.createBlockBuilder(null, 1);
GEOMETRY.writeSlice(blockBuilder, serialize(geometry));
return blockBuilder.build();
}
GeometryCollection collection = (GeometryCollection) geometry;
BlockBuilder blockBuilder = GEOMETRY.createBlockBuilder(null, collection.getNumGeometries());
for (int i = 0; i < collection.getNumGeometries(); i++) {
GEOMETRY.writeSlice(blockBuilder, serialize(collection.getGeometryN(i)));
}
return blockBuilder.build();
}
use of org.locationtech.jts.geom.GeometryCollection in project presto by prestodb.
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) {
Geometry geometry = deserialize(input);
if (geometry.isEmpty()) {
return null;
}
GeometryType type = GeometryType.getForJtsGeometryType(geometry.getGeometryType());
if (!type.isMultitype()) {
if (index == 1) {
return input;
}
return null;
}
GeometryCollection geometryCollection = ((GeometryCollection) geometry);
if (index < 1 || index > geometryCollection.getNumGeometries()) {
return null;
}
return serialize(geometryCollection.getGeometryN((int) index - 1));
}
use of org.locationtech.jts.geom.GeometryCollection in project jena by apache.
the class WKTWriter method expand.
private static String expand(final Geometry geometry, final CoordinateSequenceDimensions dimensions) {
String wktString = "";
String dimensionString = CoordinateSequenceDimensions.convertDimensions(dimensions);
switch(geometry.getGeometryType()) {
case "Point":
Point point = (Point) geometry;
wktString = buildWKT("POINT", point.getCoordinateSequence(), dimensionString);
break;
case "LineString":
case "LinearRing":
LineString lineString = (LineString) geometry;
wktString = buildWKT("LINESTRING", lineString.getCoordinateSequence(), dimensionString);
break;
case "Polygon":
Polygon polygon = (Polygon) geometry;
wktString = buildPolygon(polygon, true, dimensionString);
break;
case "MultiPoint":
MultiPoint multiPoint = (MultiPoint) geometry;
wktString = buildMultiPoint(multiPoint, dimensionString);
break;
case "MultiLineString":
MultiLineString multiLineString = (MultiLineString) geometry;
wktString = buildMultiLineString(multiLineString, dimensionString);
break;
case "MultiPolygon":
MultiPolygon multiPolygon = (MultiPolygon) geometry;
wktString = buildMultiPolygon(multiPolygon, dimensionString);
break;
case "GeometryCollection":
GeometryCollection geometryCollection = (GeometryCollection) geometry;
wktString = buildGeometryCollection(geometryCollection, dimensions);
break;
}
return wktString;
}
use of org.locationtech.jts.geom.GeometryCollection in project series-rest-api by 52North.
the class GeoJSONTest method randomGeometryCollection.
private GeometryCollection randomGeometryCollection(int srid) {
GeometryCollection geometry = geometryFactory.createGeometryCollection(new Geometry[] { randomPoint(srid), randomMultiPoint(srid), randomLineString(srid), randomMultiLineString(srid), randomPolygon(srid), randomMultiPolygon(srid) });
geometry.setSRID(srid);
return geometry;
}
Aggregations