use of org.locationtech.jts.geom.MultiPolygon in project arctic-sea by 52North.
the class GeoJSONEncoder method encode.
protected ObjectNode encode(MultiPolygon geometry, int parentSrid) {
Preconditions.checkNotNull(geometry);
ObjectNode json = jsonFactory.objectNode();
ArrayNode list = json.put(JSONConstants.TYPE, JSONConstants.MULTI_POLYGON).putArray(JSONConstants.COORDINATES);
for (int i = 0; i < geometry.getNumGeometries(); ++i) {
list.add(encodeCoordinates((Polygon) geometry.getGeometryN(i)));
}
encodeCRS(json, geometry, parentSrid);
return json;
}
use of org.locationtech.jts.geom.MultiPolygon in project arctic-sea by 52North.
the class GeoJSONDecoder method decodeMultiPolygon.
protected MultiPolygon decodeMultiPolygon(JsonNode node, GeometryFactory fac) throws GeoJSONDecodingException {
JsonNode coordinates = requireCoordinates(node);
Polygon[] polygons = new Polygon[coordinates.size()];
for (int i = 0; i < coordinates.size(); ++i) {
polygons[i] = decodePolygonCoordinates(coordinates.get(i), fac);
}
return fac.createMultiPolygon(polygons);
}
use of org.locationtech.jts.geom.MultiPolygon in project arctic-sea by 52North.
the class GeoJSONTest method testMultiPolygonWithZCoordinate.
@Test
public void testMultiPolygonWithZCoordinate() throws GeoJSONDecodingException, IOException {
MultiPolygon geometry = randomMultiPolygon(EPSG_4326);
geometry.apply(new RandomZCoordinateFilter());
geometry.geometryChanged();
readWriteTest(geometry);
}
use of org.locationtech.jts.geom.MultiPolygon in project arctic-sea by 52North.
the class GeoJSONTest method randomMultiPolygon.
private MultiPolygon randomMultiPolygon(int srid) {
MultiPolygon geometry = geometryFactory.createMultiPolygon(new Polygon[] { randomPolygon(srid), randomPolygon(srid), randomPolygon(srid) });
geometry.setSRID(srid);
return geometry;
}
Aggregations