Commit a01b9086 authored by Riegel's avatar Riegel
Browse files

Fix: Add parsing of Building ConstructiveElements

parent e5c41d24
Pipeline #11520 passed with stage
in 1 minute and 32 seconds
...@@ -53,6 +53,7 @@ public abstract class AbstractBuilding extends CityObject { ...@@ -53,6 +53,7 @@ public abstract class AbstractBuilding extends CityObject {
private final List<Storey> buildingStoreys = new ArrayList<>(); private final List<Storey> buildingStoreys = new ArrayList<>();
private final List<BuildingUnit> buildingUnits = new ArrayList<>(); private final List<BuildingUnit> buildingUnits = new ArrayList<>();
private final List<BuildingRoomFurniture> buildingRoomFurnitureList = new ArrayList<>(); private final List<BuildingRoomFurniture> buildingRoomFurnitureList = new ArrayList<>();
private final List<BuildingConstructiveElement> buildingConstructiveElements = new ArrayList<>();
private org.citygml4j.core.model.building.AbstractBuilding ab; private org.citygml4j.core.model.building.AbstractBuilding ab;
/** /**
...@@ -74,6 +75,10 @@ public abstract class AbstractBuilding extends CityObject { ...@@ -74,6 +75,10 @@ public abstract class AbstractBuilding extends CityObject {
return FeatureType.BUILDING; return FeatureType.BUILDING;
} }
public List<BuildingConstructiveElement> getConstructiveElements() {
return buildingConstructiveElements;
}
@Override @Override
public void unsetGmlGeometries() { public void unsetGmlGeometries() {
ab.setLod1Solid(null); ab.setLod1Solid(null);
...@@ -171,6 +176,9 @@ public abstract class AbstractBuilding extends CityObject { ...@@ -171,6 +176,9 @@ public abstract class AbstractBuilding extends CityObject {
for (BoundarySurface bs : boundarySurfaceList) { for (BoundarySurface bs : boundarySurfaceList) {
bs.accept(c); bs.accept(c);
} }
for (BuildingConstructiveElement bce : buildingConstructiveElements) {
bce.accept(c);
}
for (BuildingRoom br : buildingRooms) { for (BuildingRoom br : buildingRooms) {
br.accept(c); br.accept(c);
} }
...@@ -219,6 +227,11 @@ public abstract class AbstractBuilding extends CityObject { ...@@ -219,6 +227,11 @@ public abstract class AbstractBuilding extends CityObject {
buildingUnit.setParent(this); buildingUnit.setParent(this);
} }
public void addConstructiveElement(BuildingConstructiveElement constructiveElement) {
buildingConstructiveElements.add(constructiveElement);
constructiveElement.setParent(this);
}
public void setGmlObject(org.citygml4j.core.model.building.AbstractBuilding ab) { public void setGmlObject(org.citygml4j.core.model.building.AbstractBuilding ab) {
this.ab = ab; this.ab = ab;
} }
......
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.CheckableVisitor;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import javafx.scene.paint.Color;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.model.deprecated.bridge.DeprecatedPropertiesOfBridgeConstructiveElement;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.GeometryProperty;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.complexes.CompositeSurface;
import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class BuildingConstructiveElement extends CityObject {
private static final Logger logger = LogManager.getLogger(BuildingConstructiveElement.class);
private static final String CANNOT_ADD = "Cannot add ";
@Serial
private static final long serialVersionUID = 7353233899458901155L;
private final org.citygml4j.core.model.building.BuildingConstructiveElement gmlBuildingElement;
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
private AbstractBuilding parent;
public BuildingConstructiveElement(org.citygml4j.core.model.building.BuildingConstructiveElement gmlObject) {
this.gmlBuildingElement = gmlObject;
}
public void setParent(AbstractBuilding parent) {
this.parent = parent;
}
public AbstractBuilding getParent() {
return parent;
}
@Override
public Color getRenderColor() {
return parent.getRenderColor().brighter();
}
@Override
public void rebuildGeometries(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;
}
}
}
@Override
public void accept(CheckableVisitor c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.accept(c);
}
}
private void reCreateBoundarySurface(GeometryFactory factory, ParserConfiguration config, BoundarySurface bs) {
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : gmlBuildingElement.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from BridgeConstructiveElement", bs.getGmlId());
gmlBuildingElement.getBoundaries().remove(bsp);
break;
}
}
return;
}
bs.reCreateGeometries(factory, config);
}
private void setSolidAccordingToLod(Geometry geom, Solid solid) {
switch (geom.getLod()) {
case LOD1:
gmlBuildingElement.setLod1Solid(new SolidProperty(solid));
break;
case LOD2:
gmlBuildingElement.setLod2Solid(new SolidProperty(solid));
break;
case LOD3:
gmlBuildingElement.setLod3Solid(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:
gmlBuildingElement.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
gmlBuildingElement.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
gmlBuildingElement.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " multi surface to buildings");
}
}
@Override
public org.citygml4j.core.model.building.BuildingConstructiveElement getGmlObject() {
return gmlBuildingElement;
}
@Override
public void unsetGmlGeometries() {
gmlBuildingElement.setLod0MultiSurface(null);
gmlBuildingElement.setLod2MultiSurface(null);
gmlBuildingElement.setLod3MultiSurface(null);
gmlBuildingElement.setLod1Solid(null);
gmlBuildingElement.setLod2Solid(null);
gmlBuildingElement.setLod3Solid(null);
}
@Override
public CityObject getTopLevelCityObject() {
return getParent().getTopLevelCityObject();
}
@Override
public FeatureType getFeatureType() {
return FeatureType.BRIDGE_CONSTRUCTION_ELEMENT;
}
public void addBoundarySurface(BoundarySurface bs) {
boundarySurfaceList.add(bs);
bs.setParent(this);
}
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaceList;
}
}
...@@ -39,6 +39,7 @@ import org.apache.logging.log4j.LogManager; ...@@ -39,6 +39,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.CityGMLVersion; import org.citygml4j.core.model.CityGMLVersion;
import org.citygml4j.core.model.bridge.*; import org.citygml4j.core.model.bridge.*;
import org.citygml4j.core.model.building.BuildingConstructiveElement;
import org.citygml4j.core.model.building.BuildingUnit; import org.citygml4j.core.model.building.BuildingUnit;
import org.citygml4j.core.model.building.Storey; import org.citygml4j.core.model.building.Storey;
import org.citygml4j.core.model.building.*; import org.citygml4j.core.model.building.*;
...@@ -1031,6 +1032,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -1031,6 +1032,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseAndAddMultiSurface(gmlAb.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, cdBuilding); parseAndAddMultiSurface(gmlAb.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, cdBuilding);
parseAndAddSolid(gmlAb.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, cdBuilding); parseAndAddSolid(gmlAb.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, cdBuilding);
parseBuildingConstructiveElements(gmlAb, cdBuilding);
parseBuildingInstallations(gmlAb, cdBuilding); parseBuildingInstallations(gmlAb, cdBuilding);
parseBuildingRooms(gmlAb, cdBuilding); parseBuildingRooms(gmlAb, cdBuilding);
parseBuildingSubdivisions(gmlAb, cdBuilding); parseBuildingSubdivisions(gmlAb, cdBuilding);
...@@ -1084,6 +1086,19 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -1084,6 +1086,19 @@ public class Citygml3FeatureMapper extends ObjectWalker {
} }
} }
private void parseBuildingConstructiveElements(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
for (BuildingConstructiveElementProperty bceProp : gmlAb.getBuildingConstructiveElements()) {
var gmlBCE = bceProp.getObject();
if (gmlBCE == null) {
continue;
}
de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement bce =
new de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement(gmlBCE);
mapBuildingConstructiveElement(bce, gmlBCE);
cdBuilding.addConstructiveElement(bce);
}
}
private void parseBuildingRooms(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) { private void parseBuildingRooms(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
for (BuildingRoomProperty brProp : gmlAb.getBuildingRooms()) { for (BuildingRoomProperty brProp : gmlAb.getBuildingRooms()) {
var gmlBr = brProp.getObject(); var gmlBr = brProp.getObject();
...@@ -1182,6 +1197,21 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -1182,6 +1197,21 @@ public class Citygml3FeatureMapper extends ObjectWalker {
} }
private void mapBuildingConstructiveElement(de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement bce, BuildingConstructiveElement ele) {
mapAbstractOccupiedSpace(ele, bce);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : ele.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
bce.addBoundarySurface(bs);
}
}
private de.hft.stuttgart.citydoctor2.datastructure.Storey mapBuildingStorey(Storey gmlStorey) { private de.hft.stuttgart.citydoctor2.datastructure.Storey mapBuildingStorey(Storey gmlStorey) {
de.hft.stuttgart.citydoctor2.datastructure.Storey storey = new de.hft.stuttgart.citydoctor2.datastructure.Storey(); de.hft.stuttgart.citydoctor2.datastructure.Storey storey = new de.hft.stuttgart.citydoctor2.datastructure.Storey();
storey.setGmlObject(gmlStorey); storey.setGmlObject(gmlStorey);
......
...@@ -590,6 +590,7 @@ public class CityDoctorController { ...@@ -590,6 +590,7 @@ public class CityDoctorController {
TreeItem<Renderable> item = buildTopLevelCityObjectNode(b, root, b.getBoundarySurfaces()); TreeItem<Renderable> item = buildTopLevelCityObjectNode(b, root, b.getBoundarySurfaces());
createBuildingInstallationNodes(b, item); createBuildingInstallationNodes(b, item);
createBuildingConstructiveElementsNodes(b, item);
createBuildingRoomNodes(b, item); createBuildingRoomNodes(b, item);
createBuildingFurnitureNodes(b, item); createBuildingFurnitureNodes(b, item);
createBuildingStoreyNodes(b, item); createBuildingStoreyNodes(b, item);
...@@ -860,6 +861,21 @@ public class CityDoctorController { ...@@ -860,6 +861,21 @@ public class CityDoctorController {
createRoomNodes(ab.getBuildingRooms(), root); createRoomNodes(ab.getBuildingRooms(), root);
} }
private void createBuildingConstructiveElementsNodes(AbstractBuilding ab, TreeItem<Renderable> root) {
if (ab.getConstructiveElements().isEmpty()) {
return;
}
CityObjectGroupNode constructiveElementsGroupNode = new CityObjectGroupNode(
ab.getConstructiveElements(), "Constructive Elements", Color.CORAL);
TreeItem<Renderable> constructiveElementsGroupItem = new TreeItem<>(constructiveElementsGroupNode);
root.getChildren().add(constructiveElementsGroupItem);
for (BuildingConstructiveElement bce : ab.getConstructiveElements()) {
buildCityObjectNode(bce, constructiveElementsGroupItem, bce.getBoundarySurfaces());
}
}
private void createRoomNodes(List<? extends AbstractRoom> rooms, TreeItem<Renderable> root) { private void createRoomNodes(List<? extends AbstractRoom> rooms, TreeItem<Renderable> root) {
if (rooms.isEmpty()) { if (rooms.isEmpty()) {
return; return;
......
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