Commit 0f3d9a85 authored by Riegel's avatar Riegel
Browse files

Merge branch 'dev' into 'master'

CityDoctor Release Version 3.16.0

See merge request !11
2 merge requests!12Synchronize Dev branch with Master,!11CityDoctor Release Version 3.16.0
Pipeline #10323 passed with stage
in 1 minute and 25 seconds
Showing with 3380 additions and 1480 deletions
+3380 -1480
...@@ -5,6 +5,43 @@ All notable changes to this project will be documented in this file. ...@@ -5,6 +5,43 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Upcoming - [3.16.0]
CityDoctor now supports the import, export and validation of CityGML 3.0 files.
#### CityGML Object parsing
- CityDoctor is now capable of parsing and validating the following CityGML objects:
- Tunnel, TunnelParts, TunnelHollows and TunnelInstallations
- BuildingRooms, BuildingFurniture, BuildingStoreys and BuildingUnits
- BridgeRooms and BridgeFurniture
- CityFurniture
- GenericCityObjects
- CityDoctor now supports ImplicitGeometries and CompositeSurfaces.
- Data from CityDoctor's internal model will now be exported to the same CityGML version as
the input file, rather than always exporting it to CityGML 2.0.
#### CityDoctorGUI
- Featuretabs for Tunnel, CityFurniture and other CityObjects were added.
- QoL improvements:
- Added a north arrow to the mesh view.
- The camera of the mesh view can now be dragged by holding the right mouse button.
- Added a button which resets the camera view back to the initial state.
- Added a button to toggle hiding of roof BoundarySurfaces in the mesh view.
- Feature-tabs will now be greyed out if they contain no objects.
- Added a view-tab for GenericAttributes
### Fixed
- Fixed a TreeNode text color bug, which showed unchecked objects as being already validated.
- Fixed an oversight in the CityGML version number parsing
## [3.15.0] (2024-09-03) ## [3.15.0] (2024-09-03)
......
...@@ -26,23 +26,7 @@ import java.util.Map; ...@@ -26,23 +26,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import de.hft.stuttgart.citydoctor2.check.error.DependenciesNotMetError; import de.hft.stuttgart.citydoctor2.check.error.DependenciesNotMetError;
import de.hft.stuttgart.citydoctor2.datastructure.AbstractBuilding; import de.hft.stuttgart.citydoctor2.datastructure.*;
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.Installation;
import de.hft.stuttgart.citydoctor2.datastructure.BuildingPart;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.LandObject;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.Opening;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.ReliefObject;
import de.hft.stuttgart.citydoctor2.datastructure.TinObject;
import de.hft.stuttgart.citydoctor2.datastructure.TransportationObject;
import de.hft.stuttgart.citydoctor2.datastructure.Vegetation;
import de.hft.stuttgart.citydoctor2.datastructure.WaterObject;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
/** /**
...@@ -313,6 +297,14 @@ public abstract class Check { ...@@ -313,6 +297,14 @@ public abstract class Check {
} }
public void check(CityFurniture cf){
}
public void check(GenericCityObject gco) {
}
/** /**
* The initialization method of this check. It will be called before any check * The initialization method of this check. It will be called before any check
* method will be executed. Override this if you want to have configurable * method will be executed. Override this if you want to have configurable
......
/*- /*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
* *
* This file is part of CityDoctor2. * This file is part of CityDoctor2.
* *
* CityDoctor2 is free software: you can redistribute it and/or modify * CityDoctor2 is free software: you can redistribute it and/or modify
...@@ -18,10 +18,13 @@ ...@@ -18,10 +18,13 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial; import de.hft.stuttgart.citydoctor2.check.Check;
import java.util.ArrayList; import de.hft.stuttgart.citydoctor2.check.CheckError;
import java.util.List; 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;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty; import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
...@@ -31,281 +34,456 @@ import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty; ...@@ -31,281 +34,456 @@ import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.primitives.Solid; import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty; import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import de.hft.stuttgart.citydoctor2.check.Check; import java.io.Serial;
import de.hft.stuttgart.citydoctor2.check.CheckError; import java.util.ArrayList;
import de.hft.stuttgart.citydoctor2.check.CheckId; import java.util.List;
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;
/** /**
* Container for attributes of an abstract building. It can be a Building or * Container for attributes of an abstract building. It can be a Building or
* BuildingPart. * BuildingPart.
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public abstract class AbstractBuilding extends CityObject { public abstract class AbstractBuilding extends CityObject {
@Serial @Serial
private static final long serialVersionUID = -2196414503088741206L; private static final long serialVersionUID = -2196414503088741206L;
private static final Logger logger = LogManager.getLogger(AbstractBuilding.class); private static final Logger logger = LogManager.getLogger(AbstractBuilding.class);
private final List<Installation> buildingInstallations = new ArrayList<>(2); private final List<Installation> buildingInstallations = new ArrayList<>(2);
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>(); private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
private final List<BuildingRoom> buildingRooms = new ArrayList<>();
private org.citygml4j.core.model.building.AbstractBuilding ab; private final List<Storey> buildingStoreys = new ArrayList<>();
private final List<BuildingUnit> buildingUnits = new ArrayList<>();
/** private final List<BuildingRoomFurniture> buildingRoomFurnitureList = new ArrayList<>();
* Getter for all boundary surfaces contained in this building. private org.citygml4j.core.model.building.AbstractBuilding ab;
*
* @return the boundary surfaces /**
*/ * Getter for all boundary surfaces contained in this building.
public List<BoundarySurface> getBoundarySurfaces() { *
return boundarySurfaceList; * @return the boundary surfaces
} */
public List<BoundarySurface> getBoundarySurfaces() {
@Override return boundarySurfaceList;
public org.citygml4j.core.model.building.AbstractBuilding getGmlObject() { }
return ab;
} @Override
public org.citygml4j.core.model.building.AbstractBuilding getGmlObject() {
@Override return ab;
public FeatureType getFeatureType() { }
return FeatureType.BUILDING;
} @Override
public FeatureType getFeatureType() {
@Override return FeatureType.BUILDING;
public void unsetGmlGeometries() { }
ab.setLod1Solid(null);
ab.setLod2Solid(null); @Override
ab.setLod3Solid(null); public void unsetGmlGeometries() {
ab.setLod2MultiSurface(null); ab.setLod1Solid(null);
ab.setLod3MultiSurface(null); ab.setLod2Solid(null);
ab.getDeprecatedProperties().setLod1MultiSurface(null); ab.setLod3Solid(null);
ab.getDeprecatedProperties().setLod4MultiSurface(null); ab.setLod2MultiSurface(null);
ab.getDeprecatedProperties().setLod4Solid(null); ab.setLod3MultiSurface(null);
ab.getDeprecatedProperties().setLod1MultiSurface(null);
for (BoundarySurface bs : boundarySurfaceList) { ab.getDeprecatedProperties().setLod4MultiSurface(null);
bs.unsetGmlGeometries(); ab.getDeprecatedProperties().setLod4Solid(null);
}
for (Installation bi : buildingInstallations) { for (BoundarySurface bs : boundarySurfaceList) {
bi.unsetGmlGeometries(); bs.unsetGmlGeometries();
} }
} for (Installation bi : buildingInstallations) {
bi.unsetGmlGeometries();
@Override }
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { for (BuildingRoom br : buildingRooms) {
for (Geometry geom : getGeometries()) { br.unsetGmlGeometries();
if (geom.getType() == GeometryType.MULTI_SURFACE) { }
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config); for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
setMultiSurfaceAccordingToLod(geom, ms); bfr.unsetGmlGeometries();
} else { }
Solid solid = CityGmlUtils.createSolid(geom, factory, config); for (Storey storey : buildingStoreys) {
setSolidAccordingToLod(geom, solid); storey.unsetGmlGeometries();
} }
} for (BuildingUnit bu : buildingUnits) {
for (BoundarySurface bs : boundarySurfaceList) { bu.unsetGmlGeometries();
reCreateBoundarySurface(factory, config, bs); }
} }
for (Installation bi : buildingInstallations) {
bi.reCreateGeometries(factory, config); @Override
} public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
} for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
private void reCreateBoundarySurface(GeometryFactory factory, ParserConfiguration config, BoundarySurface bs) { continue;
if (bs.getGeometries().isEmpty()) { }
for (AbstractSpaceBoundaryProperty bsp : ab.getBoundaries()) { if (geom.getType() == GeometryType.MULTI_SURFACE) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) { MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
logger.warn("Found empty boundary surface: {}, removing from building", bs.getGmlId()); setMultiSurfaceAccordingToLod(geom, ms);
ab.getBoundaries().remove(bsp); } else {
break; Solid solid = CityGmlUtils.createSolid(geom, factory, config);
} setSolidAccordingToLod(geom, solid);
} }
return; }
} for (BoundarySurface bs : boundarySurfaceList) {
bs.reCreateGeometries(factory, config); reCreateBoundarySurface(factory, config, bs);
} }
for (Installation bi : buildingInstallations) {
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) { bi.reCreateGeometries(factory, config);
switch (geom.getLod()) { }
case LOD0: for (BuildingRoom br : buildingRooms) {
ab.setLod0MultiSurface(new MultiSurfaceProperty(ms)); br.reCreateGeometries(factory, config);
break; }
case LOD1: for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
ab.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms)); bfr.reCreateGeometries(factory, config);
break; }
case LOD2: for (Storey storey : buildingStoreys) {
ab.setLod2MultiSurface(new MultiSurfaceProperty(ms)); storey.reCreateGeometries(factory, config);
break; }
case LOD3: for (BuildingUnit bu : buildingUnits) {
ab.setLod3MultiSurface(new MultiSurfaceProperty(ms)); bu.reCreateGeometries(factory, config);
break; }
case LOD4: }
ab.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break; private void reCreateBoundarySurface(GeometryFactory factory, ParserConfiguration config, BoundarySurface bs) {
default: if (bs.getGeometries().isEmpty()) {
throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to buildings"); for (AbstractSpaceBoundaryProperty bsp : ab.getBoundaries()) {
} if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
} logger.warn("Found empty boundary surface: {}, removing from building", bs.getGmlId());
ab.getBoundaries().remove(bsp);
private void setSolidAccordingToLod(Geometry geom, Solid solid) { break;
switch (geom.getLod()) { }
case LOD1: }
ab.setLod1Solid(new SolidProperty(solid)); return;
break; }
case LOD2: bs.reCreateGeometries(factory, config);
ab.setLod2Solid(new SolidProperty(solid)); }
break;
case LOD3: private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
ab.setLod3Solid(new SolidProperty(solid)); switch (geom.getLod()) {
break; case LOD0:
case LOD4: ab.setLod0MultiSurface(new MultiSurfaceProperty(ms));
ab.getDeprecatedProperties().setLod4Solid(new SolidProperty(solid)); break;
break; case LOD1:
default: ab.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to buildings"); break;
} case LOD2:
} ab.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
@Override case LOD3:
public void accept(Check c) { ab.setLod3MultiSurface(new MultiSurfaceProperty(ms));
super.accept(c); break;
if (c.canExecute(this)) { case LOD4:
c.check(this); ab.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
} break;
for (Installation bi : buildingInstallations) { default:
bi.accept(c); throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to buildings");
} }
for (BoundarySurface bs : boundarySurfaceList) { }
bs.accept(c);
} private void setSolidAccordingToLod(Geometry geom, Solid solid) {
} switch (geom.getLod()) {
case LOD1:
@Override ab.setLod1Solid(new SolidProperty(solid));
public void collectContainedErrors(List<CheckError> errors) { break;
super.collectContainedErrors(errors); case LOD2:
for (Installation bi : buildingInstallations) { ab.setLod2Solid(new SolidProperty(solid));
bi.collectContainedErrors(errors); break;
} case LOD3:
for (BoundarySurface bs : boundarySurfaceList) { ab.setLod3Solid(new SolidProperty(solid));
bs.collectContainedErrors(errors); break;
} case LOD4:
} ab.getDeprecatedProperties().setLod4Solid(new SolidProperty(solid));
break;
@Override default:
public void clearAllContainedCheckResults() { throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to buildings");
super.clearAllContainedCheckResults(); }
for (Installation bi : buildingInstallations) { }
bi.clearAllContainedCheckResults();
} @Override
for (BoundarySurface bs : boundarySurfaceList) { public void accept(Check c) {
bs.clearAllContainedCheckResults(); super.accept(c);
} if (c.canExecute(this)) {
} c.check(this);
}
@Override for (Installation bi : buildingInstallations) {
public boolean containsError(CheckId checkIdentifier) { bi.accept(c);
boolean hasError = super.containsError(checkIdentifier); }
if (hasError) { for (BoundarySurface bs : boundarySurfaceList) {
return true; bs.accept(c);
} }
for (Installation bi : buildingInstallations) { for (BuildingRoom br : buildingRooms) {
if (bi.containsError(checkIdentifier)) { br.accept(c);
return true; }
} for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
} bfr.accept(c);
for (BoundarySurface bs : boundarySurfaceList) { }
if (bs.containsError(checkIdentifier)) { for (Storey storey : buildingStoreys) {
return true; storey.accept(c);
} }
} for (BuildingUnit bu : buildingUnits) {
return false; bu.accept(c);
} }
}
@Override
public boolean containsAnyError() { @Override
boolean hasError = super.containsAnyError(); public void collectContainedErrors(List<CheckError> errors) {
if (hasError) { super.collectContainedErrors(errors);
return true; for (Installation bi : buildingInstallations) {
} bi.collectContainedErrors(errors);
for (Installation bi : buildingInstallations) { }
if (bi.containsAnyError()) { for (BoundarySurface bs : boundarySurfaceList) {
return true; bs.collectContainedErrors(errors);
} }
} for (BuildingRoom br : buildingRooms) {
for (BoundarySurface bs : boundarySurfaceList) { br.collectContainedErrors(errors);
if (bs.containsAnyError()) { }
return true; for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
} bfr.collectContainedErrors(errors);
} }
return false; for (Storey storey : buildingStoreys) {
} storey.collectContainedErrors(errors);
}
void setCityGmlBuilding(org.citygml4j.core.model.building.AbstractBuilding ab) { for (BuildingUnit bu : buildingUnits) {
this.ab = ab; bu.collectContainedErrors(errors);
} }
}
public void addBoundarySurface(BoundarySurface bs) {
boundarySurfaceList.add(bs); @Override
bs.setParent(this); public void clearAllContainedCheckResults() {
} super.clearAllContainedCheckResults();
for (Installation bi : buildingInstallations) {
public void addBuildingInstallation(Installation coBi) { bi.clearAllContainedCheckResults();
buildingInstallations.add(coBi); }
coBi.setParent(this); for (BoundarySurface bs : boundarySurfaceList) {
} bs.clearAllContainedCheckResults();
}
public void setGmlObject(org.citygml4j.core.model.building.AbstractBuilding ab) { for (BuildingRoom br : buildingRooms) {
this.ab = ab; br.clearAllContainedCheckResults();
} }
for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
public List<Installation> getBuildingInstallations() { bfr.clearAllContainedCheckResults();
return buildingInstallations; }
} for (Storey storey : buildingStoreys) {
storey.clearAllContainedCheckResults();
@Override }
public void prepareForChecking() { for (BuildingUnit bu : buildingUnits) {
super.prepareForChecking(); bu.clearAllContainedCheckResults();
for (Installation bi : buildingInstallations) { }
bi.prepareForChecking(); }
}
for (BoundarySurface bs : boundarySurfaceList) { @Override
bs.prepareForChecking(); public boolean containsError(CheckId checkIdentifier) {
} boolean hasError = super.containsError(checkIdentifier);
} if (hasError) {
return true;
@Override }
public void clearMetaInformation() { for (Installation bi : buildingInstallations) {
super.clearMetaInformation(); if (bi.containsError(checkIdentifier)) {
for (Installation bi : buildingInstallations) { return true;
bi.clearMetaInformation(); }
} }
for (BoundarySurface bs : boundarySurfaceList) { for (BoundarySurface bs : boundarySurfaceList) {
bs.clearMetaInformation(); if (bs.containsError(checkIdentifier)) {
} return true;
} }
}
@Override for (BuildingRoom br : buildingRooms) {
public void collectInstances(CopyHandler handler) { if (br.containsError(checkIdentifier)) {
super.collectInstances(handler); return true;
handler.addInstance(boundarySurfaceList); }
handler.addInstance(buildingInstallations); }
} for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
if (bfr.containsError(checkIdentifier)) {
@Override return true;
public void fillValues(Copyable original, CopyHandler handler) { }
super.fillValues(original, handler); }
AbstractBuilding originalAb = (AbstractBuilding) original; for (Storey storey : buildingStoreys) {
for (BoundarySurface originalBs : originalAb.boundarySurfaceList) { if (storey.containsError(checkIdentifier)) {
boundarySurfaceList.add(handler.getCopyInstance(originalBs)); return true;
} }
for (Installation originalBi : originalAb.buildingInstallations) { }
buildingInstallations.add(handler.getCopyInstance(originalBi)); for (BuildingUnit bu : buildingUnits) {
} if (bu.containsError(checkIdentifier)) {
ab = originalAb.ab; return true;
} }
}
return false;
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (Installation bi : buildingInstallations) {
if (bi.containsAnyError()) {
return true;
}
}
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.containsAnyError()) {
return true;
}
}
for (BuildingRoom br : buildingRooms) {
if (br.containsAnyError()) {
return true;
}
}
for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
if (bfr.containsAnyError()) {
return true;
}
}
for (Storey storey : buildingStoreys) {
if (storey.containsAnyError()) {
return true;
}
}
for (BuildingUnit bu : buildingUnits) {
if (bu.containsAnyError()) {
return true;
}
}
return false;
}
void setCityGmlBuilding(org.citygml4j.core.model.building.AbstractBuilding ab) {
this.ab = ab;
}
public void addBoundarySurface(BoundarySurface bs) {
boundarySurfaceList.add(bs);
bs.setParent(this);
}
public void addBuildingInstallation(Installation coBi) {
buildingInstallations.add(coBi);
coBi.setParent(this);
}
public void addBuildingRoom(BuildingRoom room) {
buildingRooms.add(room);
room.setParent(this);
}
public void addBuildingRoomFurniture(BuildingRoomFurniture roomFurniture) {
buildingRoomFurnitureList.add(roomFurniture);
roomFurniture.setParent(this);
}
public void addStorey(Storey storey) {
buildingStoreys.add(storey);
}
public void addBuildingUnit(BuildingUnit buildingUnit) {
buildingUnits.add(buildingUnit);
}
public void setGmlObject(org.citygml4j.core.model.building.AbstractBuilding ab) {
this.ab = ab;
}
public List<Installation> getBuildingInstallations() {
return buildingInstallations;
}
public List<BuildingRoom> getBuildingRooms() {
return buildingRooms;
}
public List<BuildingRoomFurniture> getBuildingRoomFurnitureList() {
return buildingRoomFurnitureList;
}
public List<Storey> getBuildingStoreys() {
return buildingStoreys;
}
public List<BuildingUnit> getBuildingUnits() {
return buildingUnits;
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (Installation bi : buildingInstallations) {
bi.prepareForChecking();
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.prepareForChecking();
}
for (BuildingRoom br : buildingRooms) {
br.prepareForChecking();
}
for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
bfr.prepareForChecking();
}
for (Storey storey : buildingStoreys) {
storey.prepareForChecking();
}
for (BuildingUnit bu : buildingUnits) {
bu.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (Installation bi : buildingInstallations) {
bi.clearMetaInformation();
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearMetaInformation();
}
for (BuildingRoom br : buildingRooms) {
br.clearMetaInformation();
}
for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
bfr.clearMetaInformation();
}
for (Storey storey : buildingStoreys) {
storey.clearMetaInformation();
}
for (BuildingUnit bu : buildingUnits) {
bu.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(boundarySurfaceList);
handler.addInstance(buildingInstallations);
handler.addInstance(buildingRooms);
handler.addInstance(buildingRoomFurnitureList);
handler.addInstance(buildingStoreys);
handler.addInstance(buildingUnits);
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
AbstractBuilding originalAb = (AbstractBuilding) original;
for (BoundarySurface originalBs : originalAb.boundarySurfaceList) {
boundarySurfaceList.add(handler.getCopyInstance(originalBs));
}
for (Installation originalBi : originalAb.buildingInstallations) {
buildingInstallations.add(handler.getCopyInstance(originalBi));
}
for (BuildingRoom originalBr : originalAb.buildingRooms) {
buildingRooms.add(handler.getCopyInstance(originalBr));
}
for (BuildingRoomFurniture originalBFR : originalAb.buildingRoomFurnitureList) {
buildingRoomFurnitureList.add(handler.getCopyInstance(originalBFR));
}
for (Storey originalBStoreys : originalAb.buildingStoreys) {
buildingStoreys.add(handler.getCopyInstance(originalBStoreys));
}
for (BuildingUnit originalBun : originalAb.buildingUnits) {
buildingUnits.add(handler.getCopyInstance(originalBun));
}
ab = originalAb.ab;
}
} }
package de.hft.stuttgart.citydoctor2.datastructure;
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;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
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;
import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public abstract class AbstractBuildingSubdivision extends CityObject {
@Serial
private static final long serialVersionUID = 7033994252340571002L;
private static final Logger logger = LogManager.getLogger(AbstractBuildingSubdivision.class);
private final List<Installation> buildingInstallations = new ArrayList<>(2);
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
private final List<BuildingRoom> buildingRooms = new ArrayList<>();
private final List<BuildingRoomFurniture> buildingRoomFurnitureList = new ArrayList<>();
protected org.citygml4j.core.model.building.AbstractBuildingSubdivision abs;
/**
* Getter for all boundary surfaces contained in this building.
*
* @return the boundary surfaces
*/
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaceList;
}
@Override
public org.citygml4j.core.model.building.AbstractBuildingSubdivision getGmlObject() {
return abs;
}
@Override
public FeatureType getFeatureType() {
return FeatureType.BUILDING_SUBDIVISION;
}
@Override
public void unsetGmlGeometries() {
abs.setLod1Solid(null);
abs.setLod2Solid(null);
abs.setLod3Solid(null);
abs.setLod2MultiSurface(null);
abs.setLod3MultiSurface(null);
for (BoundarySurface bs : boundarySurfaceList) {
bs.unsetGmlGeometries();
}
for (Installation bi : buildingInstallations) {
bi.unsetGmlGeometries();
}
for (BuildingRoom br : buildingRooms) {
br.unsetGmlGeometries();
}
for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
bfr.unsetGmlGeometries();
}
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms);
} else {
Solid solid = CityGmlUtils.createSolid(geom, factory, config);
setSolidAccordingToLod(geom, solid);
}
}
for (BoundarySurface bs : boundarySurfaceList) {
reCreateBoundarySurface(factory, config, bs);
}
for (Installation bi : buildingInstallations) {
bi.reCreateGeometries(factory, config);
}
for (BuildingRoom br : buildingRooms) {
br.reCreateGeometries(factory, config);
}
for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
bfr.reCreateGeometries(factory, config);
}
}
private void reCreateBoundarySurface(GeometryFactory factory, ParserConfiguration config, BoundarySurface bs) {
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : abs.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from building", bs.getGmlId());
abs.getBoundaries().remove(bsp);
break;
}
}
return;
}
bs.reCreateGeometries(factory, config);
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) {
case LOD0:
abs.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
abs.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
abs.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to buildings");
}
}
private void setSolidAccordingToLod(Geometry geom, Solid solid) {
switch (geom.getLod()) {
case LOD1:
abs.setLod1Solid(new SolidProperty(solid));
break;
case LOD2:
abs.setLod2Solid(new SolidProperty(solid));
break;
case LOD3:
abs.setLod3Solid(new SolidProperty(solid));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to buildings");
}
}
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (Installation bi : buildingInstallations) {
bi.accept(c);
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.accept(c);
}
for (BuildingRoom br : buildingRooms) {
br.accept(c);
}
for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
bfr.accept(c);
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (Installation bi : buildingInstallations) {
bi.collectContainedErrors(errors);
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.collectContainedErrors(errors);
}
for (BuildingRoom br : buildingRooms) {
br.collectContainedErrors(errors);
}
for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
bfr.collectContainedErrors(errors);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (Installation bi : buildingInstallations) {
bi.clearAllContainedCheckResults();
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearAllContainedCheckResults();
}
for (BuildingRoom br : buildingRooms) {
br.clearAllContainedCheckResults();
}
for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
bfr.clearAllContainedCheckResults();
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (Installation bi : buildingInstallations) {
if (bi.containsError(checkIdentifier)) {
return true;
}
}
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.containsError(checkIdentifier)) {
return true;
}
}
for (BuildingRoom br : buildingRooms) {
if (br.containsError(checkIdentifier)) {
return true;
}
}
for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
if (bfr.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (Installation bi : buildingInstallations) {
if (bi.containsAnyError()) {
return true;
}
}
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.containsAnyError()) {
return true;
}
}
for (BuildingRoom br : buildingRooms) {
if (br.containsAnyError()) {
return true;
}
}
for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
if (bfr.containsAnyError()) {
return true;
}
}
return false;
}
void setCityGmlBuilding(org.citygml4j.core.model.building.AbstractBuildingSubdivision abs) {
this.abs = abs;
}
public void addBoundarySurface(BoundarySurface bs) {
boundarySurfaceList.add(bs);
bs.setParent(this);
}
public void addBuildingInstallation(Installation coBi) {
buildingInstallations.add(coBi);
coBi.setParent(this);
}
public void addBuildingRoom(BuildingRoom room) {
buildingRooms.add(room);
room.setParent(this);
}
public void addBuildingRoomFurniture(BuildingRoomFurniture roomFurniture) {
buildingRoomFurnitureList.add(roomFurniture);
roomFurniture.setParent(this);
}
public void setGmlObject(org.citygml4j.core.model.building.AbstractBuildingSubdivision abs) {
this.abs = abs;
}
public List<Installation> getBuildingInstallations() {
return buildingInstallations;
}
public List<BuildingRoom> getBuildingRooms() {
return buildingRooms;
}
public List<BuildingRoomFurniture> getBuildingRoomFurnitureList() {
return buildingRoomFurnitureList;
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (Installation bi : buildingInstallations) {
bi.prepareForChecking();
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.prepareForChecking();
}
for (BuildingRoom br : buildingRooms) {
br.prepareForChecking();
}
for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
bfr.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (Installation bi : buildingInstallations) {
bi.clearMetaInformation();
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearMetaInformation();
}
for (BuildingRoom br : buildingRooms) {
br.clearMetaInformation();
}
for (BuildingRoomFurniture bfr : buildingRoomFurnitureList) {
bfr.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(boundarySurfaceList);
handler.addInstance(buildingInstallations);
handler.addInstance(buildingRooms);
handler.addInstance(buildingRoomFurnitureList);
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
AbstractBuildingSubdivision originalAbs = (AbstractBuildingSubdivision) original;
for (BoundarySurface originalBs : originalAbs.boundarySurfaceList) {
boundarySurfaceList.add(handler.getCopyInstance(originalBs));
}
for (Installation originalBi : originalAbs.buildingInstallations) {
buildingInstallations.add(handler.getCopyInstance(originalBi));
}
for (BuildingRoom originalBr : originalAbs.buildingRooms) {
buildingRooms.add(handler.getCopyInstance(originalBr));
}
for (BuildingRoomFurniture originalBFR : originalAbs.buildingRoomFurnitureList) {
buildingRoomFurnitureList.add(handler.getCopyInstance(originalBFR));
}
abs = originalAbs.abs;
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
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;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
/**
* Represents all types of furniture used inside Buildings.
*/
public abstract class AbstractFurniture extends CityObject {
@Serial
private static final long serialVersionUID = -9050689238027190674L;
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
private CityObject parent;
private org.citygml4j.core.model.construction.AbstractFurniture af;
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.accept(c);
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.collectContainedErrors(errors);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.clearAllContainedCheckResults();
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (BoundarySurface boundarySurface : boundarySurfaceList) {
if (boundarySurface.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (BoundarySurface boundarySurface : boundarySurfaceList) {
if (boundarySurface.containsAnyError()) {
return true;
}
}
return false;
}
@Override
public org.citygml4j.core.model.construction.AbstractFurniture getGmlObject() {
return af;
}
public void addBoundarySurface(BoundarySurface boundarySurface) {
boundarySurfaceList.add(boundarySurface);
boundarySurface.setParent(this);
}
public List<BoundarySurface> getBoundarySurfaceList() {
return boundarySurfaceList;
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms);
} else {
Solid solid = CityGmlUtils.createSolid(geom, factory, config);
setSolidAccordingToLod(geom, solid);
}
}
}
protected void setGmlObject(org.citygml4j.core.model.construction.AbstractFurniture af) {
this.af = af;
}
public void setParent(CityObject co) {
parent = co;
}
@Override
public void unsetGmlGeometries() {
af.setLod0MultiSurface(null);
af.setLod2MultiSurface(null);
af.setLod3MultiSurface(null);
af.setLod1Solid(null);
af.setLod2Solid(null);
af.setLod3Solid(null);
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) {
case LOD0:
af.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
af.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
af.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to buildings");
}
}
private void setSolidAccordingToLod(Geometry geom, Solid solid) {
switch (geom.getLod()) {
case LOD1:
af.setLod1Solid(new SolidProperty(solid));
break;
case LOD2:
af.setLod2Solid(new SolidProperty(solid));
break;
case LOD3:
af.setLod3Solid(new SolidProperty(solid));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to buildings");
}
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.clearMetaInformation();
}
}
@Override
public FeatureType getFeatureType() {
return FeatureType.FURNITURE;
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
AbstractFurniture originalAf = (AbstractFurniture) original;
af = originalAf.af;
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
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;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
/**
* Abstract base class for rooms inside CityGML 3.0 construction objects.
*/
public abstract class AbstractRoom extends CityObject {
@Serial
private static final long serialVersionUID = -1730625513988944329L;
private final List<Installation> roomInstallations = new ArrayList<>(2);
// Rooms have a Href list of furniture, the actual object is saved in the Building
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
protected org.citygml4j.core.model.core.AbstractUnoccupiedSpace cgmlRoom;
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (Installation roomInstallation : roomInstallations) {
roomInstallation.accept(c);
}
for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.accept(c);
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (Installation roomInstallation : roomInstallations) {
roomInstallation.collectContainedErrors(errors);
}
for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.collectContainedErrors(errors);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (Installation roomInstallation : roomInstallations) {
roomInstallation.clearAllContainedCheckResults();
}
for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.clearAllContainedCheckResults();
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (Installation roomInstallation : roomInstallations) {
if (roomInstallation.containsError(checkIdentifier)) {
return true;
}
}
for (BoundarySurface boundarySurface : boundarySurfaceList) {
if (boundarySurface.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (Installation roomInstallation : roomInstallations) {
if (roomInstallation.containsAnyError()) {
return true;
}
}
for (BoundarySurface boundarySurface : boundarySurfaceList) {
if (boundarySurface.containsAnyError()) {
return true;
}
}
return false;
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms);
} else {
Solid solid = CityGmlUtils.createSolid(geom, factory, config);
setSolidAccordingToLod(geom, solid);
}
}
for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.reCreateGeometries(factory, config);
}
for (Installation roomInstallation : roomInstallations) {
roomInstallation.reCreateGeometries(factory, config);
}
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) {
case LOD0:
cgmlRoom.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
cgmlRoom.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
cgmlRoom.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to rooms");
}
}
private void setSolidAccordingToLod(Geometry geom, Solid solid) {
switch (geom.getLod()) {
case LOD1:
cgmlRoom.setLod1Solid(new SolidProperty(solid));
break;
case LOD2:
cgmlRoom.setLod2Solid(new SolidProperty(solid));
break;
case LOD3:
cgmlRoom.setLod3Solid(new SolidProperty(solid));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to rooms");
}
}
@Override
public void unsetGmlGeometries() {
cgmlRoom.setLod0MultiSurface(null);
cgmlRoom.setLod2MultiSurface(null);
cgmlRoom.setLod3MultiSurface(null);
cgmlRoom.setLod1Solid(null);
cgmlRoom.setLod2Solid(null);
cgmlRoom.setLod3Solid(null);
for (Installation roomInstallation : roomInstallations) {
roomInstallation.unsetGmlGeometries();
}
for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.unsetGmlGeometries();
}
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (Installation roomInstallation : roomInstallations) {
roomInstallation.prepareForChecking();
}
for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (Installation roomInstallation : roomInstallations) {
roomInstallation.clearMetaInformation();
}
for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.clearMetaInformation();
}
}
@Override
public AbstractCityObject getGmlObject() {
return cgmlRoom;
}
public List<Installation> getRoomInstallations() {
return roomInstallations;
}
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaceList;
}
public void addRoomInstallation(Installation roomInstallation) {
roomInstallations.add(roomInstallation);
roomInstallation.setParent(this);
}
public void addBoundarySurface(BoundarySurface boundarySurface) {
boundarySurfaceList.add(boundarySurface);
boundarySurface.setParent(this);
}
@Override
public FeatureType getFeatureType() {
return FeatureType.ROOM;
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(roomInstallations);
handler.addInstance(boundarySurfaceList);
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
AbstractRoom originalAr = (AbstractRoom) original;
for (BoundarySurface originalBs : originalAr.boundarySurfaceList) {
boundarySurfaceList.add(handler.getCopyInstance(originalBs));
}
for (Installation originalRi : originalAr.roomInstallations) {
roomInstallations.add(handler.getCopyInstance(originalRi));
}
cgmlRoom = originalAr.cgmlRoom;
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
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;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
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;
import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public abstract class AbstractTunnel extends CityObject {
@Serial
private static final long serialVersionUID = -2196414503088741206L;
private static final Logger logger = LogManager.getLogger(AbstractTunnel.class);
private final List<Installation> tunnelInstallations = new ArrayList<>(2);
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
private final List<TunnelHollow> tunnelHollows = new ArrayList<>();
private final List<TunnelPart> tunnelParts = new ArrayList<>();
private final List<TunnelFurniture> tunnelFurnitureList = new ArrayList<>();
private final List<TunnelConstructiveElement> tunnelConstructiveElements = new ArrayList<>();
private org.citygml4j.core.model.tunnel.AbstractTunnel at;
/**
* Getter for all boundary surfaces contained in this building.
*
* @return the boundary surfaces
*/
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaceList;
}
@Override
public org.citygml4j.core.model.tunnel.AbstractTunnel getGmlObject() {
return at;
}
@Override
public FeatureType getFeatureType() {
return FeatureType.TUNNEL;
}
@Override
public void unsetGmlGeometries() {
at.setLod1Solid(null);
at.setLod2Solid(null);
at.setLod3Solid(null);
at.setLod2MultiSurface(null);
at.setLod3MultiSurface(null);
at.getDeprecatedProperties().setLod1MultiSurface(null);
at.getDeprecatedProperties().setLod4MultiSurface(null);
at.getDeprecatedProperties().setLod4Solid(null);
for (BoundarySurface bs : boundarySurfaceList) {
bs.unsetGmlGeometries();
}
for (Installation bi : tunnelInstallations) {
bi.unsetGmlGeometries();
}
for (TunnelHollow th : tunnelHollows) {
th.unsetGmlGeometries();
}
for (TunnelFurniture tfr : tunnelFurnitureList) {
tfr.unsetGmlGeometries();
}
for (TunnelConstructiveElement te : tunnelConstructiveElements) {
te.unsetGmlGeometries();
}
for (TunnelPart tp : tunnelParts) {
tp.unsetGmlGeometries();
}
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms);
} else {
Solid solid = CityGmlUtils.createSolid(geom, factory, config);
setSolidAccordingToLod(geom, solid);
}
}
for (BoundarySurface bs : boundarySurfaceList) {
reCreateBoundarySurface(factory, config, bs);
}
for (Installation bi : tunnelInstallations) {
bi.reCreateGeometries(factory, config);
}
for (TunnelHollow th : tunnelHollows) {
th.reCreateGeometries(factory, config);
}
for (TunnelFurniture tfr : tunnelFurnitureList) {
tfr.reCreateGeometries(factory, config);
}
for (TunnelConstructiveElement te : tunnelConstructiveElements) {
te.reCreateGeometries(factory, config);
}
for (TunnelPart tp : tunnelParts) {
tp.reCreateGeometries(factory, config);
}
}
private void reCreateBoundarySurface(GeometryFactory factory, ParserConfiguration config, BoundarySurface bs) {
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : at.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from building", bs.getGmlId());
at.getBoundaries().remove(bsp);
break;
}
}
return;
}
bs.reCreateGeometries(factory, config);
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) {
case LOD0:
at.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD1:
at.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
at.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
at.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
at.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to buildings");
}
}
private void setSolidAccordingToLod(Geometry geom, Solid solid) {
switch (geom.getLod()) {
case LOD1:
at.setLod1Solid(new SolidProperty(solid));
break;
case LOD2:
at.setLod2Solid(new SolidProperty(solid));
break;
case LOD3:
at.setLod3Solid(new SolidProperty(solid));
break;
case LOD4:
at.getDeprecatedProperties().setLod4Solid(new SolidProperty(solid));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to buildings");
}
}
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (Installation bi : tunnelInstallations) {
bi.accept(c);
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.accept(c);
}
for (TunnelHollow th : tunnelHollows) {
th.accept(c);
}
for (TunnelFurniture tfr : tunnelFurnitureList) {
tfr.accept(c);
}
for (TunnelConstructiveElement te : tunnelConstructiveElements) {
te.accept(c);
}
for (TunnelPart tp : tunnelParts) {
tp.accept(c);
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (Installation bi : tunnelInstallations) {
bi.collectContainedErrors(errors);
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.collectContainedErrors(errors);
}
for (TunnelHollow th : tunnelHollows) {
th.collectContainedErrors(errors);
}
for (TunnelFurniture tfr : tunnelFurnitureList) {
tfr.collectContainedErrors(errors);
}
for (TunnelConstructiveElement te : tunnelConstructiveElements) {
te.collectContainedErrors(errors);
}
for (TunnelPart tp : tunnelParts) {
tp.collectContainedErrors(errors);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (Installation bi : tunnelInstallations) {
bi.clearAllContainedCheckResults();
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearAllContainedCheckResults();
}
for (TunnelHollow th : tunnelHollows) {
th.clearAllContainedCheckResults();
}
for (TunnelFurniture tfr : tunnelFurnitureList) {
tfr.clearAllContainedCheckResults();
}
for (TunnelConstructiveElement te : tunnelConstructiveElements) {
te.clearAllContainedCheckResults();
}
for (TunnelPart tp : tunnelParts) {
tp.clearAllContainedCheckResults();
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (Installation bi : tunnelInstallations) {
if (bi.containsError(checkIdentifier)) {
return true;
}
}
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.containsError(checkIdentifier)) {
return true;
}
}
for (TunnelHollow th : tunnelHollows) {
if (th.containsError(checkIdentifier)) {
return true;
}
}
for (TunnelFurniture tfr : tunnelFurnitureList) {
if (tfr.containsError(checkIdentifier)) {
return true;
}
}
for (TunnelConstructiveElement te : tunnelConstructiveElements) {
if (te.containsError(checkIdentifier)) {
return true;
}
}
for (TunnelPart tp : tunnelParts) {
if (tp.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (Installation bi : tunnelInstallations) {
if (bi.containsAnyError()) {
return true;
}
}
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.containsAnyError()) {
return true;
}
}
for (TunnelHollow th : tunnelHollows) {
if (th.containsAnyError()) {
return true;
}
}
for (TunnelFurniture tfr : tunnelFurnitureList) {
if (tfr.containsAnyError()) {
return true;
}
}
for (TunnelConstructiveElement te : tunnelConstructiveElements) {
if (te.containsAnyError()) {
return true;
}
}
for (TunnelPart tp : tunnelParts) {
if (tp.containsAnyError()) {
return true;
}
}
return false;
}
void setCityGmlBuilding(org.citygml4j.core.model.tunnel.AbstractTunnel at) {
this.at = at;
}
public void addBoundarySurface(BoundarySurface bs) {
boundarySurfaceList.add(bs);
bs.setParent(this);
}
public void addTunnelInstallation(Installation coBi) {
tunnelInstallations.add(coBi);
coBi.setParent(this);
}
public void addTunnelHollow(TunnelHollow hollow) {
tunnelHollows.add(hollow);
hollow.setParent(this);
}
public void addTunnelFurniture(TunnelFurniture furniture) {
tunnelFurnitureList.add(furniture);
furniture.setParent(this);
}
public void addTunnelConstructiveElement(TunnelConstructiveElement te) {
tunnelConstructiveElements.add(te);
}
public void addTunnelPart(TunnelPart tunnelPart) {
tunnelParts.add(tunnelPart);
}
public void setGmlObject(org.citygml4j.core.model.tunnel.AbstractTunnel at) {
this.at = at;
}
public List<Installation> getTunnelInstallations() {
return tunnelInstallations;
}
public List<TunnelHollow> getTunnelHollows() {
return tunnelHollows;
}
public List<TunnelFurniture> getTunnelFurnitureList() {
return tunnelFurnitureList;
}
public List<TunnelPart> getTunnelParts() {
return tunnelParts;
}
public List<TunnelConstructiveElement> getTunnelConstructiveElements() {
return tunnelConstructiveElements;
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (Installation bi : tunnelInstallations) {
bi.prepareForChecking();
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.prepareForChecking();
}
for (TunnelHollow th : tunnelHollows) {
th.prepareForChecking();
}
for (TunnelFurniture tfr : tunnelFurnitureList) {
tfr.prepareForChecking();
}
for (TunnelConstructiveElement te : tunnelConstructiveElements) {
te.prepareForChecking();
}
for (TunnelPart tp : tunnelParts) {
tp.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (Installation bi : tunnelInstallations) {
bi.clearMetaInformation();
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearMetaInformation();
}
for (TunnelHollow th : tunnelHollows) {
th.clearMetaInformation();
}
for (TunnelFurniture tfr : tunnelFurnitureList) {
tfr.clearMetaInformation();
}
for (TunnelConstructiveElement te : tunnelConstructiveElements) {
te.clearMetaInformation();
}
for (TunnelPart tp : tunnelParts) {
tp.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(boundarySurfaceList);
handler.addInstance(tunnelInstallations);
handler.addInstance(tunnelHollows);
handler.addInstance(tunnelFurnitureList);
handler.addInstance(tunnelConstructiveElements);
handler.addInstance(tunnelParts);
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
AbstractTunnel originalAt = (AbstractTunnel) original;
for (BoundarySurface originalBs : originalAt.boundarySurfaceList) {
boundarySurfaceList.add(handler.getCopyInstance(originalBs));
}
for (Installation originalTi : originalAt.tunnelInstallations) {
tunnelInstallations.add(handler.getCopyInstance(originalTi));
}
for (TunnelHollow originalTh : originalAt.tunnelHollows) {
tunnelHollows.add(handler.getCopyInstance(originalTh));
}
for (TunnelFurniture originalTFR : originalAt.tunnelFurnitureList) {
tunnelFurnitureList.add(handler.getCopyInstance(originalTFR));
}
for (TunnelConstructiveElement originalTE : originalAt.tunnelConstructiveElements) {
tunnelConstructiveElements.add(handler.getCopyInstance(originalTE));
}
for (TunnelPart originalTp : originalAt.tunnelParts) {
tunnelParts.add(handler.getCopyInstance(originalTp));
}
at = originalAt.at;
}
}
/*- /*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
* *
* This file is part of CityDoctor2. * This file is part of CityDoctor2.
* *
* CityDoctor2 is free software: you can redistribute it and/or modify * CityDoctor2 is free software: you can redistribute it and/or modify
...@@ -18,15 +18,6 @@ ...@@ -18,15 +18,6 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
import org.citygml4j.core.model.core.AbstractThematicSurface;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import de.hft.stuttgart.citydoctor2.check.Check; import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError; import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId; import de.hft.stuttgart.citydoctor2.check.CheckId;
...@@ -34,252 +25,262 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; ...@@ -34,252 +25,262 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils; import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler; import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable; import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.core.AbstractThematicSurface;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
/** /**
* Representing a boundary surface in CityGML * Representing a boundary surface in CityGML
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public class BoundarySurface extends CityObject { public class BoundarySurface extends CityObject {
@Serial @Serial
private static final long serialVersionUID = 8793865135393496408L; private static final long serialVersionUID = 8793865135393496408L;
private SurfaceFeatureType featureType; private SurfaceFeatureType featureType;
private BoundarySurfaceType type; private BoundarySurfaceType type;
private final List<Opening> openings = new ArrayList<>(2); private final List<Opening> openings = new ArrayList<>(2);
private CityObject parent; private CityObject parent;
private AbstractThematicSurface gmlObject; private AbstractThematicSurface gmlObject;
public BoundarySurface(AbstractThematicSurface aco) { public BoundarySurface(AbstractThematicSurface aco) {
this(SurfaceFeatureType.BUILDING, BoundarySurfaceType.UNDEFINED, aco); this(SurfaceFeatureType.BUILDING, BoundarySurfaceType.UNDEFINED, aco);
} }
public BoundarySurface(SurfaceFeatureType featureType, BoundarySurfaceType type, AbstractThematicSurface aco) { public BoundarySurface(SurfaceFeatureType featureType, BoundarySurfaceType type, AbstractThematicSurface aco) {
this.featureType = featureType; this.featureType = featureType;
this.type = type; this.type = type;
gmlObject = aco; gmlObject = aco;
} }
public void setFeatureType(SurfaceFeatureType featureType) { public void setFeatureType(SurfaceFeatureType featureType) {
this.featureType = featureType; this.featureType = featureType;
} }
public void setType(BoundarySurfaceType type) { public void setType(BoundarySurfaceType type) {
this.type = type; this.type = type;
} }
public void setGmlObject(AbstractThematicSurface gmlObject) { public void setGmlObject(AbstractThematicSurface gmlObject) {
this.gmlObject = gmlObject; this.gmlObject = gmlObject;
} }
public SurfaceFeatureType getSurfaceFeatureType() { public SurfaceFeatureType getSurfaceFeatureType() {
return featureType; return featureType;
} }
public BoundarySurfaceType getType() { public BoundarySurfaceType getType() {
return type; return type;
} }
public List<Opening> getOpenings() { public List<Opening> getOpenings() {
return openings; return openings;
} }
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
if (gmlObject.getId() == null) { if (gmlObject.getId() == null) {
gmlObject.setId(getGmlId().getGmlString()); gmlObject.setId(getGmlId().getGmlString());
} }
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom.getType() == GeometryType.MULTI_SURFACE) { if (geom instanceof ImplicitGeometryHolder) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config); continue;
if (ms != null) { }
setGeometryAccordingToLod(geom.getLod(), new MultiSurfaceProperty(ms)); if (geom.getType() == GeometryType.MULTI_SURFACE) {
} MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
} else { if (ms != null) {
throw new IllegalStateException("BoundarySurfaces can only have MultiSurface geometries"); setGeometryAccordingToLod(geom.getLod(), new MultiSurfaceProperty(ms));
} }
} } else {
for (Opening o : openings) { throw new IllegalStateException("BoundarySurfaces can only have MultiSurface geometries");
o.reCreateGeometries(factory, config); }
} }
} for (Opening o : openings) {
o.reCreateGeometries(factory, config);
private void setGeometryAccordingToLod(Lod lod, MultiSurfaceProperty ms) { }
switch (lod) { }
case LOD0:
gmlObject.setLod0MultiSurface(ms); private void setGeometryAccordingToLod(Lod lod, MultiSurfaceProperty ms) {
break; switch (lod) {
case LOD1: case LOD0:
gmlObject.setLod1MultiSurface(ms); gmlObject.setLod0MultiSurface(ms);
break; break;
case LOD2: case LOD1:
gmlObject.setLod2MultiSurface(ms); gmlObject.setLod1MultiSurface(ms);
break; break;
case LOD3: case LOD2:
gmlObject.setLod3MultiSurface(ms); gmlObject.setLod2MultiSurface(ms);
break; break;
case LOD4: case LOD3:
gmlObject.getDeprecatedProperties().setLod4MultiSurface(ms); gmlObject.setLod3MultiSurface(ms);
break; break;
default: case LOD4:
throw new IllegalStateException("Found geometry with LOD other than LOD1-4, which is illegal for BoundarySurfaces: " + lod); gmlObject.getDeprecatedProperties().setLod4MultiSurface(ms);
} break;
} default:
throw new IllegalStateException("Found geometry with LOD other than LOD1-4, which is illegal for BoundarySurfaces: " + lod);
@Override }
public void clearAllContainedCheckResults() { }
super.clearAllContainedCheckResults();
for (Opening o : openings) { @Override
o.clearAllContainedCheckResults(); public void clearAllContainedCheckResults() {
} super.clearAllContainedCheckResults();
} for (Opening o : openings) {
o.clearAllContainedCheckResults();
@Override }
public void collectContainedErrors(List<CheckError> errors) { }
super.collectContainedErrors(errors);
for (Opening o : openings) { @Override
o.collectContainedErrors(errors); public void collectContainedErrors(List<CheckError> errors) {
} super.collectContainedErrors(errors);
} for (Opening o : openings) {
o.collectContainedErrors(errors);
@Override }
public boolean containsAnyError() { }
boolean hasError = super.containsAnyError();
if (hasError) { @Override
return true; public boolean containsAnyError() {
} boolean hasError = super.containsAnyError();
for (Opening o : openings) { if (hasError) {
if (o.containsAnyError()) { return true;
return true; }
} for (Opening o : openings) {
} if (o.containsAnyError()) {
return false; return true;
} }
}
@Override return false;
public boolean containsError(CheckId checkIdentifier) { }
boolean hasError = super.containsError(checkIdentifier);
if (hasError) { @Override
return true; public boolean containsError(CheckId checkIdentifier) {
} boolean hasError = super.containsError(checkIdentifier);
for (Opening o : openings) { if (hasError) {
if (o.containsError(checkIdentifier)) { return true;
return true; }
} for (Opening o : openings) {
} if (o.containsError(checkIdentifier)) {
return false; return true;
} }
}
@Override return false;
public void accept(Check c) { }
super.accept(c);
if (c.canExecute(this)) { @Override
c.check(this); public void accept(Check c) {
} super.accept(c);
for (Opening o : openings) { if (c.canExecute(this)) {
o.accept(c); c.check(this);
} }
} for (Opening o : openings) {
o.accept(c);
public void setParent(CityObject parent) { }
this.parent = parent; }
}
public void setParent(CityObject parent) {
public CityObject getParent() { this.parent = parent;
return parent; }
}
public CityObject getParent() {
@Override return parent;
public void unsetGmlGeometries() { }
gmlObject.setLod0MultiSurface(null);
gmlObject.setLod1MultiSurface(null); @Override
gmlObject.setLod2MultiSurface(null); public void unsetGmlGeometries() {
gmlObject.setLod3MultiSurface(null); gmlObject.setLod0MultiSurface(null);
gmlObject.getDeprecatedProperties().setLod4MultiSurface(null); gmlObject.setLod1MultiSurface(null);
gmlObject.setLod2MultiSurface(null);
for (Opening o : openings) { gmlObject.setLod3MultiSurface(null);
o.unsetGmlGeometries(); gmlObject.getDeprecatedProperties().setLod4MultiSurface(null);
}
} for (Opening o : openings) {
o.unsetGmlGeometries();
@Override }
public String toString() { }
return "BoundarySurface [type=" + type + ", id=" + getGmlId() + "]";
} @Override
public String toString() {
void anonymize() { return "BoundarySurface [type=" + type + ", id=" + getGmlId() + "]";
gmlObject.setAppearances(null); }
gmlObject.setBoundedBy(null);
gmlObject.setCreationDate(null); void anonymize() {
gmlObject.setDescription(null); gmlObject.setAppearances(null);
gmlObject.setExternalReferences(null); gmlObject.setBoundedBy(null);
gmlObject.setGeneralizesTo(null); gmlObject.setCreationDate(null);
gmlObject.setADEProperties(null); gmlObject.setDescription(null);
gmlObject.setGenericAttributes(null); gmlObject.setExternalReferences(null);
setGmlId(GmlId.generateId()); gmlObject.setGeneralizesTo(null);
gmlObject.setId(getGmlId().getGmlString()); gmlObject.setADEProperties(null);
} gmlObject.setGenericAttributes(null);
setGmlId(GmlId.generateId());
@Override gmlObject.setId(getGmlId().getGmlString());
public AbstractThematicSurface getGmlObject() { }
return gmlObject;
} @Override
public AbstractThematicSurface getGmlObject() {
@Override return gmlObject;
public FeatureType getFeatureType() { }
return FeatureType.BOUNDARY_SURFACE;
} @Override
public FeatureType getFeatureType() {
public void addOpening(Opening opening) { return FeatureType.BOUNDARY_SURFACE;
openings.add(opening); }
opening.setPartOfSurface(this);
} public void addOpening(Opening opening) {
openings.add(opening);
@Override opening.setPartOfSurface(this);
public void prepareForChecking() { }
super.prepareForChecking();
for (Opening o : openings) { @Override
o.prepareForChecking(); public void prepareForChecking() {
} super.prepareForChecking();
} for (Opening o : openings) {
o.prepareForChecking();
@Override }
public void clearMetaInformation() { }
super.clearMetaInformation();
for (Opening o : openings) { @Override
o.clearMetaInformation(); public void clearMetaInformation() {
} super.clearMetaInformation();
} for (Opening o : openings) {
o.clearMetaInformation();
@Override }
public Copyable createCopyInstance() { }
return new BoundarySurface(gmlObject);
} @Override
public Copyable createCopyInstance() {
@Override return new BoundarySurface(gmlObject);
public void collectInstances(CopyHandler handler) { }
super.collectInstances(handler);
for (Opening o : openings) { @Override
handler.addInstance(o); public void collectInstances(CopyHandler handler) {
} super.collectInstances(handler);
handler.addInstance(parent); for (Opening o : openings) {
} handler.addInstance(o);
}
@Override handler.addInstance(parent);
public void fillValues(Copyable original, CopyHandler handler) { }
super.fillValues(original, handler);
BoundarySurface originalBs = (BoundarySurface) original; @Override
featureType = originalBs.featureType; public void fillValues(Copyable original, CopyHandler handler) {
type = originalBs.type; super.fillValues(original, handler);
for (Opening originalOpening : originalBs.openings) { BoundarySurface originalBs = (BoundarySurface) original;
openings.add(handler.getCopyInstance(originalOpening)); featureType = originalBs.featureType;
} type = originalBs.type;
parent = handler.getCopyInstance(originalBs.parent); for (Opening originalOpening : originalBs.openings) {
gmlObject = originalBs.gmlObject; openings.add(handler.getCopyInstance(originalOpening));
} }
parent = handler.getCopyInstance(originalBs.parent);
gmlObject = originalBs.gmlObject;
}
} }
/*- /*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
* *
* This file is part of CityDoctor2. * This file is part of CityDoctor2.
* *
* CityDoctor2 is free software: you can redistribute it and/or modify * CityDoctor2 is free software: you can redistribute it and/or modify
...@@ -20,12 +20,11 @@ package de.hft.stuttgart.citydoctor2.datastructure; ...@@ -20,12 +20,11 @@ package de.hft.stuttgart.citydoctor2.datastructure;
/** /**
* Types of boundary surfaces used in city doctor * Types of boundary surfaces used in city doctor
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public enum BoundarySurfaceType { public enum BoundarySurfaceType {
UNDEFINED, ROOF, WALL, GROUND, CLOSURE, OUTER_FLOOR, OUTER_CEILING, CEILING, INTERIOR_WALL, FLOOR UNDEFINED, ROOF, WALL, GROUND, CLOSURE, OUTER_FLOOR, OUTER_CEILING, CEILING, INTERIOR_WALL, FLOOR
} }
/*- /*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
* *
* This file is part of CityDoctor2. * This file is part of CityDoctor2.
* *
* CityDoctor2 is free software: you can redistribute it and/or modify * CityDoctor2 is free software: you can redistribute it and/or modify
...@@ -18,148 +18,147 @@ ...@@ -18,148 +18,147 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.util.Collection;
import java.util.List;
import de.hft.stuttgart.citydoctor2.math.Vector3d; import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.utils.BoundingBoxCalculator; import de.hft.stuttgart.citydoctor2.utils.BoundingBoxCalculator;
import java.util.Collection;
import java.util.List;
/** /**
* An axis aligned bounding box represented by its two corners * An axis aligned bounding box represented by its two corners
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public class BoundingBox { public class BoundingBox {
private final Vector3d[] bbox; private final Vector3d[] bbox;
/** /**
* Creates an axis aligned bounding box containing all points of all polygons * Creates an axis aligned bounding box containing all points of all polygons
* *
* @param polygons containing the points from which the box will be created * @param polygons containing the points from which the box will be created
* @return the bounding box around all points * @return the bounding box around all points
*/ */
public static BoundingBox of(Collection<? extends Polygon> polygons) { public static BoundingBox of(Collection<? extends Polygon> polygons) {
return BoundingBoxCalculator.calculateBoundingBox(polygons); return BoundingBoxCalculator.calculateBoundingBox(polygons);
} }
public static BoundingBox ofPoints(List<? extends Vector3d> points) { public static BoundingBox ofPoints(List<? extends Vector3d> points) {
return BoundingBoxCalculator.calculateBoundingBoxFromPoints(points); return BoundingBoxCalculator.calculateBoundingBoxFromPoints(points);
} }
/** /**
* Creates an axis aligned bounding box of the whole model. * Creates an axis aligned bounding box of the whole model.
* *
* @param model the model containing the features with geometries used for the * @param model the model containing the features with geometries used for the
* bounding box * bounding box
* @return the bounding box around all features * @return the bounding box around all features
*/ */
public static BoundingBox of(CityDoctorModel model) { public static BoundingBox of(CityDoctorModel model) {
return BoundingBoxCalculator.calculateBoundingBox(model); return BoundingBoxCalculator.calculateBoundingBox(model);
} }
/** /**
* Creates a new bounding box with two vectors as corner points. * Creates a new bounding box with two vectors as corner points.
* *
* @param box the array of length 2 containing both corners * @param box the array of length 2 containing both corners
* @return the new bounding box * @return the new bounding box
*/ */
public static BoundingBox of(Vector3d[] box) { public static BoundingBox of(Vector3d[] box) {
return new BoundingBox(box); return new BoundingBox(box);
} }
private BoundingBox(Vector3d[] bbox) { private BoundingBox(Vector3d[] bbox) {
if (bbox == null || bbox.length != 2) { if (bbox == null || bbox.length != 2) {
throw new IllegalArgumentException("BoundingBox must be an array of the length 2"); throw new IllegalArgumentException("BoundingBox must be an array of the length 2");
} }
this.bbox = bbox; this.bbox = bbox;
} }
/** /**
* Calculates the volume of the box * Calculates the volume of the box
* *
* @return the volume of the box * @return the volume of the box
*/ */
public double getVolume() { public double getVolume() {
double length = getDepth(); double length = getDepth();
double width = getWidth(); double width = getWidth();
double height = getHeight(); double height = getHeight();
return height * width * length; return height * width * length;
} }
/** /**
* Calculates the center of the bounding box * Calculates the center of the bounding box
* *
* @return the center of the bounding box * @return the center of the bounding box
*/ */
public Vector3d getCenter() { public Vector3d getCenter() {
return bbox[0].plus(bbox[1].minus(bbox[0]).mult(0.5)); return bbox[0].plus(bbox[1].minus(bbox[0]).mult(0.5));
} }
/** /**
* Getter for the corner array * Getter for the corner array
* *
* @return the array containing the corner points * @return the array containing the corner points
*/ */
public Vector3d[] getBox() { public Vector3d[] getBox() {
return bbox; return bbox;
} }
/** /**
* Calculates the width of the bounding box * Calculates the width of the bounding box
* *
* @return the width of the bounding box * @return the width of the bounding box
*/ */
public double getWidth() { public double getWidth() {
return bbox[1].getY() - bbox[0].getY(); return bbox[1].getY() - bbox[0].getY();
} }
/** /**
* Calculates the height of the bounding box * Calculates the height of the bounding box
* *
* @return the height of the bounding box * @return the height of the bounding box
*/ */
public double getHeight() { public double getHeight() {
return bbox[1].getZ() - bbox[0].getZ(); return bbox[1].getZ() - bbox[0].getZ();
} }
/** /**
* Calculates the depth of the bounding box * Calculates the depth of the bounding box
* *
* @return the depth of the bounding box * @return the depth of the bounding box
*/ */
public double getDepth() { public double getDepth() {
return bbox[1].getX() - bbox[0].getX(); return bbox[1].getX() - bbox[0].getX();
} }
/** /**
* Returns the length of the longest side of the bounding box, ignoring the * Returns the length of the longest side of the bounding box, ignoring the
* height. Only X and Y axis are considered * height. Only X and Y axis are considered
* *
* @return the length of the longest side in X or Y direction * @return the length of the longest side in X or Y direction
*/ */
public double getLongestSide() { public double getLongestSide() {
double width = getWidth(); double width = getWidth();
double depth = getDepth(); double depth = getDepth();
return Math.max(width, depth); return Math.max(width, depth);
} }
/** /**
* Calculates the direction vector from the lower corner to the upper corner * Calculates the direction vector from the lower corner to the upper corner
* *
* @return the direction vector from the lower corner to the upper corner * @return the direction vector from the lower corner to the upper corner
*/ */
public Vector3d getDiagonal() { public Vector3d getDiagonal() {
return bbox[1].minus(bbox[0]); return bbox[1].minus(bbox[0]);
} }
/** /**
* Calculates the distance between the corner points * Calculates the distance between the corner points
* *
* @return the distance between the corner points * @return the distance between the corner points
*/ */
public double getDiagonalLength() { public double getDiagonalLength() {
return bbox[1].getDistance(bbox[0]); return bbox[1].getDistance(bbox[0]);
} }
} }
/*- /*-
* Copyright 2022 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2022 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
* *
* This file is part of CityDoctor2. * This file is part of CityDoctor2.
* *
* CityDoctor2 is free software: you can redistribute it and/or modify * CityDoctor2 is free software: you can redistribute it and/or modify
...@@ -18,10 +18,13 @@ ...@@ -18,10 +18,13 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial; import de.hft.stuttgart.citydoctor2.check.Check;
import java.util.ArrayList; import de.hft.stuttgart.citydoctor2.check.CheckError;
import java.util.List; 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;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty; import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
...@@ -34,257 +37,256 @@ import org.xmlobjects.gml.model.geometry.complexes.CompositeSurface; ...@@ -34,257 +37,256 @@ import org.xmlobjects.gml.model.geometry.complexes.CompositeSurface;
import org.xmlobjects.gml.model.geometry.primitives.Solid; import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty; import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import de.hft.stuttgart.citydoctor2.check.Check; import java.io.Serial;
import de.hft.stuttgart.citydoctor2.check.CheckError; import java.util.ArrayList;
import de.hft.stuttgart.citydoctor2.check.CheckId; import java.util.List;
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 { 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 Logger logger = LogManager.getLogger(BridgeConstructiveElement.class);
private static final String CANNOT_ADD = "Cannot add ";
@Serial
private static final long serialVersionUID = 7353233899458901155L;
private final org.citygml4j.core.model.bridge.BridgeConstructiveElement gmlBridgeElement;
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
public BridgeConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement gmlObject) {
this.gmlBridgeElement = gmlObject;
}
@Override
public Copyable createCopyInstance() {
return new BridgeConstructiveElement(gmlBridgeElement);
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
// only handles CityGML2 for now
// unknown which CityGML is handled here
// need context information to decide
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
switch (geom.getType()) {
case SOLID:
Solid solid = CityGmlUtils.createSolid(geom, factory, config);
setSolidAccordingToLod(geom, solid);
break;
case MULTI_SURFACE:
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms);
break;
case COMPOSITE_SURFACE:
CompositeSurface cs = CityGmlUtils.createCompositeSurface(geom, factory, config);
setCompositeSurfaceAccordingToLod(geom, cs);
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);
}
@Serial private void setCompositeSurfaceAccordingToLod(Geometry geom, CompositeSurface cs) {
private static final long serialVersionUID = 7353233899458901155L; switch (geom.getLod()) {
case LOD1:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new GeometryProperty<>(cs));
break;
case LOD2:
gmlBridgeElement.getDeprecatedProperties().setLod2Geometry(new GeometryProperty<>(cs));
break;
case LOD3:
gmlBridgeElement.getDeprecatedProperties().setLod3Geometry(new GeometryProperty<>(cs));
break;
case LOD4:
gmlBridgeElement.getDeprecatedProperties().setLod4Geometry(new GeometryProperty<>(cs));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " composite surface to buildings");
}
}
private final org.citygml4j.core.model.bridge.BridgeConstructiveElement gmlBridgeElement; private void setSolidAccordingToLod(Geometry geom, Solid solid) {
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>(); switch (geom.getLod()) {
case LOD1:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new SolidProperty(solid));
break;
case LOD2:
gmlBridgeElement.getDeprecatedProperties().setLod2Geometry(new SolidProperty(solid));
break;
case LOD3:
gmlBridgeElement.getDeprecatedProperties().setLod3Geometry(new SolidProperty(solid));
break;
case LOD4:
gmlBridgeElement.getDeprecatedProperties().setLod4Geometry(new SolidProperty(solid));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " solid to buildings");
}
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) {
case LOD0:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD1:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD2:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD3:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD4:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " multi surface to buildings");
}
}
public BridgeConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement gmlObject) { @Override
this.gmlBridgeElement = gmlObject; public org.citygml4j.core.model.bridge.BridgeConstructiveElement getGmlObject() {
} return gmlBridgeElement;
}
@Override @Override
public Copyable createCopyInstance() { public void unsetGmlGeometries() {
return new BridgeConstructiveElement(gmlBridgeElement); gmlBridgeElement.setLod0MultiSurface(null);
} gmlBridgeElement.setLod2MultiSurface(null);
gmlBridgeElement.setLod3MultiSurface(null);
DeprecatedPropertiesOfBridgeConstructiveElement depProps = gmlBridgeElement.getDeprecatedProperties();
depProps.setLod1Geometry(null);
depProps.setLod2Geometry(null);
depProps.setLod3Geometry(null);
depProps.setLod4Geometry(null);
gmlBridgeElement.setLod1Solid(null);
gmlBridgeElement.setLod2Solid(null);
gmlBridgeElement.setLod3Solid(null);
for (BoundarySurface bs : boundarySurfaceList) {
bs.unsetGmlGeometries();
}
}
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public FeatureType getFeatureType() {
// only handles CityGML2 for now return FeatureType.BRIDGE_CONSTRUCTION_ELEMENT;
// unknown which CityGML is handled here }
// need context information to decide
for (Geometry geom : getGeometries()) {
switch (geom.getType()) {
case SOLID:
Solid solid = CityGmlUtils.createSolid(geom, factory, config);
setSolidAccordingToLod(geom, solid);
break;
case MULTI_SURFACE:
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms);
break;
case COMPOSITE_SURFACE:
CompositeSurface cs = CityGmlUtils.createCompositeSurface(geom, factory, config);
setCompositeSurfaceAccordingToLod(geom, cs);
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) { public void addBoundarySurface(BoundarySurface bs) {
switch (geom.getLod()) { boundarySurfaceList.add(bs);
case LOD1: bs.setParent(this);
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new GeometryProperty<>(cs)); }
break;
case LOD2:
gmlBridgeElement.getDeprecatedProperties().setLod2Geometry(new GeometryProperty<>(cs));
break;
case LOD3:
gmlBridgeElement.getDeprecatedProperties().setLod3Geometry(new GeometryProperty<>(cs));
break;
case LOD4:
gmlBridgeElement.getDeprecatedProperties().setLod4Geometry(new GeometryProperty<>(cs));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " composite surface to buildings");
}
}
private void setSolidAccordingToLod(Geometry geom, Solid solid) { public List<BoundarySurface> getBoundarySurfaces() {
switch (geom.getLod()) { return boundarySurfaceList;
case LOD1: }
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new SolidProperty(solid));
break;
case LOD2:
gmlBridgeElement.getDeprecatedProperties().setLod2Geometry(new SolidProperty(solid));
break;
case LOD3:
gmlBridgeElement.getDeprecatedProperties().setLod3Geometry(new SolidProperty(solid));
break;
case LOD4:
gmlBridgeElement.getDeprecatedProperties().setLod4Geometry(new SolidProperty(solid));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " solid to buildings");
}
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) {
case LOD0:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD1:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD2:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD3:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD4:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " multi surface to buildings");
}
}
@Override @Override
public org.citygml4j.core.model.bridge.BridgeConstructiveElement getGmlObject() { public void prepareForChecking() {
return gmlBridgeElement; super.prepareForChecking();
} for (BoundarySurface bs : boundarySurfaceList) {
bs.prepareForChecking();
}
}
@Override @Override
public void unsetGmlGeometries() { public void clearMetaInformation() {
gmlBridgeElement.setLod0MultiSurface(null); super.clearMetaInformation();
gmlBridgeElement.setLod2MultiSurface(null); for (BoundarySurface bs : boundarySurfaceList) {
gmlBridgeElement.setLod3MultiSurface(null); bs.clearMetaInformation();
DeprecatedPropertiesOfBridgeConstructiveElement depProps = gmlBridgeElement.getDeprecatedProperties(); }
depProps.setLod1Geometry(null); }
depProps.setLod2Geometry(null);
depProps.setLod3Geometry(null);
depProps.setLod4Geometry(null);
gmlBridgeElement.setLod1Solid(null);
gmlBridgeElement.setLod2Solid(null);
gmlBridgeElement.setLod3Solid(null);
for (BoundarySurface bs : boundarySurfaceList) {
bs.unsetGmlGeometries();
}
}
@Override @Override
public FeatureType getFeatureType() { public void collectInstances(CopyHandler handler) {
return FeatureType.BRIDGE_CONSTRUCTION_ELEMENT; super.collectInstances(handler);
} handler.addInstance(boundarySurfaceList);
}
public void addBoundarySurface(BoundarySurface bs) { @Override
boundarySurfaceList.add(bs); public void fillValues(Copyable original, CopyHandler handler) {
bs.setParent(this); super.fillValues(original, handler);
} BridgeConstructiveElement originalBce = (BridgeConstructiveElement) original;
for (BoundarySurface originalBs : originalBce.boundarySurfaceList) {
public List<BoundarySurface> getBoundarySurfaces() { boundarySurfaceList.add(handler.getCopyInstance(originalBs));
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));
}
}
} }
...@@ -52,8 +52,10 @@ public class BridgeObject extends CityObject { ...@@ -52,8 +52,10 @@ public class BridgeObject extends CityObject {
private final List<BridgeConstructiveElement> elements = new ArrayList<>(2); private final List<BridgeConstructiveElement> elements = new ArrayList<>(2);
private final List<BoundarySurface> boundarySurfaces = new ArrayList<>(2); private final List<BoundarySurface> boundarySurfaces = new ArrayList<>(2);
private final List<Installation> bridgeInstallations = new ArrayList<>(2); private final List<Installation> bridgeInstallations = new ArrayList<>(2);
private final List<BridgeRoom> bridgeRooms = new ArrayList<>(2);
private AbstractBridge ab; private AbstractBridge ab;
private BridgeType type; private BridgeType type;
public BridgeObject(BridgeType type, AbstractBridge ab) { public BridgeObject(BridgeType type, AbstractBridge ab) {
this.ab = ab; this.ab = ab;
this.type = type; this.type = type;
...@@ -72,9 +74,16 @@ public class BridgeObject extends CityObject { ...@@ -72,9 +74,16 @@ public class BridgeObject extends CityObject {
return bridgeInstallations; return bridgeInstallations;
} }
public List<BridgeRoom> getBridgeRooms() {
return bridgeRooms;
}
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (geom.getType() == GeometryType.MULTI_SURFACE) { if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config); MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms); setMultiSurfaceAccordingToLod(geom, ms);
...@@ -95,6 +104,9 @@ public class BridgeObject extends CityObject { ...@@ -95,6 +104,9 @@ public class BridgeObject extends CityObject {
for (BridgeConstructiveElement ele : elements) { for (BridgeConstructiveElement ele : elements) {
ele.reCreateGeometries(factory, config); ele.reCreateGeometries(factory, config);
} }
for (BridgeRoom br : bridgeRooms) {
br.reCreateGeometries(factory, config);
}
} }
...@@ -135,11 +147,16 @@ public class BridgeObject extends CityObject { ...@@ -135,11 +147,16 @@ public class BridgeObject extends CityObject {
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to bridges"); throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to bridges");
} }
} }
public void addBridgeInstallation(Installation coBi) { public void addBridgeInstallation(Installation coBi) {
bridgeInstallations.add(coBi); bridgeInstallations.add(coBi);
coBi.setParent(this); coBi.setParent(this);
} }
public void addBridgeRoom(BridgeRoom room) {
bridgeRooms.add(room);
}
@Override @Override
public void clearAllContainedCheckResults() { public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults(); super.clearAllContainedCheckResults();
...@@ -155,6 +172,9 @@ public class BridgeObject extends CityObject { ...@@ -155,6 +172,9 @@ public class BridgeObject extends CityObject {
for (BridgeConstructiveElement ele : elements) { for (BridgeConstructiveElement ele : elements) {
ele.clearAllContainedCheckResults(); ele.clearAllContainedCheckResults();
} }
for (BridgeRoom br : bridgeRooms) {
br.clearAllContainedCheckResults();
}
} }
@Override @Override
...@@ -172,6 +192,9 @@ public class BridgeObject extends CityObject { ...@@ -172,6 +192,9 @@ public class BridgeObject extends CityObject {
for (BridgeConstructiveElement ele : elements) { for (BridgeConstructiveElement ele : elements) {
ele.collectContainedErrors(errors); ele.collectContainedErrors(errors);
} }
for (BridgeRoom br : bridgeRooms) {
br.collectContainedErrors(errors);
}
} }
...@@ -199,6 +222,11 @@ public class BridgeObject extends CityObject { ...@@ -199,6 +222,11 @@ public class BridgeObject extends CityObject {
return true; return true;
} }
} }
for (BridgeRoom br : bridgeRooms) {
if (br.containsAnyError()) {
return true;
}
}
return false; return false;
} }
...@@ -236,6 +264,11 @@ public class BridgeObject extends CityObject { ...@@ -236,6 +264,11 @@ public class BridgeObject extends CityObject {
return true; return true;
} }
} }
for (BridgeRoom br : bridgeRooms) {
if (br.containsError(checkIdentifier)) {
return true;
}
}
return false; return false;
} }
...@@ -267,6 +300,9 @@ public class BridgeObject extends CityObject { ...@@ -267,6 +300,9 @@ public class BridgeObject extends CityObject {
for (BridgeConstructiveElement ele : elements) { for (BridgeConstructiveElement ele : elements) {
ele.accept(c); ele.accept(c);
} }
for (BridgeRoom br : bridgeRooms) {
br.accept(c);
}
} }
...@@ -324,6 +360,9 @@ public class BridgeObject extends CityObject { ...@@ -324,6 +360,9 @@ public class BridgeObject extends CityObject {
for (BridgeConstructiveElement ele : elements) { for (BridgeConstructiveElement ele : elements) {
ele.unsetGmlGeometries(); ele.unsetGmlGeometries();
} }
for (BridgeRoom br : bridgeRooms) {
br.unsetGmlGeometries();
}
} }
...@@ -348,6 +387,9 @@ public class BridgeObject extends CityObject { ...@@ -348,6 +387,9 @@ public class BridgeObject extends CityObject {
for (Installation bi : bridgeInstallations) { for (Installation bi : bridgeInstallations) {
bi.prepareForChecking(); bi.prepareForChecking();
} }
for (BridgeObject part : parts) {
part.prepareForChecking();
}
} }
@Override @Override
...@@ -369,6 +411,10 @@ public class BridgeObject extends CityObject { ...@@ -369,6 +411,10 @@ public class BridgeObject extends CityObject {
ele.clearMetaInformation(); ele.clearMetaInformation();
} }
for (BridgeRoom br : bridgeRooms) {
br.clearMetaInformation();
}
} }
@Override @Override
...@@ -390,6 +436,10 @@ public class BridgeObject extends CityObject { ...@@ -390,6 +436,10 @@ public class BridgeObject extends CityObject {
handler.addInstance(ele); handler.addInstance(ele);
} }
for (BridgeRoom br : bridgeRooms) {
handler.addInstance(br);
}
} }
public void anonymize() { public void anonymize() {
...@@ -429,6 +479,10 @@ public class BridgeObject extends CityObject { ...@@ -429,6 +479,10 @@ public class BridgeObject extends CityObject {
getConstructiveElements().add(handler.getCopyInstance(ele)); getConstructiveElements().add(handler.getCopyInstance(ele));
} }
for (BridgeRoom br : originalBo.bridgeRooms) {
getBridgeRooms().add(handler.getCopyInstance(br));
}
} }
public List<BoundarySurface> getBoundarySurfaces() { public List<BoundarySurface> getBoundarySurfaces() {
......
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
public class BridgeRoom extends AbstractRoom {
@Serial
private static final long serialVersionUID = -276088332165299253L;
private BridgeObject parent;
private BridgeRoom() {
}
public BridgeRoom(BridgeObject parent) {
this.parent = parent;
parent.addBridgeRoom(this);
}
public void setGmlObject(org.citygml4j.core.model.bridge.BridgeRoom cgmlRoom) {
super.cgmlRoom = cgmlRoom;
}
public BridgeObject getParent() {
return parent;
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
BridgeRoom oRoom = (BridgeRoom) original;
parent = handler.getCopyInstance(oRoom.getParent());
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(parent);
}
@Override
public Copyable createCopyInstance() {
return new BridgeRoom();
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.bridge.BridgeFurniture;
import java.io.Serial;
public class BridgeRoomFurniture extends AbstractFurniture {
@Serial
private static final long serialVersionUID = 2450802405053172352L;
public void setGmlObject(BridgeFurniture gmlObject) {
super.setGmlObject(gmlObject);
}
@Override
public Copyable createCopyInstance() {
return new BridgeRoomFurniture();
}
}
/*- /*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
* *
* This file is part of CityDoctor2. * This file is part of CityDoctor2.
* *
* CityDoctor2 is free software: you can redistribute it and/or modify * CityDoctor2 is free software: you can redistribute it and/or modify
...@@ -18,158 +18,157 @@ ...@@ -18,158 +18,157 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
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;
import de.hft.stuttgart.citydoctor2.check.Check; import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError; import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId; import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler; import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable; import de.hft.stuttgart.citydoctor2.utils.Copyable;
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;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class Building extends AbstractBuilding { public class Building extends AbstractBuilding {
@Serial @Serial
private static final long serialVersionUID = 588480113268630052L; private static final long serialVersionUID = 588480113268630052L;
private final List<BuildingPart> buildingParts = new ArrayList<>(2); private final List<BuildingPart> buildingParts = new ArrayList<>(2);
public List<BuildingPart> getBuildingParts() { public List<BuildingPart> getBuildingParts() {
return buildingParts; return buildingParts;
} }
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config); super.reCreateGeometries(factory, config);
for (BuildingPart bp : buildingParts) { for (BuildingPart bp : buildingParts) {
bp.reCreateGeometries(factory, config); bp.reCreateGeometries(factory, config);
} }
} }
@Override @Override
public void accept(Check c) { public void accept(Check c) {
super.accept(c); super.accept(c);
if (c.canExecute(this)) { if (c.canExecute(this)) {
c.check(this); c.check(this);
} }
for (BuildingPart bp : buildingParts) { for (BuildingPart bp : buildingParts) {
bp.accept(c); bp.accept(c);
} }
} }
@Override @Override
public void clearAllContainedCheckResults() { public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults(); super.clearAllContainedCheckResults();
for (BuildingPart bp : buildingParts) { for (BuildingPart bp : buildingParts) {
bp.clearAllContainedCheckResults(); bp.clearAllContainedCheckResults();
} }
} }
@Override @Override
public void collectContainedErrors(List<CheckError> errors) { public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors); super.collectContainedErrors(errors);
for (BuildingPart bp : buildingParts) { for (BuildingPart bp : buildingParts) {
bp.collectContainedErrors(errors); bp.collectContainedErrors(errors);
} }
} }
@Override @Override
public boolean containsAnyError() { public boolean containsAnyError() {
boolean hasError = super.containsAnyError(); boolean hasError = super.containsAnyError();
if (hasError) { if (hasError) {
return true; return true;
} }
for (BuildingPart bp : buildingParts) { for (BuildingPart bp : buildingParts) {
if (bp.containsAnyError()) { if (bp.containsAnyError()) {
return true; return true;
} }
} }
return false; return false;
} }
@Override @Override
public boolean containsError(CheckId checkIdentifier) { public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier); boolean hasError = super.containsError(checkIdentifier);
if (hasError) { if (hasError) {
return true; return true;
} }
for (BuildingPart bp : buildingParts) { for (BuildingPart bp : buildingParts) {
if (bp.containsError(checkIdentifier)) { if (bp.containsError(checkIdentifier)) {
return true; return true;
} }
} }
return false; return false;
} }
public void addBuildingPart(BuildingPart buildingPart) { public void addBuildingPart(BuildingPart buildingPart) {
buildingParts.add(buildingPart); buildingParts.add(buildingPart);
} }
@Override @Override
public String toString() { public String toString() {
return "Building [id=" + getGmlId() + "]"; return "Building [id=" + getGmlId() + "]";
} }
public void anonymize() { public void anonymize() {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
geom.anonymize(); geom.anonymize();
} }
org.citygml4j.core.model.building.Building gmlB = new org.citygml4j.core.model.building.Building(); org.citygml4j.core.model.building.Building gmlB = new org.citygml4j.core.model.building.Building();
gmlB.setId(GmlId.generateId().getGmlString()); gmlB.setId(GmlId.generateId().getGmlString());
for (Installation bi : getBuildingInstallations()) { for (Installation bi : getBuildingInstallations()) {
bi.anonymize(); bi.anonymize();
gmlB.getBuildingInstallations().add(new BuildingInstallationProperty((BuildingInstallation) bi.getGmlObject())); gmlB.getBuildingInstallations().add(new BuildingInstallationProperty((BuildingInstallation) bi.getGmlObject()));
} }
for (BoundarySurface bs : getBoundarySurfaces()) { for (BoundarySurface bs : getBoundarySurfaces()) {
bs.anonymize(); bs.anonymize();
gmlB.addBoundary(new AbstractSpaceBoundaryProperty(bs.getGmlObject())); gmlB.addBoundary(new AbstractSpaceBoundaryProperty(bs.getGmlObject()));
} }
setCityGmlBuilding(gmlB); setCityGmlBuilding(gmlB);
} }
@Override @Override
public void clearMetaInformation() { public void clearMetaInformation() {
super.clearMetaInformation(); super.clearMetaInformation();
for (BuildingPart part : buildingParts) { for (BuildingPart part : buildingParts) {
part.clearMetaInformation(); part.clearMetaInformation();
} }
} }
@Override @Override
public void prepareForChecking() { public void prepareForChecking() {
super.prepareForChecking(); super.prepareForChecking();
for (BuildingPart part : buildingParts) { for (BuildingPart part : buildingParts) {
part.prepareForChecking(); part.prepareForChecking();
} }
} }
@Override @Override
public void fillValues(Copyable original, CopyHandler handler) { public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler); super.fillValues(original, handler);
Building originalBuilding = (Building) original; Building originalBuilding = (Building) original;
for (BuildingPart originalBp : originalBuilding.buildingParts) { for (BuildingPart originalBp : originalBuilding.buildingParts) {
buildingParts.add(handler.getCopyInstance(originalBp)); buildingParts.add(handler.getCopyInstance(originalBp));
} }
} }
@Override @Override
public void collectInstances(CopyHandler handler) { public void collectInstances(CopyHandler handler) {
super.collectInstances(handler); super.collectInstances(handler);
for (BuildingPart bp : buildingParts) { for (BuildingPart bp : buildingParts) {
handler.addInstance(bp); handler.addInstance(bp);
} }
} }
@Override @Override
public Copyable createCopyInstance() { public Copyable createCopyInstance() {
return new Building(); return new Building();
} }
} }
/*- /*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
* *
* This file is part of CityDoctor2. * This file is part of CityDoctor2.
* *
* CityDoctor2 is free software: you can redistribute it and/or modify * CityDoctor2 is free software: you can redistribute it and/or modify
...@@ -24,50 +24,50 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable; ...@@ -24,50 +24,50 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial; import java.io.Serial;
public class BuildingPart extends AbstractBuilding { public class BuildingPart extends AbstractBuilding {
@Serial
private static final long serialVersionUID = 8200322261958679163L;
private Building parent;
private BuildingPart() {
}
public BuildingPart(Building parent) {
this.parent = parent;
parent.addBuildingPart(this);
}
public Building getParent() {
return parent;
}
@Override
public FeatureType getFeatureType() {
return FeatureType.BUILDING_PART;
}
@Override @Serial
public String toString() { private static final long serialVersionUID = 8200322261958679163L;
return "BuildingPart [id=" + getGmlId() + "]";
} private Building parent;
@Override private BuildingPart() {
public void fillValues(Copyable original, CopyHandler handler) { }
super.fillValues(original, handler);
BuildingPart originalPart = (BuildingPart) original; public BuildingPart(Building parent) {
parent = handler.getCopyInstance(originalPart.parent); this.parent = parent;
} parent.addBuildingPart(this);
}
@Override
public void collectInstances(CopyHandler handler) { public Building getParent() {
super.collectInstances(handler); return parent;
handler.addInstance(parent); }
}
@Override
public FeatureType getFeatureType() {
return FeatureType.BUILDING_PART;
}
@Override
public String toString() {
return "BuildingPart [id=" + getGmlId() + "]";
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
BuildingPart originalPart = (BuildingPart) original;
parent = handler.getCopyInstance(originalPart.parent);
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(parent);
}
@Override @Override
public Copyable createCopyInstance() { public Copyable createCopyInstance() {
return new BuildingPart(); return new BuildingPart();
} }
} }
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.building.BuildingFurnitureProperty;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class BuildingRoom extends AbstractRoom {
@Serial
private static final long serialVersionUID = -276088332165299253L;
private final List<BuildingFurnitureProperty> furnitureRefs = new ArrayList<>(2);
private CityObject parent;
public void setGmlObject(org.citygml4j.core.model.building.BuildingRoom cgmlRoom) {
super.cgmlRoom = cgmlRoom;
}
public void setParent(CityObject parent) {
this.parent = parent;
}
public void addFurnitureRef(BuildingFurnitureProperty furnitureRef) {
furnitureRefs.add(furnitureRef);
}
/**
* Returns the list of citygml3 furniture objects registered to this room.
* The reference objects only hold a HRef to the actual furniture object.
*
* @return
*/
public List<BuildingFurnitureProperty> getFurnitureRefs() {
return furnitureRefs;
}
public CityObject getParent() {
return parent;
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
BuildingRoom oRoom = (BuildingRoom) original;
parent = handler.getCopyInstance(oRoom.getParent());
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(parent);
}
@Override
public Copyable createCopyInstance() {
return new BuildingRoom();
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.building.BuildingFurniture;
import java.io.Serial;
public class BuildingRoomFurniture extends AbstractFurniture {
@Serial
private static final long serialVersionUID = -1046265159354525567L;
public void setGmlObject(BuildingFurniture gmlObject) {
super.setGmlObject(gmlObject);
}
@Override
public Copyable createCopyInstance() {
return new BuildingRoomFurniture();
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
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.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.util.geometry.GeometryFactory;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class BuildingUnit extends AbstractBuildingSubdivision {
@Serial
private static final long serialVersionUID = -2931788311665810322L;
private final List<Storey> storeys = new ArrayList<>();
@Override
public Copyable createCopyInstance() {
return new BuildingUnit();
}
@Override
public void unsetGmlGeometries() {
super.unsetGmlGeometries();
for (Storey storey : storeys) {
storey.unsetGmlGeometries();
}
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config);
for (Storey storey : storeys) {
storey.reCreateGeometries(factory, config);
}
}
@Override
public void accept(Check c) {
super.accept(c);
for (Storey storey : storeys) {
storey.accept(c);
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (Storey storey : storeys) {
storey.collectContainedErrors(errors);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (Storey storey : storeys) {
storey.clearAllContainedCheckResults();
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (Storey storey : storeys) {
if (storey.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (Storey storey : storeys) {
if (storey.containsAnyError()) {
return true;
}
}
return false;
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (Storey storey : storeys) {
storey.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (Storey storey : storeys) {
storey.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
for (Storey storey : storeys) {
storey.collectInstances(handler);
}
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
BuildingUnit originalBu = (BuildingUnit) original;
for (Storey storey : originalBu.storeys) {
storeys.add(handler.getCopyInstance(storey));
}
this.abs = originalBu.abs;
}
}
/*- /*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
* *
* This file is part of CityDoctor2. * This file is part of CityDoctor2.
* *
* CityDoctor2 is free software: you can redistribute it and/or modify * CityDoctor2 is free software: you can redistribute it and/or modify
...@@ -18,24 +18,6 @@ ...@@ -18,24 +18,6 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
import org.citygml4j.core.model.CityGMLVersion;
import org.citygml4j.core.model.core.CityModel;
import de.hft.stuttgart.citydoctor2.check.AbstractCheck; import de.hft.stuttgart.citydoctor2.check.AbstractCheck;
import de.hft.stuttgart.citydoctor2.check.Check; import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError; import de.hft.stuttgart.citydoctor2.check.CheckError;
...@@ -43,361 +25,441 @@ import de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException; ...@@ -43,361 +25,441 @@ import de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.writer.CityGMLWriterUtils; import de.hft.stuttgart.citydoctor2.writer.CityGMLWriterUtils;
import de.hft.stuttgart.quality.model.types.ValidationPlan; import de.hft.stuttgart.quality.model.types.ValidationPlan;
import org.citygml4j.core.model.CityGMLVersion;
import org.citygml4j.core.model.core.CityModel;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
/** /**
* The complete CityGML model containing all features that are used in * The complete CityGML model containing all features that are used in
* CityDoctor * CityDoctor
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public class CityDoctorModel { public class CityDoctorModel {
private static final String COULD_NOT_FIND_FEATURE = "Could not find feature: "; private static final String COULD_NOT_FIND_FEATURE = "Could not find feature: ";
private final List<Building> buildings; private final List<Building> buildings;
private final List<Vegetation> vegetation; private final List<Vegetation> vegetation;
private final List<BridgeObject> bridges; private final List<BridgeObject> bridges;
private final List<CityObject> land; private final List<CityFurniture> cityfurniture;
private final List<TransportationObject> roads; private final List<GenericCityObject> genericObjects;
private final List<WaterObject> water; private final List<CityObject> land;
private CityModel cModel; private final List<TransportationObject> roads;
private final ParserConfiguration config; private final List<Tunnel> tunnels;
private final String fileName; private final List<WaterObject> water;
private final File file; private CityModel cModel;
private final List<CheckError> globalErrors; private final ParserConfiguration config;
private boolean isValidated = false; private final String fileName;
private ValidationPlan plan; private final File file;
private CityGMLVersion cityGMLVersion; private final List<CheckError> globalErrors;
private boolean isValidated = false;
public CityDoctorModel(ParserConfiguration config, File file) { private ValidationPlan plan;
if (config == null) { private CityGMLVersion cityGMLVersion;
throw new IllegalArgumentException("Parser configuration may not be null");
} public CityDoctorModel(ParserConfiguration config, File file) {
this.fileName = file.getName(); if (config == null) {
this.config = config; throw new IllegalArgumentException("Parser configuration may not be null");
this.file = file; }
buildings = new ArrayList<>(); this.fileName = file.getName();
vegetation = new ArrayList<>(); this.config = config;
bridges = new ArrayList<>(); this.file = file;
land = new ArrayList<>(); buildings = new ArrayList<>();
roads = new ArrayList<>(); vegetation = new ArrayList<>();
water = new ArrayList<>(); bridges = new ArrayList<>();
globalErrors = new ArrayList<>(); land = new ArrayList<>();
} roads = new ArrayList<>();
tunnels = new ArrayList<>();
public boolean isValidated() { water = new ArrayList<>();
return isValidated; cityfurniture = new ArrayList<>();
} genericObjects = new ArrayList<>();
globalErrors = new ArrayList<>();
public void setValidated(ValidationPlan plan) { }
if (plan == null) {
this.plan = null; public boolean isValidated() {
this.isValidated = false; return isValidated;
return; }
}
this.plan = plan; public void setValidated(ValidationPlan plan) {
this.isValidated = true; if (plan == null) {
} this.plan = null;
this.isValidated = false;
public ValidationPlan getValidationPlan() { return;
return plan; }
} this.plan = plan;
this.isValidated = true;
public void addGlobalError(CheckError err) { }
globalErrors.add(err);
} public ValidationPlan getValidationPlan() {
return plan;
public void addGlobalErrors(List<? extends CheckError> generalErrors) { }
globalErrors.addAll(generalErrors);
} public void addGlobalError(CheckError err) {
globalErrors.add(err);
public List<CheckError> getGlobalErrors() { }
return globalErrors;
} public void addGlobalErrors(List<? extends CheckError> generalErrors) {
globalErrors.addAll(generalErrors);
public File getFile() { }
return file;
} public List<CheckError> getGlobalErrors() {
return globalErrors;
public Stream<CityObject> createFeatureStream() { }
return Stream.of(buildings.stream(), vegetation.stream(), bridges.stream(), land.stream(), roads.stream(),
water.stream()).flatMap(co -> co); public File getFile() {
} return file;
}
public void saveAs(String file, boolean saveQualityAde) throws CityDoctorWriteException {
if (file.endsWith(".off")) { public Stream<CityObject> createFeatureStream() {
exportAsOff(file); return Stream.of(buildings.stream(), vegetation.stream(), bridges.stream(), land.stream(), roads.stream(),
} else { tunnels.stream(), water.stream(), cityfurniture.stream(), genericObjects.stream()).flatMap(co -> co);
ValidationPlan tempPlan = plan; }
if (!saveQualityAde) {
setValidated(null); public void saveAs(String file, boolean saveQualityAde) throws CityDoctorWriteException {
} if (file.endsWith(".off")) {
exportAsGML(file); exportAsOff(file);
if (!saveQualityAde) { } else {
setValidated(tempPlan); ValidationPlan tempPlan = plan;
} if (!saveQualityAde) {
} setValidated(null);
} }
exportAsGML(file);
private void exportAsGML(String file) throws CityDoctorWriteException { if (!saveQualityAde) {
CityGMLWriterUtils.writeCityModel(file, this); setValidated(tempPlan);
} }
}
private void exportAsOff(String file) { }
file = file.substring(0, file.lastIndexOf('.'));
File folder = new File(file); private void exportAsGML(String file) throws CityDoctorWriteException {
folder.mkdirs(); CityGMLWriterUtils.writeCityModel(file, this);
createFeatureStream().forEach(co -> { }
Map<Lod, Set<Polygon>> polygonMap = new EnumMap<>(Lod.class);
Check c = new AbstractCheck() { private void exportAsOff(String file) {
file = file.substring(0, file.lastIndexOf('.'));
@Override File folder = new File(file);
public void check(Geometry geom) { folder.mkdirs();
polygonMap.compute(geom.getLod(), (lod, polys) -> { createFeatureStream().forEach(co -> {
if (polys == null) { Map<Lod, Set<Polygon>> polygonMap = new EnumMap<>(Lod.class);
polys = new HashSet<>(); Check c = new AbstractCheck() {
}
for (Polygon poly : geom.getPolygons()) { @Override
polys.add(poly.getOriginal()); public void check(Geometry geom) {
} polygonMap.compute(geom.getLod(), (lod, polys) -> {
return polys; if (polys == null) {
}); polys = new HashSet<>();
} }
}; for (Polygon poly : geom.getPolygons()) {
co.accept(c); polys.add(poly.getOriginal());
}
Set<Polygon> highestLod = polygonMap.get(Lod.LOD2); return polys;
if (highestLod == null) { });
highestLod = polygonMap.get(Lod.LOD1); }
} };
if (highestLod == null) { co.accept(c);
return;
} Set<Polygon> highestLod = polygonMap.get(Lod.LOD2);
Map<Vertex, Integer> idMap = new LinkedHashMap<>(); if (highestLod == null) {
AtomicInteger counter = new AtomicInteger(0); highestLod = polygonMap.get(Lod.LOD1);
for (Polygon poly : highestLod) { }
addRing(poly.getExteriorRing(), idMap, counter); if (highestLod == null) {
} return;
}
try (BufferedWriter writer = Files.newBufferedWriter(folder.toPath().resolve(co.getGmlId() + ".off"))) { Map<Vertex, Integer> idMap = new LinkedHashMap<>();
writer.write("OFF\n"); AtomicInteger counter = new AtomicInteger(0);
writer.write(Integer.toString(idMap.size())); for (Polygon poly : highestLod) {
writer.write(' '); addRing(poly.getExteriorRing(), idMap, counter);
writer.write(Integer.toString(highestLod.size())); }
writer.write(" 0\n");
for (Vertex v : idMap.keySet()) { try (BufferedWriter writer = Files.newBufferedWriter(folder.toPath().resolve(co.getGmlId() + ".off"))) {
writer.write(Double.toString(v.getX())); writer.write("OFF\n");
writer.write(' '); writer.write(Integer.toString(idMap.size()));
writer.write(Double.toString(v.getY())); writer.write(' ');
writer.write(' '); writer.write(Integer.toString(highestLod.size()));
writer.write(Double.toString(v.getZ())); writer.write(" 0\n");
writer.write('\n'); for (Vertex v : idMap.keySet()) {
} writer.write(Double.toString(v.getX()));
for (Polygon poly : highestLod) { writer.write(' ');
writer.write(Integer.toString(poly.getExteriorRing().getVertices().size() - 1)); writer.write(Double.toString(v.getY()));
writer.write(' '); writer.write(' ');
for (int i = 0; i < poly.getExteriorRing().getVertices().size() - 1; i++) { writer.write(Double.toString(v.getZ()));
Vertex v = poly.getExteriorRing().getVertices().get(i); writer.write('\n');
writer.write(Integer.toString(idMap.get(v))); }
writer.write(' '); for (Polygon poly : highestLod) {
} writer.write(Integer.toString(poly.getExteriorRing().getVertices().size() - 1));
writer.write('\n'); writer.write(' ');
} for (int i = 0; i < poly.getExteriorRing().getVertices().size() - 1; i++) {
} catch (IOException e) { Vertex v = poly.getExteriorRing().getVertices().get(i);
throw new UncheckedIOException(e); writer.write(Integer.toString(idMap.get(v)));
} writer.write(' ');
}
}); writer.write('\n');
} }
} catch (IOException e) {
private void addRing(LinearRing ring, Map<Vertex, Integer> idMap, AtomicInteger counter) { throw new UncheckedIOException(e);
for (Vertex v : ring.getVertices()) { }
idMap.computeIfAbsent(v, k -> counter.getAndIncrement());
} });
} }
public Set<CheckError> collectErrors() { private void addRing(LinearRing ring, Map<Vertex, Integer> idMap, AtomicInteger counter) {
List<CheckError> errors = new ArrayList<>(); for (Vertex v : ring.getVertices()) {
collectErrorsFromList(errors, buildings); idMap.computeIfAbsent(v, k -> counter.getAndIncrement());
collectErrorsFromList(errors, vegetation); }
collectErrorsFromList(errors, bridges); }
collectErrorsFromList(errors, land);
collectErrorsFromList(errors, roads); public Set<CheckError> collectErrors() {
collectErrorsFromList(errors, water); List<CheckError> errors = new ArrayList<>();
return new HashSet<>(errors); collectErrorsFromList(errors, buildings);
} collectErrorsFromList(errors, vegetation);
collectErrorsFromList(errors, bridges);
private void collectErrorsFromList(List<CheckError> errors, List<? extends CityObject> cos) { collectErrorsFromList(errors, land);
for (CityObject co : cos) { collectErrorsFromList(errors, roads);
co.collectContainedErrors(errors); collectErrorsFromList(errors, tunnels);
} collectErrorsFromList(errors, water);
} collectErrorsFromList(errors, cityfurniture);
collectErrorsFromList(errors, genericObjects);
public String getFileName() { return new HashSet<>(errors);
return fileName; }
}
private void collectErrorsFromList(List<CheckError> errors, List<? extends CityObject> cos) {
public void addBridge(BridgeObject coBridge) { for (CityObject co : cos) {
bridges.add(coBridge); co.collectContainedErrors(errors);
} }
}
public void addBuilding(Building coBuilding) {
buildings.add(coBuilding); public String getFileName() {
} return fileName;
}
public List<Building> getBuildings() {
return buildings; public void addBridge(BridgeObject coBridge) {
} bridges.add(coBridge);
}
public List<BridgeObject> getBridges() {
return bridges; public void addBuilding(Building coBuilding) {
} buildings.add(coBuilding);
}
public void setCityModel(CityModel cModel) {
this.cModel = cModel; public List<Building> getBuildings() {
} return buildings;
}
public CityModel getCityModel() {
return cModel; public List<BridgeObject> getBridges() {
} return bridges;
}
public List<TransportationObject> getTransportation() {
return roads; public List<CityFurniture> getCityFurniture() {
} return cityfurniture;
}
public List<WaterObject> getWater() {
return water; public void addCityFurniture(CityFurniture coFurniture) {
} cityfurniture.add(coFurniture);
}
public List<CityObject> getLand() {
return land; public List<GenericCityObject> getGenericCityObjects() {
} return genericObjects;
}
public List<Vegetation> getVegetation() {
return vegetation; public void addGenericCityObject(GenericCityObject coGenericCityObject) {
} genericObjects.add(coGenericCityObject);
}
public void addWater(WaterObject wo) {
water.add(wo); public void setCityModel(CityModel cModel) {
} this.cModel = cModel;
}
public void addLand(LandObject lo) {
land.add(lo); public CityModel getCityModel() {
} return cModel;
}
public void addVegetation(Vegetation veg) {
vegetation.add(veg); public List<TransportationObject> getTransportation() {
} return roads;
}
public void addTransportation(TransportationObject to) {
roads.add(to); public List<Tunnel> getTunnels() {
} return tunnels;
}
public int getNumberOfFeatures() {
return buildings.size() + vegetation.size() + bridges.size() + land.size() + roads.size() + water.size(); public List<WaterObject> getWater() {
} return water;
}
public ParserConfiguration getParserConfig() {
return config; public List<CityObject> getLand() {
} return land;
}
public void replaceFeature(CityObject currentFeature, CityObject nextFeature) {
if (nextFeature instanceof Building) { public List<Vegetation> getVegetation() {
replaceBuilding(currentFeature, nextFeature); return vegetation;
} else if (nextFeature instanceof BridgeObject) { }
replaceBridge(currentFeature, nextFeature);
} else if (nextFeature instanceof TransportationObject) { public void addWater(WaterObject wo) {
replaceTransportationObject(currentFeature, nextFeature); water.add(wo);
} else if (nextFeature instanceof Vegetation) { }
replaceVegetation(currentFeature, nextFeature);
} else if (nextFeature instanceof LandObject) { public void addLand(LandObject lo) {
replaceLandObject(currentFeature, nextFeature); land.add(lo);
} else if (nextFeature instanceof WaterObject) { }
replaceWaterObject(currentFeature, nextFeature);
} public void addVegetation(Vegetation veg) {
} vegetation.add(veg);
}
private void replaceWaterObject(CityObject currentFeature, CityObject nextFeature) {
int index = water.indexOf(currentFeature); public void addTransportation(TransportationObject to) {
if (index == -1) { roads.add(to);
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in water objects"); }
}
water.set(index, (WaterObject) nextFeature); public void addTunnel(Tunnel tunnel) {
} tunnels.add(tunnel);
}
private void replaceLandObject(CityObject currentFeature, CityObject nextFeature) {
int index = land.indexOf(currentFeature); public int getNumberOfFeatures() {
if (index == -1) { return buildings.size() + vegetation.size() + bridges.size() + land.size() + tunnels.size()
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in land objects"); + roads.size() + water.size() + cityfurniture.size() + genericObjects.size();
} }
land.set(index, nextFeature);
} public ParserConfiguration getParserConfig() {
return config;
private void replaceVegetation(CityObject currentFeature, CityObject nextFeature) { }
int index = vegetation.indexOf(currentFeature);
if (index == -1) { public void replaceFeature(CityObject currentFeature, CityObject nextFeature) {
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in vegetation"); if (nextFeature instanceof Building) {
} replaceBuilding(currentFeature, nextFeature);
vegetation.set(index, (Vegetation) nextFeature); } else if (nextFeature instanceof BridgeObject) {
} replaceBridge(currentFeature, nextFeature);
} else if (nextFeature instanceof TransportationObject) {
private void replaceTransportationObject(CityObject currentFeature, CityObject nextFeature) { replaceTransportationObject(currentFeature, nextFeature);
int index = roads.indexOf(currentFeature); } else if (nextFeature instanceof Tunnel) {
if (index == -1) { replaceTunnel(currentFeature, nextFeature);
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in transportation objects"); } else if (nextFeature instanceof Vegetation) {
} replaceVegetation(currentFeature, nextFeature);
roads.set(index, (TransportationObject) nextFeature); } else if (nextFeature instanceof LandObject) {
} replaceLandObject(currentFeature, nextFeature);
} else if (nextFeature instanceof WaterObject) {
private void replaceBridge(CityObject currentFeature, CityObject nextFeature) { replaceWaterObject(currentFeature, nextFeature);
int index = bridges.indexOf(currentFeature); } else if (nextFeature instanceof CityFurniture) {
if (index == -1) { replaceCityFurniture(currentFeature, nextFeature);
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in bridges"); } else if (nextFeature instanceof GenericCityObject) {
} replaceGenericCityObject(currentFeature, nextFeature);
bridges.set(index, (BridgeObject) nextFeature); }
} }
private void replaceBuilding(CityObject currentFeature, CityObject nextFeature) { private void replaceWaterObject(CityObject currentFeature, CityObject nextFeature) {
int index = buildings.indexOf(currentFeature); int index = water.indexOf(currentFeature);
if (index == -1) { if (index == -1) {
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in buildings"); throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in water objects");
} }
buildings.set(index, (Building) nextFeature); water.set(index, (WaterObject) nextFeature);
} }
public void addCityObject(CityObject co) { private void replaceLandObject(CityObject currentFeature, CityObject nextFeature) {
if (co instanceof Building b) { int index = land.indexOf(currentFeature);
buildings.add(b); if (index == -1) {
} else if (co instanceof BridgeObject bo) { throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in land objects");
bridges.add(bo); }
} else if (co instanceof TransportationObject to) { land.set(index, nextFeature);
roads.add(to); }
} else if (co instanceof Vegetation veg) {
vegetation.add(veg); private void replaceVegetation(CityObject currentFeature, CityObject nextFeature) {
} else if (co instanceof LandObject lo) { int index = vegetation.indexOf(currentFeature);
land.add(lo); if (index == -1) {
} else if (co instanceof WaterObject wo) { throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in vegetation");
water.add(wo); }
} else if (co instanceof ReliefObject) { vegetation.set(index, (Vegetation) nextFeature);
land.add(co); }
} else if (co instanceof TinObject) {
land.add(co); private void replaceCityFurniture(CityObject currentFeature, CityObject nextFeature) {
} int index = cityfurniture.indexOf(currentFeature);
} if (index == -1) {
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in vegetation");
public void setParsedCityGMLVersion(CityGMLVersion cityGMLVersion) { }
this.cityGMLVersion = cityGMLVersion; cityfurniture.set(index, (CityFurniture) nextFeature);
} }
public CityGMLVersion getCityGMLVersion() { private void replaceGenericCityObject(CityObject currentFeature, CityObject nextFeature) {
return cityGMLVersion; int index = genericObjects.indexOf(currentFeature);
} if (index == -1) {
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in generic city objects");
public void addRelief(ReliefObject relief) { }
addCityObject(relief); genericObjects.set(index, (GenericCityObject) nextFeature);
} }
public void addTin(TinObject tin) { private void replaceTransportationObject(CityObject currentFeature, CityObject nextFeature) {
addCityObject(tin); int index = roads.indexOf(currentFeature);
} if (index == -1) {
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in transportation objects");
}
roads.set(index, (TransportationObject) nextFeature);
}
private void replaceTunnel(CityObject currentFeature, CityObject nextFeature) {
int index = tunnels.indexOf(currentFeature);
if (index == -1) {
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in tunnels");
}
tunnels.set(index, (Tunnel) nextFeature);
}
private void replaceBridge(CityObject currentFeature, CityObject nextFeature) {
int index = bridges.indexOf(currentFeature);
if (index == -1) {
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in bridges");
}
bridges.set(index, (BridgeObject) nextFeature);
}
private void replaceBuilding(CityObject currentFeature, CityObject nextFeature) {
int index = buildings.indexOf(currentFeature);
if (index == -1) {
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in buildings");
}
buildings.set(index, (Building) nextFeature);
}
public void addCityObject(CityObject co) {
if (co instanceof Building b) {
buildings.add(b);
} else if (co instanceof BridgeObject bo) {
bridges.add(bo);
} else if (co instanceof TransportationObject to) {
roads.add(to);
} else if (co instanceof Tunnel tu) {
tunnels.add(tu);
} else if (co instanceof Vegetation veg) {
vegetation.add(veg);
} else if (co instanceof LandObject lo) {
land.add(lo);
} else if (co instanceof WaterObject wo) {
water.add(wo);
} else if (co instanceof ReliefObject) {
land.add(co);
} else if (co instanceof TinObject) {
land.add(co);
} else if (co instanceof CityFurniture cf) {
cityfurniture.add(cf);
} else if (co instanceof GenericCityObject gco) {
genericObjects.add(gco);
}
}
public void setParsedCityGMLVersion(CityGMLVersion cityGMLVersion) {
this.cityGMLVersion = cityGMLVersion;
}
public CityGMLVersion getCityGMLVersion() {
return cityGMLVersion;
}
public void addRelief(ReliefObject relief) {
addCityObject(relief);
}
public void addTin(TinObject tin) {
addCityObject(tin);
}
} }
Supports Markdown
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