Commit fcd48bc1 authored by Matthias Betz's avatar Matthias Betz
Browse files

Merge branch 'dev'

parents 7ebb95c1 fcafb694
Pipeline #7620 passed with stage
in 54 seconds
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId>
<version>3.13.0</version>
<version>3.13.1</version>
</parent>
<artifactId>CityDoctorCheckResult</artifactId>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
......
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId>
<version>3.13.0</version>
<version>3.13.1</version>
</parent>
<artifactId>CityDoctorEdge</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
......@@ -29,7 +27,6 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
......
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId>
<version>3.13.0</version>
<version>3.13.1</version>
</parent>
<properties>
<versionString>${project.version}-${git.commit.id.abbrev}</versionString>
</properties>
<artifactId>CityDoctorModel</artifactId>
<name>CityDoctorModel</name>
<dependencies>
......@@ -60,7 +59,6 @@
<artifactId>proj4j</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
......
......@@ -30,7 +30,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.AbstractBuilding;
import de.hft.stuttgart.citydoctor2.datastructure.BoundarySurface;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeObject;
import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.BuildingInstallation;
import de.hft.stuttgart.citydoctor2.datastructure.Installation;
import de.hft.stuttgart.citydoctor2.datastructure.BuildingPart;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
......@@ -211,7 +211,7 @@ public abstract class Check {
*
* @param bi a building installation
*/
public void check(BuildingInstallation bi) {
public void check(Installation bi) {
}
......
......@@ -51,7 +51,7 @@ public abstract class AbstractBuilding extends CityObject {
private static final Logger logger = LogManager.getLogger(AbstractBuilding.class);
private List<BuildingInstallation> buildingInstallations = new ArrayList<>(2);
private List<Installation> buildingInstallations = new ArrayList<>(2);
private List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
private org.citygml4j.core.model.building.AbstractBuilding ab;
......@@ -89,7 +89,7 @@ public abstract class AbstractBuilding extends CityObject {
for (BoundarySurface bs : boundarySurfaceList) {
bs.unsetGmlGeometries();
}
for (BuildingInstallation bi : buildingInstallations) {
for (Installation bi : buildingInstallations) {
bi.unsetGmlGeometries();
}
}
......@@ -108,7 +108,7 @@ public abstract class AbstractBuilding extends CityObject {
for (BoundarySurface bs : boundarySurfaceList) {
reCreateBoundarySurface(factory, config, bs);
}
for (BuildingInstallation bi : buildingInstallations) {
for (Installation bi : buildingInstallations) {
bi.reCreateGeometries(factory, config);
}
}
......@@ -174,7 +174,7 @@ public abstract class AbstractBuilding extends CityObject {
if (c.canExecute(this)) {
c.check(this);
}
for (BuildingInstallation bi : buildingInstallations) {
for (Installation bi : buildingInstallations) {
bi.accept(c);
}
for (BoundarySurface bs : boundarySurfaceList) {
......@@ -185,7 +185,7 @@ public abstract class AbstractBuilding extends CityObject {
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (BuildingInstallation bi : buildingInstallations) {
for (Installation bi : buildingInstallations) {
bi.collectContainedErrors(errors);
}
for (BoundarySurface bs : boundarySurfaceList) {
......@@ -196,7 +196,7 @@ public abstract class AbstractBuilding extends CityObject {
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (BuildingInstallation bi : buildingInstallations) {
for (Installation bi : buildingInstallations) {
bi.clearAllContainedCheckResults();
}
for (BoundarySurface bs : boundarySurfaceList) {
......@@ -210,7 +210,7 @@ public abstract class AbstractBuilding extends CityObject {
if (hasError) {
return true;
}
for (BuildingInstallation bi : buildingInstallations) {
for (Installation bi : buildingInstallations) {
if (bi.containsError(checkIdentifier)) {
return true;
}
......@@ -229,7 +229,7 @@ public abstract class AbstractBuilding extends CityObject {
if (hasError) {
return true;
}
for (BuildingInstallation bi : buildingInstallations) {
for (Installation bi : buildingInstallations) {
if (bi.containsAnyError()) {
return true;
}
......@@ -251,7 +251,7 @@ public abstract class AbstractBuilding extends CityObject {
bs.setParent(this);
}
public void addBuildingInstallation(BuildingInstallation coBi) {
public void addBuildingInstallation(Installation coBi) {
buildingInstallations.add(coBi);
coBi.setParent(this);
}
......@@ -260,14 +260,14 @@ public abstract class AbstractBuilding extends CityObject {
this.ab = ab;
}
public List<BuildingInstallation> getBuildingInstallations() {
public List<Installation> getBuildingInstallations() {
return buildingInstallations;
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (BuildingInstallation bi : buildingInstallations) {
for (Installation bi : buildingInstallations) {
bi.prepareForChecking();
}
for (BoundarySurface bs : boundarySurfaceList) {
......@@ -278,7 +278,7 @@ public abstract class AbstractBuilding extends CityObject {
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (BuildingInstallation bi : buildingInstallations) {
for (Installation bi : buildingInstallations) {
bi.clearMetaInformation();
}
for (BoundarySurface bs : boundarySurfaceList) {
......@@ -300,7 +300,7 @@ public abstract class AbstractBuilding extends CityObject {
for (BoundarySurface originalBs : originalAb.boundarySurfaceList) {
boundarySurfaceList.add(handler.getCopyInstance(originalBs));
}
for (BuildingInstallation originalBi : originalAb.buildingInstallations) {
for (Installation originalBi : originalAb.buildingInstallations) {
buildingInstallations.add(handler.getCopyInstance(originalBi));
}
ab = originalAb.ab;
......
......@@ -18,6 +18,12 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.util.ArrayList;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.model.deprecated.bridge.DeprecatedPropertiesOfBridgeConstructiveElement;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.GeometryProperty;
......@@ -27,17 +33,25 @@ import org.xmlobjects.gml.model.geometry.complexes.CompositeSurface;
import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
public class BridgeConstructiveElement extends CityObject {
private static final Logger logger = LogManager.getLogger(BridgeConstructiveElement.class);
private static final String CANNOT_ADD = "Cannot add ";
private static final long serialVersionUID = 7353233899458901155L;
private org.citygml4j.core.model.bridge.BridgeConstructiveElement gmlBridgeElement;
private List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
public BridgeConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement gmlObject) {
this.gmlBridgeElement = gmlObject;
......@@ -69,6 +83,78 @@ public class BridgeConstructiveElement extends CityObject {
break;
}
}
for (BoundarySurface bs : boundarySurfaceList) {
reCreateBoundarySurface(factory, config, bs);
}
}
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.accept(c);
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (BoundarySurface bs : boundarySurfaceList) {
bs.collectContainedErrors(errors);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearAllContainedCheckResults();
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.containsAnyError()) {
return true;
}
}
return false;
}
private void reCreateBoundarySurface(GeometryFactory factory, ParserConfiguration config, BoundarySurface bs) {
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : gmlBridgeElement.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from BridgeConstructiveElement", bs.getGmlId());
gmlBridgeElement.getBoundaries().remove(bsp);
break;
}
}
return;
}
bs.reCreateGeometries(factory, config);
}
private void setCompositeSurfaceAccordingToLod(Geometry geom, CompositeSurface cs) {
......@@ -149,6 +235,9 @@ public class BridgeConstructiveElement extends CityObject {
gmlBridgeElement.setLod1Solid(null);
gmlBridgeElement.setLod2Solid(null);
gmlBridgeElement.setLod3Solid(null);
for (BoundarySurface bs : boundarySurfaceList) {
bs.unsetGmlGeometries();
}
}
@Override
......@@ -156,4 +245,44 @@ public class BridgeConstructiveElement extends CityObject {
return FeatureType.BRIDGE_CONSTRUCTION_ELEMENT;
}
public void addBoundarySurface(BoundarySurface bs) {
boundarySurfaceList.add(bs);
bs.setParent(this);
}
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaceList;
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (BoundarySurface bs : boundarySurfaceList) {
bs.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(boundarySurfaceList);
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
BridgeConstructiveElement originalBce = (BridgeConstructiveElement) original;
for (BoundarySurface originalBs : originalBce.boundarySurfaceList) {
boundarySurfaceList.add(handler.getCopyInstance(originalBs));
}
}
}
......@@ -22,6 +22,9 @@ import java.util.ArrayList;
import java.util.List;
import org.citygml4j.core.model.bridge.AbstractBridge;
import org.citygml4j.core.model.bridge.BridgeInstallation;
import org.citygml4j.core.model.bridge.BridgeInstallationProperty;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
......@@ -54,9 +57,10 @@ public class BridgeObject extends CityObject {
private BridgeType type;
private List<BridgeObject> parts = null;
private List<BridgeConstructiveElement> elements = null;
private List<BoundarySurface> boundarySurfaces = new ArrayList<>(2);
private List<Installation> bridgeInstallations = new ArrayList<>(2);
public BridgeObject(BridgeType type, AbstractBridge ab) {
this.ab = ab;
......@@ -74,6 +78,10 @@ public class BridgeObject extends CityObject {
}
return elements;
}
public List<Installation> getBridgeInstallations() {
return bridgeInstallations;
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
......@@ -89,6 +97,9 @@ public class BridgeObject extends CityObject {
for (BoundarySurface bs : boundarySurfaces) {
bs.reCreateGeometries(factory, config);
}
for (Installation bi : bridgeInstallations) {
bi.reCreateGeometries(factory, config);
}
if (parts != null) {
for (BridgeObject part : parts) {
part.reCreateGeometries(factory, config);
......@@ -138,6 +149,11 @@ public class BridgeObject extends CityObject {
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to bridges");
}
}
public void addBridgeInstallation(Installation coBi) {
bridgeInstallations.add(coBi);
coBi.setParent(this);
}
@Override
public void clearAllContainedCheckResults() {
......@@ -145,6 +161,9 @@ public class BridgeObject extends CityObject {
for (BoundarySurface bs : boundarySurfaces) {
bs.clearAllContainedCheckResults();
}
for (Installation bi : bridgeInstallations) {
bi.clearAllContainedCheckResults();
}
if (parts != null) {
for (BridgeObject part : parts) {
part.clearAllContainedCheckResults();
......@@ -163,6 +182,9 @@ public class BridgeObject extends CityObject {
for (BoundarySurface bs : boundarySurfaces) {
bs.collectContainedErrors(errors);
}
for (Installation bi : bridgeInstallations) {
bi.collectContainedErrors(errors);
}
if (parts != null) {
for (BridgeObject part : parts) {
part.collectContainedErrors(errors);
......@@ -181,6 +203,11 @@ public class BridgeObject extends CityObject {
if (hasError) {
return true;
}
for (Installation bi : bridgeInstallations) {
if (bi.containsAnyError()) {
return true;
}
}
for (BoundarySurface bs : boundarySurfaces) {
if (bs.containsAnyError()) {
return true;
......@@ -216,6 +243,11 @@ public class BridgeObject extends CityObject {
if (hasError) {
return true;
}
for (Installation bi : bridgeInstallations) {
if (bi.containsError(checkIdentifier)) {
return true;
}
}
for (BoundarySurface bs : boundarySurfaces) {
if (bs.containsError(checkIdentifier)) {
return true;
......@@ -254,6 +286,9 @@ public class BridgeObject extends CityObject {
for (BoundarySurface bs : boundarySurfaces) {
bs.accept(c);
}
for (Installation bi : bridgeInstallations) {
bi.accept(c);
}
if (parts != null) {
for (BridgeObject part : parts) {
part.accept(c);
......@@ -307,6 +342,9 @@ public class BridgeObject extends CityObject {
for (BoundarySurface bs : boundarySurfaces) {
bs.unsetGmlGeometries();
}
for (Installation bi : bridgeInstallations) {
bi.unsetGmlGeometries();
}
if (parts != null) {
for (BridgeObject part : parts) {
part.unsetGmlGeometries();
......@@ -331,9 +369,22 @@ public class BridgeObject extends CityObject {
@Override
public void prepareForChecking() {
super.prepareForChecking();
if (elements != null) {
for (BridgeConstructiveElement e : elements) {
e.prepareForChecking();
}
}
if (parts != null) {
for (BridgeObject part : parts) {
part.prepareForChecking();
}
}
for (BoundarySurface bs : boundarySurfaces) {
bs.prepareForChecking();
}
for (Installation bi : bridgeInstallations) {
bi.prepareForChecking();
}
}
@Override
......@@ -342,6 +393,9 @@ public class BridgeObject extends CityObject {
for (BoundarySurface bs : boundarySurfaces) {
bs.clearMetaInformation();
}
for (Installation bi : bridgeInstallations) {
bi.clearMetaInformation();
}
if (parts != null) {
for (BridgeObject part : parts) {
part.clearMetaInformation();
......@@ -360,6 +414,9 @@ public class BridgeObject extends CityObject {
for (BoundarySurface bs : boundarySurfaces) {
handler.addInstance(bs);
}
for (Installation bi : bridgeInstallations) {
handler.addInstance(bi);
}
if (parts != null) {
for (BridgeObject part : parts) {
handler.addInstance(part);
......@@ -372,6 +429,24 @@ public class BridgeObject extends CityObject {
}
}
public void anonymize() {
for (Geometry geom : getGeometries()) {
geom.anonymize();
}
org.citygml4j.core.model.bridge.Bridge gmlB = new org.citygml4j.core.model.bridge.Bridge();
gmlB.setId(GmlId.generateId().getGmlString());
for (Installation bi : getBridgeInstallations()) {
bi.anonymize();
gmlB.getBridgeInstallations().add(new BridgeInstallationProperty((BridgeInstallation) bi.getGmlObject()));
}
for (BoundarySurface bs : getBoundarySurfaces()) {
bs.anonymize();
gmlB.addBoundary(new AbstractSpaceBoundaryProperty(bs.getGmlObject()));
}
this.ab = gmlB;
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
......@@ -379,14 +454,17 @@ public class BridgeObject extends CityObject {
for (BoundarySurface originalBs : originalBo.boundarySurfaces) {
boundarySurfaces.add(handler.getCopyInstance(originalBs));
}
if (parts != null) {
for (BridgeObject part : parts) {
handler.addInstance(part);
for (Installation originalBi : originalBo.bridgeInstallations) {
bridgeInstallations.add(handler.getCopyInstance(originalBi));
}
if (originalBo.parts != null) {
for (BridgeObject part : originalBo.parts) {
getParts().add(handler.getCopyInstance(part));
}
}
if (elements != null) {
for (BridgeConstructiveElement ele : elements) {
handler.addInstance(ele);
if (originalBo.elements != null) {
for (BridgeConstructiveElement ele : originalBo.elements) {
getConstructiveElements().add(handler.getCopyInstance(ele));
}
}
}
......
......@@ -21,6 +21,7 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import java.util.ArrayList;
import java.util.List;
import org.citygml4j.core.model.building.BuildingInstallation;
import org.citygml4j.core.model.building.BuildingInstallationProperty;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.util.geometry.GeometryFactory;
......@@ -120,9 +121,9 @@ public class Building extends AbstractBuilding {
}
org.citygml4j.core.model.building.Building gmlB = new org.citygml4j.core.model.building.Building();
gmlB.setId(GmlId.generateId().getGmlString());
for (BuildingInstallation bi : getBuildingInstallations()) {
for (Installation bi : getBuildingInstallations()) {
bi.anonymize();
gmlB.getBuildingInstallations().add(new BuildingInstallationProperty(bi.getGmlObject()));
gmlB.getBuildingInstallations().add(new BuildingInstallationProperty((BuildingInstallation) bi.getGmlObject()));
}
for (BoundarySurface bs : getBoundarySurfaces()) {
bs.anonymize();
......
......@@ -333,7 +333,7 @@ public class CityDoctorModel {
if (index == -1) {
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in land objects");
}
land.set(index, (LandObject) nextFeature);
land.set(index, nextFeature);
}
private void replaceVegetation(CityObject currentFeature, CityObject nextFeature) {
......
......@@ -46,7 +46,7 @@ public class ConcretePolygon extends Polygon {
private LinearRing exterior;
private List<LinearRing> innerRings;
private BoundarySurface partOfSurface;
private BuildingInstallation partfOfInstallation;
private Installation partfOfInstallation;
private Geometry parent;
private LinkedPolygon linkedFromPolygon;
......@@ -335,7 +335,7 @@ public class ConcretePolygon extends Polygon {
* hft.stuttgart.citydoctor2.datastructure.BuildingInstallation)
*/
@Override
public void setPartOfInstallation(BuildingInstallation bi) {
public void setPartOfInstallation(Installation bi) {
partfOfInstallation = bi;
}
......@@ -346,7 +346,7 @@ public class ConcretePolygon extends Polygon {
* de.hft.stuttgart.citydoctor2.datastructure.Polygon#getPartOfInstallation()
*/
@Override
public BuildingInstallation getPartOfInstallation() {
public Installation getPartOfInstallation() {
return partfOfInstallation;
}
......
......@@ -26,7 +26,7 @@ package de.hft.stuttgart.citydoctor2.datastructure;
*/
public enum FeatureType {
BUILDING, TRANSPORTATION, VEGETATION, BRIDGE, LAND, WATER, BOUNDARY_SURFACE, BUILDING_INSTALLATION, OPENING,
BUILDING_PART, BRIDGE_CONSTRUCTION_ELEMENT;
BUILDING, TRANSPORTATION, VEGETATION, BRIDGE, LAND, WATER, BOUNDARY_SURFACE, INSTALLATION, OPENING,
BUILDING_PART, BRIDGE_CONSTRUCTION_ELEMENT, BRIDGE_INSTALLATION;
}
......@@ -97,10 +97,10 @@ public class Geometry extends GmlElement {
// set part of boundary surface or building installation or both
if (parent instanceof BoundarySurface bs) {
cdPoly.setPartOfSurface(bs);
if (bs.getParent() instanceof BuildingInstallation bi) {
if (bs.getParent() instanceof Installation bi) {
cdPoly.setPartOfInstallation(bi);
}
} else if (parent instanceof BuildingInstallation bi) {
} else if (parent instanceof Installation bi) {
cdPoly.setPartOfInstallation(bi);
}
}
......
......@@ -21,6 +21,8 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import java.util.ArrayList;
import java.util.List;
import org.citygml4j.core.model.bridge.BridgeInstallation;
import org.citygml4j.core.model.construction.AbstractInstallation;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.GeometryProperty;
......@@ -37,15 +39,15 @@ import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
public class BuildingInstallation extends CityObject {
public class Installation extends CityObject {
private static final long serialVersionUID = 1576237433322680191L;
private List<BoundarySurface> boundarySurfaces = new ArrayList<>(4);
private org.citygml4j.core.model.building.BuildingInstallation gmlBi;
private AbstractInstallation gmlBi;
private AbstractBuilding parent;
private CityObject parent;
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
......@@ -69,16 +71,41 @@ public class BuildingInstallation extends CityObject {
}
private void setGeometryAccordingToLod(Lod lod, GeometryProperty<?> ms) {
if (gmlBi instanceof org.citygml4j.core.model.building.BuildingInstallation localBi) {
addGeometryToBuildingInstallation(lod, ms, localBi);
} else if (gmlBi instanceof BridgeInstallation localBi) {
addGeometryToBridgeInstallation(lod, ms, localBi);
}
}
private void addGeometryToBuildingInstallation(Lod lod, GeometryProperty<?> ms,
org.citygml4j.core.model.building.BuildingInstallation localBi) {
switch (lod) {
case LOD2:
gmlBi.getDeprecatedProperties().setLod2Geometry(ms);
localBi.getDeprecatedProperties().setLod2Geometry(ms);
break;
case LOD3:
gmlBi.getDeprecatedProperties().setLod3Geometry(ms);
localBi.getDeprecatedProperties().setLod3Geometry(ms);
break;
case LOD4:
gmlBi.getDeprecatedProperties().setLod4Geometry(ms);
localBi.getDeprecatedProperties().setLod4Geometry(ms);
break;
default:
throw new IllegalStateException("Found geometry with LOD other than LOD2,"
+ " LOD3, LOD4, which is illegal for BuildingInstallations: " + lod);
}
}
private void addGeometryToBridgeInstallation(Lod lod, GeometryProperty<?> ms, BridgeInstallation localBi) {
switch (lod) {
case LOD2:
localBi.getDeprecatedProperties().setLod2Geometry(ms);
break;
case LOD3:
localBi.getDeprecatedProperties().setLod3Geometry(ms);
break;
case LOD4:
localBi.getDeprecatedProperties().setLod4Geometry(ms);
break;
default:
throw new IllegalStateException("Found geometry with LOD other than LOD2,"
......@@ -141,11 +168,11 @@ public class BuildingInstallation extends CityObject {
return false;
}
public void setParent(AbstractBuilding parent) {
public void setParent(CityObject parent) {
this.parent = parent;
}
public AbstractBuilding getParent() {
public CityObject getParent() {
return parent;
}
......@@ -155,15 +182,25 @@ public class BuildingInstallation extends CityObject {
}
public void unsetGmlGeometries() {
gmlBi.getDeprecatedProperties().setLod2Geometry(null);
gmlBi.getDeprecatedProperties().setLod3Geometry(null);
gmlBi.getDeprecatedProperties().setLod4Geometry(null);
if (gmlBi instanceof org.citygml4j.core.model.building.BuildingInstallation localBi) {
localBi.getDeprecatedProperties().setLod2Geometry(null);
localBi.getDeprecatedProperties().setLod3Geometry(null);
localBi.getDeprecatedProperties().setLod4Geometry(null);
} else if (gmlBi instanceof BridgeInstallation localBi) {
removeGeometriesFromBridgeInstallation(localBi);
}
for (BoundarySurface bs : boundarySurfaces) {
bs.unsetGmlGeometries();
}
}
public void setGmlObject(org.citygml4j.core.model.building.BuildingInstallation gmlBi) {
private void removeGeometriesFromBridgeInstallation(BridgeInstallation localBi) {
localBi.getDeprecatedProperties().setLod2Geometry(null);
localBi.getDeprecatedProperties().setLod3Geometry(null);
localBi.getDeprecatedProperties().setLod4Geometry(null);
}
public void setGmlObject(AbstractInstallation gmlBi) {
this.gmlBi = gmlBi;
}
......@@ -184,13 +221,13 @@ public class BuildingInstallation extends CityObject {
@Override
public org.citygml4j.core.model.building.BuildingInstallation getGmlObject() {
public AbstractInstallation getGmlObject() {
return gmlBi;
}
@Override
public FeatureType getFeatureType() {
return FeatureType.BUILDING_INSTALLATION;
return FeatureType.INSTALLATION;
}
public List<BoundarySurface> getBoundarySurfaces() {
......@@ -219,7 +256,7 @@ public class BuildingInstallation extends CityObject {
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
BuildingInstallation originalBi = (BuildingInstallation) original;
Installation originalBi = (Installation) original;
for (BoundarySurface originalBs : originalBi.boundarySurfaces) {
boundarySurfaces.add(handler.getCopyInstance(originalBs));
}
......@@ -238,7 +275,7 @@ public class BuildingInstallation extends CityObject {
@Override
public Copyable createCopyInstance() {
return new BuildingInstallation();
return new Installation();
}
}
......@@ -213,12 +213,12 @@ public class LinkedPolygon extends Polygon {
}
@Override
public void setPartOfInstallation(BuildingInstallation bi) {
public void setPartOfInstallation(Installation bi) {
poly.setPartOfInstallation(bi);
}
@Override
public BuildingInstallation getPartOfInstallation() {
public Installation getPartOfInstallation() {
return poly.getPartOfInstallation();
}
......
......@@ -60,9 +60,9 @@ public abstract class Polygon extends GmlElement {
public abstract void removeInnerRing(LinearRing ring);
public abstract void setPartOfInstallation(BuildingInstallation bi);
public abstract void setPartOfInstallation(Installation bi);
public abstract BuildingInstallation getPartOfInstallation();
public abstract Installation getPartOfInstallation();
public abstract boolean hasPointAsCorner(Vertex v);
......
......@@ -64,7 +64,7 @@ public class WaterObject extends CityObject {
}
}
}
/**
* Getter for all boundary surfaces contained in this building.
*
......@@ -73,7 +73,7 @@ public class WaterObject extends CityObject {
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaceList;
}
public void addBoundarySurface(BoundarySurface bs) {
boundarySurfaceList.add(bs);
bs.setParent(this);
......@@ -90,6 +90,9 @@ public class WaterObject extends CityObject {
if (c.canExecute(this)) {
c.check(this);
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.accept(c);
}
}
@Override
......@@ -120,7 +123,48 @@ public class WaterObject extends CityObject {
@Override
public void fillValues(Copyable original, CopyHandler handler) {
WaterObject wo = (WaterObject) original;
WaterObject originalWaterObject = (WaterObject) original;
for (BoundarySurface originalBs : originalWaterObject.boundarySurfaceList) {
boundarySurfaceList.add(handler.getCopyInstance(originalBs));
}
gmlWater = wo.gmlWater;
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.containsAnyError()) {
return true;
}
}
return false;
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(boundarySurfaceList);
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearMetaInformation();
}
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (BoundarySurface bs : boundarySurfaceList) {
bs.prepareForChecking();
}
}
}
......@@ -30,6 +30,8 @@ import org.citygml4j.core.model.CityGMLVersion;
import org.citygml4j.core.model.bridge.AbstractBridge;
import org.citygml4j.core.model.bridge.Bridge;
import org.citygml4j.core.model.bridge.BridgeConstructiveElementProperty;
import org.citygml4j.core.model.bridge.BridgeInstallation;
import org.citygml4j.core.model.bridge.BridgeInstallationProperty;
import org.citygml4j.core.model.bridge.BridgePart;
import org.citygml4j.core.model.bridge.BridgePartProperty;
import org.citygml4j.core.model.building.BuildingInstallationProperty;
......@@ -83,7 +85,6 @@ import de.hft.stuttgart.citydoctor2.datastructure.BridgeConstructiveElement;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeObject;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeObject.BridgeType;
import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.BuildingInstallation;
import de.hft.stuttgart.citydoctor2.datastructure.BuildingPart;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
......@@ -92,6 +93,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.GmlElement;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.Installation;
import de.hft.stuttgart.citydoctor2.datastructure.LandObject;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.LinkedPolygon;
......@@ -256,6 +258,15 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
for (BridgeConstructiveElement ele : bo.getConstructiveElements()) {
updateEdgesAndVertices(ele);
for (BoundarySurface bs : ele.getBoundarySurfaces()) {
updateEdgesAndVertices(bs);
}
}
for (Installation bi : bo.getBridgeInstallations()) {
updateEdgesAndVertices(bi);
for (BoundarySurface bs : bi.getBoundarySurfaces()) {
updateEdgesAndVertices(bs);
}
}
model.addBridge(bo);
}
......@@ -272,6 +283,16 @@ public class Citygml3FeatureMapper extends ObjectWalker {
bo.addConstructiveElement(cdEle);
}
List<BridgeInstallationProperty> bridgeInstallations = ab.getBridgeInstallations();
for (BridgeInstallationProperty installationProp : bridgeInstallations) {
var gmlBi = installationProp.getObject();
if (gmlBi == null) {
// ignore empty properties
continue;
}
Installation bi = mapBridgeInstallation(gmlBi);
bo.addBridgeInstallation(bi);
}
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : ab.getBoundaries()) {
......@@ -290,6 +311,44 @@ public class Citygml3FeatureMapper extends ObjectWalker {
bo.unsetGmlGeometries();
}
private Installation mapBridgeInstallation(BridgeInstallation gmlBi) {
Installation bi = new Installation();
bi.setGmlObject(gmlBi);
mapAbstractOccupiedSpace(gmlBi, bi);
GeometryProperty<?> lod2Prop = gmlBi.getDeprecatedProperties().getLod2Geometry();
parseAndAddAbstractGeometry(lod2Prop, Lod.LOD2, bi);
GeometryProperty<?> lod3Prop = gmlBi.getDeprecatedProperties().getLod3Geometry();
parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, bi);
GeometryProperty<?> lod4Prop = gmlBi.getDeprecatedProperties().getLod4Geometry();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi);
bi.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
bi.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
p.setPartOfInstallation(bi);
}
}
}
for (Geometry geom : bi.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfInstallation(bi);
}
}
return bi;
}
private void updatePartOfSurface(BridgeObject bo, SurfaceMapper surfaceMapper) {
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
bo.addBoundarySurface(bs);
......@@ -303,6 +362,18 @@ public class Citygml3FeatureMapper extends ObjectWalker {
private void mapConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement ele, BridgeConstructiveElement bce) {
mapAbstractConstructiveElement(ele, bce);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : ele.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
bce.addBoundarySurface(bs);
}
}
private void mapAbstractConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement ele, BridgeConstructiveElement bce) {
......@@ -486,7 +557,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
LinkedPolygon lPoly = new LinkedPolygon(concPoly, geom);
if (geom.getParent() instanceof BoundarySurface bs) {
lPoly.setPartOfSurface(bs);
if (bs.getParent() instanceof BuildingInstallation bi) {
if (bs.getParent() instanceof Installation bi) {
lPoly.setPartOfInstallation(bi);
}
}
......@@ -516,7 +587,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
// ignore empty properties
continue;
}
BuildingInstallation bi = mapBuildingInstallation(gmlBi);
Installation bi = mapBuildingInstallation(gmlBi);
cdBuilding.addBuildingInstallation(bi);
}
......@@ -536,7 +607,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
updateEdgesAndVertices(bs);
}
for (BuildingInstallation bi : cdBuilding.getBuildingInstallations()) {
for (Installation bi : cdBuilding.getBuildingInstallations()) {
updateEdgesAndVertices(bi);
for (BoundarySurface bs : bi.getBoundarySurfaces()) {
updateEdgesAndVertices(bs);
......@@ -562,8 +633,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
private BuildingInstallation mapBuildingInstallation(org.citygml4j.core.model.building.BuildingInstallation gmlBi) {
BuildingInstallation bi = new BuildingInstallation();
private Installation mapBuildingInstallation(org.citygml4j.core.model.building.BuildingInstallation gmlBi) {
Installation bi = new Installation();
bi.setGmlObject(gmlBi);
mapAbstractOccupiedSpace(gmlBi, bi);
GeometryProperty<?> lod2Prop = gmlBi.getDeprecatedProperties().getLod2Geometry();
......
......@@ -21,6 +21,7 @@ package de.hft.stuttgart.citydoctor2.writer;
import java.io.File;
import java.time.ZonedDateTime;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
......@@ -93,6 +94,17 @@ public class CityGMLWriterUtils {
storeCityObjects(model.getWater(), gmlFactory, model, cModel, val);
writer.write(cModel);
cModel.getCityObjectMembers().clear();
if (model.isValidated()) {
// remove validation plan again to not re-add it on recurring save
Iterator<AbstractFeatureProperty> it = cModel.getFeatureMembers().iterator();
while (it.hasNext()) {
AbstractFeatureProperty afp = it.next();
if (afp.getObject() == val || afp.getObject() == model.getValidationPlan()) {
it.remove();
}
}
}
} catch (CityGMLWriteException e) {
throw new CityDoctorWriteException(e);
}
......
......@@ -55,5 +55,4 @@ public class AttributeInvalidErrorTest {
assertEquals("attr", adeErr.getAttributeName());
}
}
......@@ -57,8 +57,8 @@ public class AbstractBuildingTest {
public void testAccept() {
AbstractBuilding ab = createAbstractBuilding();
ab.addBoundarySurface(new BoundarySurface(null));
ab.addBuildingInstallation(new BuildingInstallation());
ab.addBuildingInstallation(new BuildingInstallation());
ab.addBuildingInstallation(new Installation());
ab.addBuildingInstallation(new Installation());
AtomicInteger abCounter = new AtomicInteger(0);
AtomicInteger bsCounter = new AtomicInteger(0);
AtomicInteger biCounter = new AtomicInteger(0);
......@@ -82,7 +82,7 @@ public class AbstractBuildingTest {
AbstractCheck c2 = new AbstractCheck() {
@Override
public void check(BuildingInstallation bi) {
public void check(Installation bi) {
biCounter.incrementAndGet();
}
};
......@@ -92,7 +92,7 @@ public class AbstractBuildingTest {
@Test
public void testPrepareForChecking() {
BuildingInstallation biMock = mock(BuildingInstallation.class);
Installation biMock = mock(Installation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = createAbstractBuilding();
......@@ -105,7 +105,7 @@ public class AbstractBuildingTest {
@Test
public void testClearMetaInformation() {
BuildingInstallation biMock = mock(BuildingInstallation.class);
Installation biMock = mock(Installation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = createAbstractBuilding();
......@@ -137,7 +137,7 @@ public class AbstractBuildingTest {
@Test
public void testContainsErrorInBi() {
AbstractBuilding ab = createAbstractBuilding();
BuildingInstallation biMock = mock(BuildingInstallation.class);
Installation biMock = mock(Installation.class);
ab.addBuildingInstallation(biMock);
assertFalse(ab.containsError(CheckId.C_GE_P_HOLE_OUTSIDE));
Mockito.when(biMock.containsError(CheckId.C_GE_P_HOLE_OUTSIDE)).thenReturn(true);
......@@ -146,7 +146,7 @@ public class AbstractBuildingTest {
@Test
public void testClearAllContainedCheckResults() {
BuildingInstallation biMock = mock(BuildingInstallation.class);
Installation biMock = mock(Installation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = createAbstractBuilding();
......@@ -185,7 +185,7 @@ public class AbstractBuildingTest {
@Test
public void testContainsAnyErrorInBi() {
AbstractBuilding ab = createAbstractBuilding();
BuildingInstallation biMock = mock(BuildingInstallation.class);
Installation biMock = mock(Installation.class);
ab.addBuildingInstallation(biMock);
assertFalse(ab.containsAnyError());
Mockito.when(biMock.containsAnyError()).thenReturn(true);
......@@ -194,7 +194,7 @@ public class AbstractBuildingTest {
@Test
public void testCollectContainedErrors() {
BuildingInstallation biMock = mock(BuildingInstallation.class);
Installation biMock = mock(Installation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = createAbstractBuilding();
......@@ -291,7 +291,7 @@ public class AbstractBuildingTest {
@Test
public void testReCreateGeometriesEmptyBi() {
BuildingInstallation biMock = mock(BuildingInstallation.class);
Installation biMock = mock(Installation.class);
AbstractBuilding ab = createAbstractBuilding();
ab.addBuildingInstallation(biMock);
GeometryFactory factory = GeometryFactory.newInstance();
......@@ -304,7 +304,7 @@ public class AbstractBuildingTest {
@Test
public void testUnsetGmlGeometries() {
BuildingInstallation biMock = mock(BuildingInstallation.class);
Installation biMock = mock(Installation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = createAbstractBuilding();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment