From c593ccaf36a0637ef0cbc2acd1592a9af5169635 Mon Sep 17 00:00:00 2001
From: Matthias Betz <matthias.betz@hft-stuttgart.de>
Date: Fri, 29 Jan 2021 09:28:35 +0100
Subject: [PATCH] Release 3.7.0 fixed writing composite surface in building
 installations

---
 CityDoctorParent/CityDoctorCheckResult/pom.xml    |  2 +-
 CityDoctorParent/CityDoctorEdge/pom.xml           |  2 +-
 CityDoctorParent/CityDoctorModel/pom.xml          |  2 +-
 .../datastructure/BuildingInstallation.java       | 10 ++++++++--
 .../stuttgart/citydoctor2/utils/CityGmlUtils.java | 15 +++++++++++++++
 CityDoctorParent/CityDoctorValidation/pom.xml     |  2 +-
 CityDoctorParent/pom.xml                          |  4 ++--
 7 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/CityDoctorParent/CityDoctorCheckResult/pom.xml b/CityDoctorParent/CityDoctorCheckResult/pom.xml
index ae4395b..3ba2f10 100644
--- a/CityDoctorParent/CityDoctorCheckResult/pom.xml
+++ b/CityDoctorParent/CityDoctorCheckResult/pom.xml
@@ -5,7 +5,7 @@
 	<parent>
 		<groupId>de.hft.stuttgart</groupId>
 		<artifactId>CityDoctorParent</artifactId>
-		<version>3.7.0-SNAPSHOT</version>
+		<version>3.7.0</version>
 	</parent>
 
 	<artifactId>CityDoctorCheckResult</artifactId>
diff --git a/CityDoctorParent/CityDoctorEdge/pom.xml b/CityDoctorParent/CityDoctorEdge/pom.xml
index 309405e..d674595 100644
--- a/CityDoctorParent/CityDoctorEdge/pom.xml
+++ b/CityDoctorParent/CityDoctorEdge/pom.xml
@@ -5,7 +5,7 @@
 	<parent>
 		<groupId>de.hft.stuttgart</groupId>
 		<artifactId>CityDoctorParent</artifactId>
-		<version>3.7.0-SNAPSHOT</version>
+		<version>3.7.0</version>
 	</parent>
 	<artifactId>CityDoctorEdge</artifactId>
 
diff --git a/CityDoctorParent/CityDoctorModel/pom.xml b/CityDoctorParent/CityDoctorModel/pom.xml
index 6aba765..0fd0fc9 100644
--- a/CityDoctorParent/CityDoctorModel/pom.xml
+++ b/CityDoctorParent/CityDoctorModel/pom.xml
@@ -5,7 +5,7 @@
 	<parent>
 		<groupId>de.hft.stuttgart</groupId>
 		<artifactId>CityDoctorParent</artifactId>
-		<version>3.7.0-SNAPSHOT</version>
+		<version>3.7.0</version>
 	</parent>
 
 	<properties>
diff --git a/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/BuildingInstallation.java b/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/BuildingInstallation.java
index 031c2ac..4952285 100644
--- a/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/BuildingInstallation.java
+++ b/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/BuildingInstallation.java
@@ -24,8 +24,11 @@ import java.util.List;
 import org.citygml4j.factory.GMLGeometryFactory;
 import org.citygml4j.model.citygml.building.AbstractBoundarySurface;
 import org.citygml4j.model.citygml.building.BoundarySurfaceProperty;
+import org.citygml4j.model.gml.geometry.GeometryProperty;
 import org.citygml4j.model.gml.geometry.aggregates.MultiSurface;
 import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty;
+import org.citygml4j.model.gml.geometry.complexes.CompositeSurface;
+import org.citygml4j.model.gml.geometry.complexes.CompositeSurfaceProperty;
 
 import de.hft.stuttgart.citydoctor2.check.Check;
 import de.hft.stuttgart.citydoctor2.check.CheckError;
