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