Commit 23ca3296 authored by Riegel's avatar Riegel
Browse files

Refactor: Implement ReCreateGeometries as Visitor

parent efa04ffb
......@@ -90,7 +90,7 @@ public abstract class AbstractBuilding extends CityObject {
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
......@@ -103,38 +103,21 @@ public abstract class AbstractBuilding extends CityObject {
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);
}
for (Storey storey : buildingStoreys) {
storey.reCreateGeometries(factory, config);
}
for (BuildingUnit bu : buildingUnits) {
bu.reCreateGeometries(factory, config);
}
removeEmptyBoundarySurfaces();
}
private void reCreateBoundarySurface(GeometryFactory factory, ParserConfiguration config, BoundarySurface bs) {
if (bs.getGeometries().isEmpty()) {
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);
break;
private void removeEmptyBoundarySurfaces() {
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.getGeometries().isEmpty()) {
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);
break;
}
}
}
return;
}
bs.reCreateGeometries(factory, config);
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
......
......@@ -75,7 +75,7 @@ public abstract class AbstractBuildingSubdivision extends CityObject {
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
......@@ -88,32 +88,21 @@ public abstract class AbstractBuildingSubdivision extends CityObject {
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);
}
removeEmptyBoundarySurfaces();
}
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;
private void removeEmptyBoundarySurfaces() {
for (BoundarySurface bs : boundarySurfaceList) {
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-subdivision", bs.getGmlId());
abs.getBoundaries().remove(bsp);
break;
}
}
}
return;
}
bs.reCreateGeometries(factory, config);
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
......
......@@ -70,7 +70,7 @@ public abstract class AbstractFurniture extends CityObject {
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
......
......@@ -60,7 +60,7 @@ public abstract class AbstractRoom extends CityObject {
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
......@@ -73,12 +73,6 @@ public abstract class AbstractRoom extends CityObject {
setSolidAccordingToLod(geom, solid);
}
}
for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.reCreateGeometries(factory, config);
}
for (Installation roomInstallation : roomInstallations) {
roomInstallation.reCreateGeometries(factory, config);
}
}
......
......@@ -72,7 +72,7 @@ public abstract class AbstractTunnel extends CityObject {
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
......@@ -85,38 +85,21 @@ public abstract class AbstractTunnel extends CityObject {
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);
}
removeEmptyBoundarySurfaces();
}
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;
private void removeEmptyBoundarySurfaces() {
for (BoundarySurface bs : boundarySurfaceList) {
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 tunnel", bs.getGmlId());
at.getBoundaries().remove(bsp);
break;
}
}
}
return;
}
bs.reCreateGeometries(factory, config);
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
......
......@@ -25,6 +25,7 @@ import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import javafx.scene.paint.Color;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.model.core.AbstractThematicSurface;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
......@@ -101,7 +102,7 @@ public class BoundarySurface extends CityObject {
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
if (gmlObject.getId() == null) {
gmlObject.setId(getGmlId().getGmlString());
}
......@@ -118,9 +119,6 @@ public class BoundarySurface extends CityObject {
throw new IllegalStateException("BoundarySurfaces can only have MultiSurface geometries");
}
}
for (Opening o : openings) {
o.reCreateGeometries(factory, config);
}
}
private void setGeometryAccordingToLod(Lod lod, MultiSurfaceProperty ms) {
......
......@@ -77,7 +77,7 @@ public class BridgeConstructiveElement extends CityObject {
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
// only handles CityGML2 for now
// unknown which CityGML is handled here
// need context information to decide
......@@ -100,9 +100,6 @@ public class BridgeConstructiveElement extends CityObject {
break;
}
}
for (BoundarySurface bs : boundarySurfaceList) {
reCreateBoundarySurface(factory, config, bs);
}
}
@Override
......
......@@ -26,6 +26,8 @@ import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import javafx.scene.paint.Color;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.bridge.AbstractBridge;
import org.citygml4j.core.model.bridge.BridgeInstallation;
import org.citygml4j.core.model.bridge.BridgeInstallationProperty;
......@@ -49,6 +51,9 @@ public class BridgeObject extends CityObject {
@Serial
private static final long serialVersionUID = 6301112640328373842L;
private static final Logger logger = LogManager.getLogger(BridgeObject.class);
private final List<BridgeObject> parts = new ArrayList<>(2);
private final List<BridgeConstructiveElement> elements = new ArrayList<>(2);
private final List<BoundarySurface> boundarySurfaces = new ArrayList<>(2);
......@@ -104,7 +109,7 @@ public class BridgeObject extends CityObject {
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
......@@ -117,25 +122,21 @@ public class BridgeObject extends CityObject {
setSolidAccordingToLod(geom, solid);
}
}
removeEmptyBoundarySurfaces();
}
private void removeEmptyBoundarySurfaces() {
for (BoundarySurface bs : boundarySurfaces) {
bs.reCreateGeometries(factory, config);
}
for (Installation bi : bridgeInstallations) {
bi.reCreateGeometries(factory, config);
}
for (BridgeObject part : parts) {
part.reCreateGeometries(factory, config);
}
for (BridgeConstructiveElement ele : elements) {
ele.reCreateGeometries(factory, config);
}
for (BridgeRoom br : bridgeRooms) {
br.reCreateGeometries(factory, config);
}
for (BridgeRoomFurniture bri : bridgeFurniture) {
bri.reCreateGeometries(factory, config);
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : ab.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from bridge", bs.getGmlId());
ab.getBoundaries().remove(bsp);
break;
}
}
}
}
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
......
......@@ -43,13 +43,6 @@ public class Building extends AbstractBuilding {
return buildingParts;
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config);
for (BuildingPart bp : buildingParts) {
bp.reCreateGeometries(factory, config);
}
}
@Override
public CityObject getTopLevelCityObject() {
......
......@@ -26,7 +26,7 @@ public class BuildingUnit extends AbstractBuildingSubdivision {
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config);
for (Storey storey : storeys) {
storey.reCreateGeometries(factory, config);
......
......@@ -62,7 +62,7 @@ public class CityFurniture extends CityObject {
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
......
......@@ -23,6 +23,7 @@ import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import de.hft.stuttgart.citydoctor2.utils.visitors.GmlGeometryRebuilder;
import de.hft.stuttgart.citydoctor2.utils.visitors.UnsetGeometriesVisitor;
import javafx.scene.paint.Color;
import org.citygml4j.core.model.core.AbstractCityObject;
......@@ -48,6 +49,7 @@ public abstract class CityObject extends GmlElement {
private final List<Geometry> geometryList = new ArrayList<>();
private final List<GenericAttribute> genericAttributeList = new ArrayList<>();
/**
* Recreates the CityGML4j geometry in this object. The CityGML4j geometry is
* deleted from the data structure as was mapped to the city doctor data
......@@ -59,7 +61,11 @@ public abstract class CityObject extends GmlElement {
* transformed to a different coordinate system. It would need to
* be transformed to the original coordinate system
*/
public abstract void reCreateGeometries(GeometryFactory factory, ParserConfiguration config);
public final void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
this.accept(new GmlGeometryRebuilder(factory, config));
}
public abstract void rebuildGeometries(GeometryFactory factory, ParserConfiguration config);
/**
* Getter for the CityGML4j data object
......
......@@ -47,7 +47,7 @@ public class GenericCityObject extends CityObject {
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
......@@ -60,23 +60,21 @@ public class GenericCityObject extends CityObject {
setSolidAccordingToLod(geom, solid);
}
}
for (BoundarySurface bs : boundarySurfaceList) {
reCreateBoundarySurface(factory, config, bs);
}
removeEmptyBoundarySurfaces();
}
private void reCreateBoundarySurface(GeometryFactory factory, ParserConfiguration config, BoundarySurface bs) {
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : cgmlGos.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from generic object", bs.getGmlId());
cgmlGos.getBoundaries().remove(bsp);
break;
private void removeEmptyBoundarySurfaces() {
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : cgmlGos.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from feature", bs.getGmlId());
cgmlGos.getBoundaries().remove(bsp);
break;
}
}
}
return;
}
bs.reCreateGeometries(factory, config);
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
......
......@@ -25,6 +25,8 @@ import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import javafx.scene.paint.Color;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.bridge.BridgeInstallation;
import org.citygml4j.core.model.construction.AbstractInstallation;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
......@@ -45,13 +47,15 @@ public class Installation extends CityObject {
@Serial
private static final long serialVersionUID = 1576237433322680191L;
private static final Logger logger = LogManager.getLogger(Installation.class);
private List<BoundarySurface> boundarySurfaces = new ArrayList<>(4);
private AbstractInstallation gmlBi;
private CityObject parent;
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
......@@ -67,8 +71,20 @@ public class Installation extends CityObject {
throw new IllegalStateException("BuildingInstallation not have Solid geometries");
}
}
removeEmptyBoundarySurfaces();
}
private void removeEmptyBoundarySurfaces() {
for (BoundarySurface bs : boundarySurfaces) {
bs.reCreateGeometries(factory, config);
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : gmlBi.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from feature", bs.getGmlId());
gmlBi.getBoundaries().remove(bsp);
break;
}
}
}
}
}
......
......@@ -48,7 +48,7 @@ public class LandObject extends CityObject {
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
......@@ -104,6 +104,7 @@ public class LandObject extends CityObject {
@Override
public void unsetGmlGeometries() {
lu.setLod0MultiCurve(null);
lu.setLod0MultiSurface(null);
lu.setLod1MultiSurface(null);
lu.setLod2MultiSurface(null);
......
......@@ -61,7 +61,7 @@ public class Opening extends CityObject {
this.ao = ao;
}
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
if (ao.getId() != null) {
ao.setId(getGmlId().getGmlString());
}
......
......@@ -82,7 +82,7 @@ public class ReliefObject extends CityObject {
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
// no geometries
}
......
......@@ -25,7 +25,7 @@ public class Storey extends AbstractBuildingSubdivision {
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config);
for (BuildingUnit buildingUnit : buildingUnits) {
buildingUnit.reCreateGeometries(factory, config);
......
......@@ -62,7 +62,7 @@ public class TinObject extends CityObject {
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
if (getGeometries().isEmpty()) {
return;
}
......
......@@ -80,17 +80,6 @@ public class TopLevelTransportFeature extends TransportationSpace {
return intersections;
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config);
for (TransportSection section : sections) {
section.reCreateGeometries(factory, config);
}
for (TransportSection section : intersections) {
section.reCreateGeometries(factory, config);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
......
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