use of org.locationtech.jts.geom.GeometryFactory in project arctic-sea by 52North.
the class GmlDecoderv321 method parseCompositeSurfaceType.
private Geometry parseCompositeSurfaceType(CompositeSurfaceType xbCompositeSurface) throws DecodingException {
SurfacePropertyType[] xbCurfaceProperties = xbCompositeSurface.getSurfaceMemberArray();
int srid = -1;
ArrayList<Polygon> polygons = new ArrayList<>(xbCurfaceProperties.length);
if (xbCompositeSurface.getSrsName() != null) {
srid = CRSHelper.parseSrsName(xbCompositeSurface.getSrsName());
}
for (SurfacePropertyType xbSurfaceProperty : xbCurfaceProperties) {
AbstractSurfaceType xbAbstractSurface = xbSurfaceProperty.getAbstractSurface();
if (srid == -1 && xbAbstractSurface.getSrsName() != null) {
srid = CRSHelper.parseSrsName(xbAbstractSurface.getSrsName());
}
if (xbAbstractSurface instanceof PolygonType) {
polygons.add((Polygon) parsePolygonType((PolygonType) xbAbstractSurface));
} else {
throw new DecodingException("The FeatureType %s is not supportted! Only PolygonType", xbAbstractSurface);
}
}
if (polygons.isEmpty()) {
throw new DecodingException("The FeatureType: %s does not contain any member!", xbCompositeSurface);
}
srid = setDefaultForUnsetSrid(srid);
GeometryFactory factory = new GeometryFactory();
Geometry geom = factory.createMultiPolygon(polygons.toArray(new Polygon[polygons.size()]));
geom.setSRID(srid);
return geom;
}
Aggregations