@@ -48,8 +51,11 @@ public class BuildingInstallation extends CityObject {
 			if (geom.getType() == GeometryType.MULTI_SURFACE) {
 				MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
 				setGeometryAccordingToLod(geom.getLod(), new MultiSurfaceProperty(ms));
+			} else if (geom.getType() == GeometryType.COMPOSITE_SURFACE) {
+				CompositeSurface cs = CityGmlUtils.createCompositeSurface(geom, factory, config);
+				setGeometryAccordingToLod(geom.getLod(), new CompositeSurfaceProperty(cs));
 			} else {
-				throw new IllegalStateException("BuildingInstallation can only have MultiSurface geometries");
+				throw new IllegalStateException("BuildingInstallation not have Solid geometries");
 			}
 		}
 		for (BoundarySurface bs : boundarySurfaces) {
@@ -62,7 +68,7 @@ public class BuildingInstallation extends CityObject {
 		throw new UnsupportedOperationException("Cannot copy BuildingInstallation");
 	}
 	
-	private void setGeometryAccordingToLod(Lod lod, MultiSurfaceProperty ms) {
+	private void setGeometryAccordingToLod(Lod lod, GeometryProperty<?> ms) {
 		switch (lod) {
 		case LOD2:
 			gmlBi.setLod2Geometry(ms);
diff --git a/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/CityGmlUtils.java b/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/CityGmlUtils.java
index f861e43..c33e600 100644
--- a/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/CityGmlUtils.java
+++ b/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/CityGmlUtils.java
@@ -176,4 +176,19 @@ public final class CityGmlUtils {
 		return new MultiSurface(surfaces);
 	}
 
+	public static CompositeSurface createCompositeSurface(Geometry geom, GMLGeometryFactory factory,
+			ParserConfiguration config) {
+		List<AbstractSurface> surfaces = new ArrayList<>();
+		for (Polygon cdPoly : geom.getPolygons()) {
+			org.citygml4j.model.gml.geometry.primitives.Polygon gmlPoly = createGmlPolygon(factory, cdPoly, config);
+			if (gmlPoly != null) {
+				surfaces.add(gmlPoly);
+			}
+		}
+		if (surfaces.isEmpty()) {
+			return null;
+		}
+		return new CompositeSurface(surfaces);
+	}
+
 }
diff --git a/CityDoctorParent/CityDoctorValidation/pom.xml b/CityDoctorParent/CityDoctorValidation/pom.xml
index f9c22c3..b6bc3f1 100644
--- a/CityDoctorParent/CityDoctorValidation/pom.xml
+++ b/CityDoctorParent/CityDoctorValidation/pom.xml
@@ -5,7 +5,7 @@
 	<parent>
 		<groupId>de.hft.stuttgart</groupId>
 		<artifactId>CityDoctorParent</artifactId>
-		<version>3.7.0-SNAPSHOT</version>
+		<version>3.7.0</version>
 	</parent>
 	<artifactId>CityDoctorValidation</artifactId>
 	<name>CityDoctorValidation</name>
diff --git a/CityDoctorParent/pom.xml b/CityDoctorParent/pom.xml
index 8cca78d..7ac74eb 100644
--- a/CityDoctorParent/pom.xml
+++ b/CityDoctorParent/pom.xml
@@ -4,7 +4,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>de.hft.stuttgart</groupId>
 	<artifactId>CityDoctorParent</artifactId>
-	<version>3.7.0-SNAPSHOT</version>
+	<version>3.7.0</version>
 	<packaging>pom</packaging>
 	<name>CityDoctorParent</name>
 
@@ -12,7 +12,7 @@
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<maven.compiler.source>1.8</maven.compiler.source>
 		<maven.compiler.target>1.8</maven.compiler.target>
-		<revision>3.7.0-SNAPSHOT</revision>
+		<revision>${project.version}</revision>
 	</properties>
 
 	<build>
-- 
GitLab