use of org.geotoolkit.gml.xml.SurfaceProperty in project geotoolkit by Geomatys.
the class JAXPStreamFeatureWriter method setId.
/**
* @param inc auto increment value, ids must be unique
*/
private void setId(AbstractGeometry gmlGeometry, String id) {
if (gmlGeometry.getId() == null || gmlGeometry.getId().isEmpty()) {
// do not override ids if they exist
gmlGeometry.setId(id + (gidInc));
gidInc++;
}
if (gmlGeometry instanceof MultiCurve) {
for (CurveProperty po : ((MultiCurve) gmlGeometry).getCurveMember()) {
final AbstractCurve child = po.getAbstractCurve();
if (child instanceof AbstractGeometry) {
setId((AbstractGeometry) child, id);
}
}
} else if (gmlGeometry instanceof MultiSurface) {
for (SurfaceProperty po : ((MultiSurface) gmlGeometry).getSurfaceMember()) {
final AbstractSurface child = po.getAbstractSurface();
if (child instanceof AbstractGeometry) {
setId((AbstractGeometry) child, id);
}
}
} else if (gmlGeometry instanceof MultiGeometryType) {
for (GeometryPropertyType po : ((MultiGeometryType) gmlGeometry).getGeometryMember()) {
final AbstractGeometryType child = po.getAbstractGeometry();
if (child instanceof AbstractGeometry) {
setId((AbstractGeometry) child, id);
}
}
} else if (gmlGeometry instanceof MultiSolidType) {
for (SolidPropertyType po : ((MultiSolidType) gmlGeometry).getSolidMember()) {
final AbstractSolidType child = po.getAbstractSolid().getValue();
if (child instanceof AbstractGeometry) {
setId((AbstractGeometry) child, id);
}
}
} else if (gmlGeometry instanceof MultiPointType) {
for (PointPropertyType po : ((MultiPointType) gmlGeometry).getPointMember()) {
final PointType child = po.getPoint();
if (child instanceof AbstractGeometry) {
setId((AbstractGeometry) child, id);
}
}
}
}
use of org.geotoolkit.gml.xml.SurfaceProperty in project geotoolkit by Geomatys.
the class GeometryTransformer method convertMultiSurface.
private MultiPolygon convertMultiSurface(final MultiSurface mp) {
Polygon[] polys;
try {
polys = mp.getSurfaceMember().stream().map(SurfaceProperty::getAbstractSurface).map(surface -> {
if (surface instanceof AbstractGeometry) {
return (AbstractGeometry) surface;
}
throw new UnconvertibleObjectException("We cannot convert a non-geometric object: " + surface.getClass());
}).map(p -> new GeometryTransformer(p, this).get()).map(Polygon.class::cast).toArray(size -> new Polygon[size]);
} catch (ClassCastException e) {
throw new UnconvertibleObjectException("Cannot create a multi-surface, because some of its components are not polygons", e);
}
final MultiPolygon result = GF.createMultiPolygon(polys);
applyCRS(result);
return result;
}
Aggregations