use of org.locationtech.jts.geom.MultiPoint in project arctic-sea by 52North.
the class GeoJSONTest method testMultiPointWithZCoordinate.
@Test
public void testMultiPointWithZCoordinate() {
MultiPoint geometry = randomMultiPoint(EPSG_4326);
geometry.apply(new RandomZCoordinateFilter());
geometry.geometryChanged();
readWriteTest(geometry);
}
use of org.locationtech.jts.geom.MultiPoint in project arctic-sea by 52North.
the class GeoJSONTest method randomMultiPoint.
private MultiPoint randomMultiPoint(int srid) {
MultiPoint geometry = geometryFactory.createMultiPointFromCoords(new Coordinate[] { randomCoordinate(), randomCoordinate(), randomCoordinate(), randomCoordinate(), randomCoordinate(), randomCoordinate() });
geometry.setSRID(srid);
return geometry;
}
use of org.locationtech.jts.geom.MultiPoint in project arctic-sea by 52North.
the class GmlEncoderv321 method createPosition.
private XmlObject createPosition(Geometry geom, EncodingContext ctx) throws EncodingException {
String foiId = ctx.<String>get(XmlBeansEncodingFlags.GMLID).orElse(null);
if (geom instanceof Point) {
PointType xbPoint = PointType.Factory.newInstance(getXmlOptions());
xbPoint.setId(getGmlID(geom, foiId));
createPointFromJtsGeometry((Point) geom, xbPoint);
if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
PointDocument xbPointDoc = PointDocument.Factory.newInstance(getXmlOptions());
xbPointDoc.setPoint(xbPoint);
return xbPointDoc;
} else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
geometryPropertyType.setAbstractGeometry(xbPoint);
geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_POINT_32, PointType.type);
return geometryPropertyType;
}
return xbPoint;
} else if (geom instanceof LineString) {
LineStringType xbLineString = LineStringType.Factory.newInstance(getXmlOptions());
xbLineString.setId(getGmlID(geom, foiId));
createLineStringFromJtsGeometry((LineString) geom, xbLineString);
if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
LineStringDocument xbLineStringDoc = LineStringDocument.Factory.newInstance(getXmlOptions());
xbLineStringDoc.setLineString(xbLineString);
return xbLineStringDoc;
} else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
geometryPropertyType.setAbstractGeometry(xbLineString);
geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_LINESTRING_32, LineStringType.type);
return geometryPropertyType;
}
return xbLineString;
} else if (geom instanceof MultiLineString) {
MultiCurveType xbMultiCurve = MultiCurveType.Factory.newInstance(getXmlOptions());
xbMultiCurve.setId(getGmlID(geom, foiId));
xbMultiCurve.setSrsName(getSrsName(geom));
for (int i = 0; i < geom.getNumGeometries(); ++i) {
Geometry lineString = geom.getGeometryN(i);
LineStringType xbLineString = LineStringType.Factory.newInstance(getXmlOptions());
xbLineString.setId(getGmlID(geom, foiId));
xbLineString.addNewPosList().setStringValue(JTSHelper.getCoordinatesString(lineString));
CurvePropertyType xbCurveMember = xbMultiCurve.addNewCurveMember();
xbCurveMember.addNewAbstractCurve().set(xbLineString);
XmlHelper.substituteElement(xbCurveMember.getAbstractCurve(), xbLineString);
}
if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
MultiCurveDocument xbMultiCurveDoc = MultiCurveDocument.Factory.newInstance(getXmlOptions());
xbMultiCurveDoc.setMultiCurve(xbMultiCurve);
return xbMultiCurveDoc;
} else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
GeometryPropertyType xbGeometryProperty = GeometryPropertyType.Factory.newInstance(getXmlOptions());
xbGeometryProperty.addNewAbstractGeometry().set(xbMultiCurve);
XmlHelper.substituteElement(xbGeometryProperty.getAbstractGeometry(), xbMultiCurve);
return xbGeometryProperty;
} else {
return xbMultiCurve;
}
} else if (geom instanceof Polygon) {
PolygonType xbPolygon = PolygonType.Factory.newInstance(getXmlOptions());
xbPolygon.setId(getGmlID(geom, foiId));
createPolygonFromJtsGeometry((Polygon) geom, xbPolygon);
if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
PolygonDocument xbPolygonDoc = PolygonDocument.Factory.newInstance(getXmlOptions());
xbPolygonDoc.setPolygon(xbPolygon);
return xbPolygonDoc;
} else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
geometryPropertyType.setAbstractGeometry(xbPolygon);
geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_POLYGON_32, PolygonType.type);
return geometryPropertyType;
}
return xbPolygon;
} else if (geom instanceof MultiPoint) {
MultiPointType xbMultiPoint = MultiPointType.Factory.newInstance(getXmlOptions());
String id = getGmlID(geom, foiId);
xbMultiPoint.setId(id);
createMultiPointFromJtsGeometry((MultiPoint) geom, xbMultiPoint, id);
if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
MultiPointDocument xbMultiPointDoc = MultiPointDocument.Factory.newInstance(getXmlOptions());
xbMultiPointDoc.setMultiPoint(xbMultiPoint);
return xbMultiPointDoc;
} else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
geometryPropertyType.setAbstractGeometry(xbMultiPoint);
geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_MULTI_POINT_32, PolygonType.type);
return geometryPropertyType;
}
return xbMultiPoint;
} else {
throw new UnsupportedEncoderInputException(this, geom);
}
}
use of org.locationtech.jts.geom.MultiPoint in project arctic-sea by 52North.
the class GeoJSONEncoder method encode.
protected ObjectNode encode(MultiPoint geometry, int parentSrid) {
Preconditions.checkNotNull(geometry);
ObjectNode json = jsonFactory.objectNode();
ArrayNode list = json.put(JSONConstants.TYPE, JSONConstants.MULTI_POINT).putArray(JSONConstants.COORDINATES);
for (int i = 0; i < geometry.getNumGeometries(); ++i) {
list.add(encodeCoordinates((Point) geometry.getGeometryN(i)));
}
encodeCRS(json, geometry, parentSrid);
return json;
}
use of org.locationtech.jts.geom.MultiPoint in project arctic-sea by 52North.
the class AbstractMultiPointCoverageTypeEncoder method encodeMultiPointDomain.
private void encodeMultiPointDomain(DiscreteCoverageType dct, PointValueLists pointValues) throws EncodingException {
MultiPointDomainDocument mpdd = MultiPointDomainDocument.Factory.newInstance();
DomainSetType mpdst = mpdd.addNewMultiPointDomain();
GeometryFactory factory = pointValues.getPoints().get(0).getFactory();
MultiPoint multiPoint = factory.createMultiPoint(pointValues.getPoints().toArray(new Point[0]));
EncodingContext ec = EncodingContext.of(XmlBeansEncodingFlags.GMLID, JavaHelper.generateID(multiPoint.toString())).with(XmlBeansEncodingFlags.PROPERTY_TYPE, true);
XmlObject encodedGeometry = encodeGML(multiPoint, ec);
mpdst.addNewAbstractGeometry().set(encodedGeometry);
substitute(mpdst.getAbstractGeometry(), encodedGeometry);
dct.setDomainSet(mpdst);
}
Aggregations