Commit 8edfe8d6 authored by Luna Riegel's avatar Luna Riegel
Browse files

Fix: Add OtherConstructionObject to mapper

parent ab1681b7
...@@ -154,6 +154,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -154,6 +154,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param checkable a checkable * @param checkable a checkable
*/ */
@Override
public void check(Checkable checkable) { public void check(Checkable checkable) {
} }
...@@ -163,6 +164,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -163,6 +164,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param ab building or building part * @param ab building or building part
*/ */
@Override
public void check(AbstractBuilding ab) { public void check(AbstractBuilding ab) {
} }
...@@ -172,6 +174,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -172,6 +174,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param bs a boundary surface * @param bs a boundary surface
*/ */
@Override
public void check(BoundarySurface bs) { public void check(BoundarySurface bs) {
} }
...@@ -181,6 +184,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -181,6 +184,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param bo a bridge * @param bo a bridge
*/ */
@Override
public void check(BridgeObject bo) { public void check(BridgeObject bo) {
} }
...@@ -190,6 +194,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -190,6 +194,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param b a building * @param b a building
*/ */
@Override
public void check(Building b) { public void check(Building b) {
} }
...@@ -199,6 +204,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -199,6 +204,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param bi a building installation * @param bi a building installation
*/ */
@Override
public void check(Installation bi) { public void check(Installation bi) {
} }
...@@ -208,6 +214,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -208,6 +214,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param bp a building part * @param bp a building part
*/ */
@Override
public void check(BuildingPart bp) { public void check(BuildingPart bp) {
} }
...@@ -217,6 +224,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -217,6 +224,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param co a city object * @param co a city object
*/ */
@Override
public void check(CityObject co) { public void check(CityObject co) {
} }
...@@ -226,6 +234,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -226,6 +234,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param lo a land use object * @param lo a land use object
*/ */
@Override
public void check(LandObject lo) { public void check(LandObject lo) {
} }
...@@ -235,6 +244,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -235,6 +244,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param o an opening * @param o an opening
*/ */
@Override
public void check(Opening o) { public void check(Opening o) {
} }
...@@ -244,6 +254,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -244,6 +254,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param to a transportation object * @param to a transportation object
*/ */
@Override
public void check(TransportationObject to) { public void check(TransportationObject to) {
} }
...@@ -253,6 +264,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -253,6 +264,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param veg a vegetation object * @param veg a vegetation object
*/ */
@Override
public void check(Vegetation veg) { public void check(Vegetation veg) {
} }
...@@ -262,6 +274,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -262,6 +274,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param wo a water object * @param wo a water object
*/ */
@Override
public void check(WaterObject wo) { public void check(WaterObject wo) {
} }
...@@ -271,6 +284,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -271,6 +284,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param geom a geometry * @param geom a geometry
*/ */
@Override
public void check(Geometry geom) { public void check(Geometry geom) {
} }
...@@ -280,6 +294,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -280,6 +294,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param poly a polygon * @param poly a polygon
*/ */
@Override
public void check(Polygon poly) { public void check(Polygon poly) {
} }
...@@ -289,26 +304,36 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -289,26 +304,36 @@ public abstract non-sealed class Check implements CheckableVisitor {
* *
* @param ring a linear ring * @param ring a linear ring
*/ */
@Override
public void check(LinearRing ring) { public void check(LinearRing ring) {
} }
@Override
public void check(TinObject tin) { public void check(TinObject tin) {
} }
@Override
public void check(ReliefObject relief) { public void check(ReliefObject relief) {
} }
@Override
public void check(CityFurniture cf){ public void check(CityFurniture cf){
} }
@Override
public void check(GenericCityObject gco) { public void check(GenericCityObject gco) {
} }
@Override
public void check(OtherConstructionObject oco){
}
/** /**
* 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
......
...@@ -31,6 +31,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.Installation; ...@@ -31,6 +31,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.Installation;
import de.hft.stuttgart.citydoctor2.datastructure.LandObject; import de.hft.stuttgart.citydoctor2.datastructure.LandObject;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing; import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.Opening; import de.hft.stuttgart.citydoctor2.datastructure.Opening;
import de.hft.stuttgart.citydoctor2.datastructure.OtherConstructionObject;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon; import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.ReliefObject; import de.hft.stuttgart.citydoctor2.datastructure.ReliefObject;
import de.hft.stuttgart.citydoctor2.datastructure.TinObject; import de.hft.stuttgart.citydoctor2.datastructure.TinObject;
...@@ -165,4 +166,8 @@ public abstract non-sealed class CheckableUtilsVisitor implements CheckableVisit ...@@ -165,4 +166,8 @@ public abstract non-sealed class CheckableUtilsVisitor implements CheckableVisit
} }
@Override
public void check(OtherConstructionObject oco){
}
} }
...@@ -13,6 +13,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.Installation; ...@@ -13,6 +13,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.Installation;
import de.hft.stuttgart.citydoctor2.datastructure.LandObject; import de.hft.stuttgart.citydoctor2.datastructure.LandObject;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing; import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.Opening; import de.hft.stuttgart.citydoctor2.datastructure.Opening;
import de.hft.stuttgart.citydoctor2.datastructure.OtherConstructionObject;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon; import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.ReliefObject; import de.hft.stuttgart.citydoctor2.datastructure.ReliefObject;
import de.hft.stuttgart.citydoctor2.datastructure.TinObject; import de.hft.stuttgart.citydoctor2.datastructure.TinObject;
...@@ -69,4 +70,6 @@ public sealed interface CheckableVisitor permits Check, CheckableUtilsVisitor { ...@@ -69,4 +70,6 @@ public sealed interface CheckableVisitor permits Check, CheckableUtilsVisitor {
void check(GenericCityObject gco); void check(GenericCityObject gco);
void check(OtherConstructionObject oco);
} }
...@@ -27,5 +27,5 @@ public enum FeatureType { ...@@ -27,5 +27,5 @@ public enum FeatureType {
BUILDING, TRANSPORTATION, VEGETATION, BRIDGE, LAND, WATER, BOUNDARY_SURFACE, INSTALLATION, OPENING, BUILDING, TRANSPORTATION, VEGETATION, BRIDGE, LAND, WATER, BOUNDARY_SURFACE, INSTALLATION, OPENING,
BUILDING_PART, BUILDING_SUBDIVISION, BRIDGE_CONSTRUCTION_ELEMENT, BRIDGE_INSTALLATION, ROOM, FURNITURE, CITY_FURNITURE, BUILDING_PART, BUILDING_SUBDIVISION, BRIDGE_CONSTRUCTION_ELEMENT, BRIDGE_INSTALLATION, ROOM, FURNITURE, CITY_FURNITURE,
GENERIC_CITY_OBJECT, TUNNEL, TUNNEL_PART, TUNNEL_CONSTRUCTION_ELEMENT, TUNNEL_INSTALLATION, OTHER_CITY_OBJECT, TUNNEL, TUNNEL_PART, TUNNEL_CONSTRUCTION_ELEMENT, TUNNEL_INSTALLATION,
} }
...@@ -111,7 +111,7 @@ public class GenericCityObject extends CityObject { ...@@ -111,7 +111,7 @@ public class GenericCityObject extends CityObject {
cgmlGos.getDeprecatedProperties().setLod4Geometry(new SolidProperty(solid)); cgmlGos.getDeprecatedProperties().setLod4Geometry(new SolidProperty(solid));
break; break;
default: default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to buildings"); throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to generic city object");
} }
} }
@Override @Override
...@@ -121,7 +121,7 @@ public class GenericCityObject extends CityObject { ...@@ -121,7 +121,7 @@ public class GenericCityObject extends CityObject {
@Override @Override
public FeatureType getFeatureType() { public FeatureType getFeatureType() {
return FeatureType.GENERIC_CITY_OBJECT; return FeatureType.OTHER_CITY_OBJECT;
} }
public List<BoundarySurface> getBoundarySurfaces() { public List<BoundarySurface> getBoundarySurfaces() {
......
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 org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.construction.OtherConstruction;
import org.citygml4j.core.model.core.AbstractCityObject;
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 class OtherConstructionObject extends CityObject{
@Serial
private static final long serialVersionUID = -3885206364978761701L;
private static final Logger logger = LogManager.getLogger(OtherConstructionObject.class);
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
private OtherConstruction gmlObject;
@Override
public void accept(CheckableVisitor c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.accept(c);
}
}
public void setGmlObject(OtherConstruction gmlObject) {
this.gmlObject = gmlObject;
}
@Override
public void rebuildGeometries(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);
}
}
removeEmptyBoundarySurfaces();
}
private void removeEmptyBoundarySurfaces() {
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : gmlObject.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from feature", bs.getGmlId());
gmlObject.getBoundaries().remove(bsp);
break;
}
}
}
}
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) {
case LOD0:
gmlObject.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
gmlObject.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
gmlObject.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to other construction object");
}
}
private void setSolidAccordingToLod(Geometry geom, Solid solid) {
switch (geom.getLod()) {
case LOD1:
gmlObject.setLod1Solid(new SolidProperty(solid));
break;
case LOD2:
gmlObject.setLod2Solid(new SolidProperty(solid));
break;
case LOD3:
gmlObject.setLod3Solid(new SolidProperty(solid));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to other construction object");
}
}
@Override
public OtherConstruction getGmlObject() {
return gmlObject;
}
@Override
public void unsetGmlGeometries() {
gmlObject.setLod0MultiSurface(null);
gmlObject.setLod2MultiSurface(null);
gmlObject.setLod3MultiSurface(null);
gmlObject.setLod1Solid(null);
gmlObject.setLod2Solid(null);
gmlObject.setLod3Solid(null);
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
@Override
public FeatureType getFeatureType() {
return FeatureType.OTHER_CITY_OBJECT;
}
public void addBoundarySurface(BoundarySurface bs) {
boundarySurfaceList.add(bs);
bs.setParent(this);
}
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaceList;
}
}
...@@ -26,6 +26,7 @@ import java.util.Map; ...@@ -26,6 +26,7 @@ import java.util.Map;
import de.hft.stuttgart.citydoctor2.database.FeatureCache; import de.hft.stuttgart.citydoctor2.database.FeatureCache;
import de.hft.stuttgart.citydoctor2.database.UnconnectedCache; import de.hft.stuttgart.citydoctor2.database.UnconnectedCache;
import de.hft.stuttgart.citydoctor2.datastructure.OtherConstructionObject;
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.CityGMLVersion; import org.citygml4j.core.model.CityGMLVersion;
...@@ -47,6 +48,7 @@ import org.citygml4j.core.model.building.BuildingRoomProperty; ...@@ -47,6 +48,7 @@ import org.citygml4j.core.model.building.BuildingRoomProperty;
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.construction.AbstractConstruction; import org.citygml4j.core.model.construction.AbstractConstruction;
import org.citygml4j.core.model.construction.OtherConstruction;
import org.citygml4j.core.model.core.AbstractCityObject; import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.model.core.AbstractFeatureWithLifespan; import org.citygml4j.core.model.core.AbstractFeatureWithLifespan;
import org.citygml4j.core.model.core.AbstractGenericAttributeProperty; import org.citygml4j.core.model.core.AbstractGenericAttributeProperty;
...@@ -202,6 +204,31 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -202,6 +204,31 @@ public class Citygml3FeatureMapper extends ObjectWalker {
} }
@Override
public void visit(OtherConstruction gmlOc){
OtherConstructionObject oco = new OtherConstructionObject();
oco.setGmlObject(gmlOc);
mapAbstractOccupiedSpace(gmlOc, oco, Orientation.OUTWARD);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlOc.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
oco.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
}
}
}
finishCityObjectConstruction(oco);
}
@Override @Override
public void visit(org.citygml4j.core.model.cityfurniture.CityFurniture gmlCityFurniture) { public void visit(org.citygml4j.core.model.cityfurniture.CityFurniture gmlCityFurniture) {
CityFurniture cf = new CityFurniture(); CityFurniture cf = new CityFurniture();
...@@ -229,7 +256,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -229,7 +256,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
} }
mapAbstractOccupiedSpace(gos, gco, Orientation.OUTWARD); mapAbstractOccupiedSpace(gos, gco, Orientation.OUTWARD);
finishCityObjectConstruction(gco); finishCityObjectConstruction(gco);
model.addGenericCityObject(gco); model.addOtherCityObject(gco);
} }
@Override @Override
......
...@@ -230,6 +230,24 @@ public class CheckContainer extends Check { ...@@ -230,6 +230,24 @@ public class CheckContainer extends Check {
} }
} }
@Override
public void check(TinObject to) {
try {
check.check(to);
}catch (Exception e) {
handleException(e, to);
}
}
@Override
public void check(ReliefObject ro) {
try {
check.check(ro);
}catch (Exception e) {
handleException(e, ro);
}
}
@Override @Override
public void check(CityFurniture cf){ public void check(CityFurniture cf){
try { try {
...@@ -248,6 +266,15 @@ public class CheckContainer extends Check { ...@@ -248,6 +266,15 @@ public class CheckContainer extends Check {
} }
} }
@Override
public void check(OtherConstructionObject oco) {
try {
check.check(oco);
}catch (Exception e) {
handleException(e, oco);
}
}
@Override @Override
public RequirementType getType() { public RequirementType getType() {
return check.getType(); return check.getType();
......
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