Commit 03fbe199 authored by Luna Riegel's avatar Luna Riegel
Browse files

Refactor: Unify and generalize CityGml3FeatureMapper

parent 8abf5e03
Pipeline #12357 failed with stage
in 1 minute and 17 seconds
......@@ -9,18 +9,17 @@ public class TunnelPart extends AbstractTunnel {
private Tunnel parent;
private TunnelPart() {
}
public TunnelPart(Tunnel parent) {
this.parent = parent;
parent.addTunnelPart(this);
public TunnelPart() {
}
public Tunnel getParent() {
return parent;
}
public void setParent(Tunnel parent) {
this.parent = parent;
}
@Override
public CityObject getTopLevelCityObject() {
return getParent().getTopLevelCityObject();
......
......@@ -24,11 +24,21 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import java.util.stream.Collectors;
import de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor;
import de.hft.stuttgart.citydoctor2.database.FeatureCache;
import de.hft.stuttgart.citydoctor2.database.UnconnectedCache;
import de.hft.stuttgart.citydoctor2.datastructure.AbstractBridgeObject;
import de.hft.stuttgart.citydoctor2.datastructure.AbstractBuildingSubdivision;
import de.hft.stuttgart.citydoctor2.datastructure.AbstractConstructiveFillingElement;
import de.hft.stuttgart.citydoctor2.datastructure.AbstractFurniture;
import de.hft.stuttgart.citydoctor2.datastructure.BoundedSpace;
import de.hft.stuttgart.citydoctor2.datastructure.BoundingBox;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeObjectPart;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeRoom;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeRoomFurniture;
import de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement;
import de.hft.stuttgart.citydoctor2.datastructure.DoorObject;
import de.hft.stuttgart.citydoctor2.datastructure.FeatureType;
import de.hft.stuttgart.citydoctor2.datastructure.OtherConstructionObject;
......@@ -39,12 +49,13 @@ import org.citygml4j.core.model.CityGMLVersion;
import org.citygml4j.core.model.bridge.AbstractBridge;
import org.citygml4j.core.model.bridge.Bridge;
import org.citygml4j.core.model.bridge.BridgeConstructiveElementProperty;
import org.citygml4j.core.model.bridge.BridgeFurniture;
import org.citygml4j.core.model.bridge.BridgeFurnitureProperty;
import org.citygml4j.core.model.bridge.BridgeInstallation;
import org.citygml4j.core.model.bridge.BridgeInstallationProperty;
import org.citygml4j.core.model.bridge.BridgePart;
import org.citygml4j.core.model.bridge.BridgePartProperty;
import org.citygml4j.core.model.bridge.BridgeRoomProperty;
import org.citygml4j.core.model.building.AbstractBuildingSubdivisionProperty;
import org.citygml4j.core.model.building.BuildingConstructiveElement;
import org.citygml4j.core.model.building.BuildingConstructiveElementProperty;
import org.citygml4j.core.model.building.BuildingFurniture;
import org.citygml4j.core.model.building.BuildingFurnitureProperty;
......@@ -52,11 +63,13 @@ import org.citygml4j.core.model.building.BuildingInstallationProperty;
import org.citygml4j.core.model.building.BuildingPartProperty;
import org.citygml4j.core.model.building.BuildingRoomProperty;
import org.citygml4j.core.model.building.BuildingUnit;
import org.citygml4j.core.model.building.BuildingUnitProperty;
import org.citygml4j.core.model.building.Storey;
import org.citygml4j.core.model.construction.AbstractConstruction;
import org.citygml4j.core.model.building.StoreyProperty;
import org.citygml4j.core.model.construction.AbstractConstructiveElement;
import org.citygml4j.core.model.construction.AbstractFillingElement;
import org.citygml4j.core.model.construction.AbstractFillingElementProperty;
import org.citygml4j.core.model.construction.AbstractInstallation;
import org.citygml4j.core.model.construction.Door;
import org.citygml4j.core.model.construction.OtherConstruction;
import org.citygml4j.core.model.construction.Window;
......@@ -249,119 +262,100 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
@Override
public void visit(OtherConstruction gmlOc){
OtherConstructionObject oco = new OtherConstructionObject();
oco.setGmlObject(gmlOc);
mapAbstractOccupiedSpace(gmlOc, oco, Orientation.OUTWARD);
public void visit(OtherConstruction gmlOtherConstruction){
OtherConstructionObject cdOtherConstruction = new OtherConstructionObject();
cdOtherConstruction.setGmlObject(gmlOtherConstruction);
mapAbstractOccupiedSpace(gmlOtherConstruction, cdOtherConstruction, Orientation.OUTWARD);
mapBoundedSpace(gmlOtherConstruction, cdOtherConstruction);
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);
model.addOtherCityObject(oco);
finishFeatureConstruction(cdOtherConstruction);
model.addOtherCityObject(cdOtherConstruction);
}
@Override
public void visit(org.citygml4j.core.model.cityfurniture.CityFurniture gmlCityFurniture) {
CityFurniture cf = new CityFurniture();
cf.setGmlObject(gmlCityFurniture);
mapAbstractOccupiedSpace(gmlCityFurniture, cf, Orientation.OUTWARD);
finishCityObjectConstruction(cf);
model.addCityFurniture(cf);
CityFurniture cdCityFurniture = new CityFurniture();
cdCityFurniture.setGmlObject(gmlCityFurniture);
mapAbstractOccupiedSpace(gmlCityFurniture, cdCityFurniture, Orientation.OUTWARD);
mapBoundedSpace(gmlCityFurniture, cdCityFurniture);
var dProp = gmlCityFurniture.getDeprecatedProperties();
parseAndAddAbstractGeometry(dProp.getLod1Geometry(), Lod.LOD1, cdCityFurniture, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod2Geometry(), Lod.LOD2, cdCityFurniture, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod3Geometry(), Lod.LOD3, cdCityFurniture, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod4Geometry(), Lod.LOD4, cdCityFurniture, Orientation.OUTWARD);
finishFeatureConstruction(cdCityFurniture);
model.addCityFurniture(cdCityFurniture);
}
@Override
public void visit(org.citygml4j.core.model.generics.GenericOccupiedSpace gos) {
GenericCityObject gco = new GenericCityObject();
gco.setGmlObject(gos);
GeometryProperty<?> agLod1 = gos.getDeprecatedProperties().getLod1Geometry();
GeometryProperty<?> agLod4 = gos.getDeprecatedProperties().getLod4Geometry();
if (agLod1 != null && agLod1.getObject() != null && agLod1.getObject() instanceof MultiSurface ms) {
gco.addGeometry(parseMultiSurface(ms, Lod.LOD1));
}
if (agLod4 != null && agLod4.getObject() != null) {
if (agLod4.getObject() instanceof MultiSurface ms) {
gco.addGeometry(parseMultiSurface(ms, Lod.LOD4));
} else if (agLod4.getObject() instanceof AbstractSolid solid) {
gco.addGeometry(parseSolid(solid, Lod.LOD4, Orientation.OUTWARD));
}
}
mapAbstractOccupiedSpace(gos, gco, Orientation.OUTWARD);
finishCityObjectConstruction(gco);
model.addOtherCityObject(gco);
public void visit(org.citygml4j.core.model.generics.GenericOccupiedSpace gmlGenericOccupiedSpace) {
GenericCityObject cdGenericOccupiedSpace = new GenericCityObject();
cdGenericOccupiedSpace.setGmlObject(gmlGenericOccupiedSpace);
mapAbstractOccupiedSpace(gmlGenericOccupiedSpace, cdGenericOccupiedSpace, Orientation.OUTWARD);
mapBoundedSpace(gmlGenericOccupiedSpace, cdGenericOccupiedSpace);
var dProp = gmlGenericOccupiedSpace.getDeprecatedProperties();
parseAndAddAbstractGeometry(dProp.getLod0Geometry(), Lod.LOD0, cdGenericOccupiedSpace, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod1Geometry(), Lod.LOD1, cdGenericOccupiedSpace, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod2Geometry(), Lod.LOD2, cdGenericOccupiedSpace, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod3Geometry(), Lod.LOD3, cdGenericOccupiedSpace, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod4Geometry(), Lod.LOD4, cdGenericOccupiedSpace, Orientation.OUTWARD);
finishFeatureConstruction(cdGenericOccupiedSpace);
model.addOtherCityObject(cdGenericOccupiedSpace);
}
@Override
public void visit(org.citygml4j.core.model.building.Building gmlBuilding) {
Building cdBuilding = new Building();
readAbstractBuilding(gmlBuilding, cdBuilding);
mapAbstractBuilding(gmlBuilding, cdBuilding);
for (BuildingPartProperty bpProp : gmlBuilding.getBuildingParts()) {
if (!bpProp.isSetObject()) {
continue;
}
BuildingPart part = new BuildingPart(cdBuilding);
readAbstractBuilding(bpProp.getObject(), part);
mapAbstractBuilding(bpProp.getObject(), part);
cdBuilding.addBuildingPart(part);
}
finishCityObjectConstruction(cdBuilding);
finishFeatureConstruction(cdBuilding);
model.addBuilding(cdBuilding);
}
@Override
public void visit(WaterBody waterBody) {
WaterObject wo = new WaterObject();
wo.setGmlObject(waterBody);
mapAbstractOccupiedSpace(waterBody, wo, Orientation.OUTWARD);
parseAndAddMultiSurface(waterBody.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, wo);
parseAndAddSolid(waterBody.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, wo, Orientation.OUTWARD);
WaterObject cdWaterObject = new WaterObject();
cdWaterObject.setGmlObject(waterBody);
mapAbstractOccupiedSpace(waterBody, cdWaterObject, Orientation.OUTWARD);
mapBoundedSpace(waterBody, cdWaterObject);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : waterBody.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
wo.addBoundarySurface(bs);
}
var dProp = waterBody.getDeprecatedProperties();
parseAndAddMultiSurface(dProp.getLod1MultiSurface(), Lod.LOD1, cdWaterObject);
parseAndAddSolid(dProp.getLod4Solid(), Lod.LOD4, cdWaterObject, Orientation.OUTWARD);
finishCityObjectConstruction(wo);
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
updateEdgesAndVertices(bs);
}
model.addWater(wo);
finishFeatureConstruction(cdWaterObject);
model.addWater(cdWaterObject);
}
@Override
public void visit(LandUse landUse) {
LandObject lo = new LandObject(landUse);
public void visit(LandUse gmlLandUse) {
LandObject cdLandObject = new LandObject(gmlLandUse);
mapAbstractThematicSurface(landUse, lo);
mapAbstractThematicSurface(gmlLandUse, cdLandObject);
finishCityObjectConstruction(lo);
model.addLand(lo);
finishFeatureConstruction(cdLandObject);
model.addLand(cdLandObject);
}
public void visit(ReliefFeature relief) {
ReliefObject ro = new ReliefObject(relief);
mapAbstractSpaceBoundary(relief, ro);
mapReliefFeature(relief, ro);
finishCityObjectConstruction(ro);
model.addRelief(ro);
@Override
public void visit(ReliefFeature gmlRelief) {
ReliefObject cdRelief = new ReliefObject(gmlRelief);
mapAbstractSpaceBoundary(gmlRelief, cdRelief);
mapReliefFeature(gmlRelief, cdRelief);
finishFeatureConstruction(cdRelief);
model.addRelief(cdRelief);
}
public void mapReliefFeature(ReliefFeature relief, ReliefObject reliefObject) {
......@@ -423,10 +417,11 @@ public class Citygml3FeatureMapper extends ObjectWalker {
veg.setGmlObject(plantCover);
mapAbstractVegetationObject(plantCover, veg);
parseAndAddMultiSurface(plantCover.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, veg);
parseAndAddMultiSurface(plantCover.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, veg);
var dProp = plantCover.getDeprecatedProperties();
parseAndAddMultiSurface(dProp.getLod1MultiSurface(), Lod.LOD1, veg);
parseAndAddMultiSurface(dProp.getLod4MultiSurface(), Lod.LOD4, veg);
finishCityObjectConstruction(veg);
finishFeatureConstruction(veg);
model.addVegetation(veg);
}
......@@ -436,21 +431,19 @@ public class Citygml3FeatureMapper extends ObjectWalker {
veg.setGmlObject(solitaryVegetationObject);
mapAbstractVegetationObject(solitaryVegetationObject, veg);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod1Geometry(), Lod.LOD1,
veg, Orientation.OUTWARD);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod2Geometry(), Lod.LOD2,
veg, Orientation.OUTWARD);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod3Geometry(), Lod.LOD3,
veg, Orientation.OUTWARD);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod4Geometry(), Lod.LOD4,
veg, Orientation.OUTWARD);
var dProp = solitaryVegetationObject.getDeprecatedProperties();
parseAndAddAbstractGeometry(dProp.getLod1Geometry(), Lod.LOD1, veg, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod2Geometry(), Lod.LOD2, veg, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod3Geometry(), Lod.LOD3, veg, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod4Geometry(), Lod.LOD4, veg, Orientation.OUTWARD);
finishCityObjectConstruction(veg);
finishFeatureConstruction(veg);
model.addVegetation(veg);
}
private void mapAbstractVegetationObject(AbstractVegetationObject avo, Vegetation veg) {
mapAbstractOccupiedSpace(avo, veg, Orientation.OUTWARD);
mapBoundedSpace(avo, veg);
}
private void mapAbstractOccupiedSpace(AbstractOccupiedSpace aos, CityObject co, Orientation orientation) {
......@@ -482,404 +475,314 @@ public class Citygml3FeatureMapper extends ObjectWalker {
@Override
public void visit(Bridge bridge) {
BridgeObject bo = new BridgeObject(bridge);
// parse deprecated geometries
parseAndAddMultiSurface(bridge.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, bo);
parseAndAddMultiSurface(bridge.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, bo);
parseAndAddSolid(bridge.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, bo, Orientation.OUTWARD);
mapAbstractBridge(bridge, bo);
for (BridgePartProperty bPartProperty : bridge.getBridgeParts()) {
if (!bPartProperty.isSetObject()) {
var gmlPart = bPartProperty.getObject();
if (gmlPart == null) {
continue;
}
BridgePart gmlBridgePart = bPartProperty.getObject();
BridgeObject bPart = new BridgeObject(gmlBridgePart, bo);
mapAbstractBridge(gmlBridgePart, bPart);
BridgeObjectPart bPart = new BridgeObjectPart(gmlPart);
mapAbstractBridge(gmlPart, bPart);
bo.addBridgePart(bPart);
}
finishCityObjectConstruction(bo);
for (BridgeObject part : bo.getParts()) {
updateEdgesAndVertices(part);
}
for (BridgeConstructiveElement ele : bo.getConstructiveElements()) {
updateEdgesAndVertices(ele);
for (BoundarySurface bs : ele.getBoundarySurfaces()) {
updateEdgesAndVertices(bs);
}
}
for (Installation bi : bo.getBridgeInstallations()) {
updateEdgesAndVertices(bi);
for (BoundarySurface bs : bi.getBoundarySurfaces()) {
updateEdgesAndVertices(bs);
}
}
finishFeatureConstruction(bo);
model.addBridge(bo);
}
private void mapAbstractBridge(AbstractBridge ab, BridgeObject bo) {
mapAbstractConstruction(ab, bo);
for (BridgeConstructiveElementProperty eleProp : ab.getBridgeConstructiveElements()) {
if (!eleProp.isSetObject()) {
private void mapAbstractBridge(AbstractBridge gmlBridge, AbstractBridgeObject cdBridge) {
mapAbstractOccupiedSpace(gmlBridge, cdBridge, Orientation.OUTWARD);
mapBoundedSpace(gmlBridge, cdBridge);
var dProp = gmlBridge.getDeprecatedProperties();
parseAndAddMultiSurface(dProp.getLod1MultiSurface(), Lod.LOD1, cdBridge);
parseAndAddMultiSurface(dProp.getLod4MultiSurface(), Lod.LOD4, cdBridge);
parseAndAddSolid(dProp.getLod4Solid(), Lod.LOD4, cdBridge, Orientation.OUTWARD);
List<de.hft.stuttgart.citydoctor2.datastructure.BridgeConstructiveElement> elements =
readBridgeConstructiveElementProperties(gmlBridge.getBridgeConstructiveElements());
elements.forEach(cdBridge::addConstructiveElement);
List<BridgeRoomFurniture> furniture = readBridgeFurnitureProperties(gmlBridge.getBridgeFurniture());
furniture.forEach(cdBridge::addFurniture);
List<Installation> installations = readBridgeInstallationProperties(gmlBridge.getBridgeInstallations());
installations.forEach(cdBridge::addInstallation);
List<BridgeRoom> rooms = readBridgeRoomProperties(gmlBridge.getBridgeRooms());
rooms.forEach(cdBridge::addRoom);
}
private List<de.hft.stuttgart.citydoctor2.datastructure.BridgeConstructiveElement>
readBridgeConstructiveElementProperties(List<BridgeConstructiveElementProperty> properties){
List<de.hft.stuttgart.citydoctor2.datastructure.BridgeConstructiveElement> elements = new ArrayList<>();
for (BridgeConstructiveElementProperty eleProp : properties) {
var gmlBce = eleProp.getObject();
if (gmlBce == null) {
continue;
}
org.citygml4j.core.model.bridge.BridgeConstructiveElement constructiveElement = eleProp.getObject();
BridgeConstructiveElement cdEle = new BridgeConstructiveElement(constructiveElement);
mapConstructiveElement(constructiveElement, cdEle);
bo.addConstructiveElement(cdEle);
BridgeConstructiveElement cdEle = parseBridgeConstructiveElement(gmlBce);
elements.add(cdEle);
}
return elements;
}
List<BridgeInstallationProperty> bridgeInstallations = ab.getBridgeInstallations();
for (BridgeInstallationProperty installationProp : bridgeInstallations) {
var gmlBi = installationProp.getObject();
if (gmlBi == null) {
// ignore empty properties
private List<Installation> readBridgeInstallationProperties(List<BridgeInstallationProperty> properties){
List<Installation> installations = new ArrayList<>();
for (BridgeInstallationProperty installationProp : properties) {
var gmlBce = installationProp.getObject();
if (gmlBce == null) {
continue;
}
Installation bi = mapBridgeInstallation(gmlBi);
bo.addBridgeInstallation(bi);
Installation inst = parseBridgeInstallation(gmlBce);
installations.add(inst);
}
return installations;
}
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : ab.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
private List<BridgeRoom> readBridgeRoomProperties(List<BridgeRoomProperty> properties){
List<BridgeRoom> rooms = new ArrayList<>();
for (BridgeRoomProperty roomProp : properties) {
var gmlRoom = roomProp.getObject();
if (gmlRoom == null) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
updatePartOfSurface(bo, surfaceMapper);
for (BoundarySurface bs : bo.getBoundarySurfaces()) {
updateEdgesAndVertices(bs);
BridgeRoom room = parseBridgeRoom(gmlRoom);
rooms.add(room);
}
return rooms;
}
private Installation mapBridgeInstallation(BridgeInstallation gmlBi) {
Installation bi = new Installation();
bi.setGmlObject(gmlBi);
mapAbstractOccupiedSpace(gmlBi, bi, Orientation.OUTWARD);
GeometryProperty<?> lod2Prop = gmlBi.getDeprecatedProperties().getLod2Geometry();
parseAndAddAbstractGeometry(lod2Prop, Lod.LOD2, bi, Orientation.OUTWARD);
GeometryProperty<?> lod3Prop = gmlBi.getDeprecatedProperties().getLod3Geometry();
parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, bi, Orientation.OUTWARD);
GeometryProperty<?> lod4Prop = gmlBi.getDeprecatedProperties().getLod4Geometry();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi, Orientation.OUTWARD);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
private List<BridgeRoomFurniture> readBridgeFurnitureProperties(List<BridgeFurnitureProperty> properties){
List<BridgeRoomFurniture> rooms = new ArrayList<>();
for (BridgeFurnitureProperty furnProp : properties) {
var gmlFurn = furnProp.getObject();
if (gmlFurn == null) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
bi.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
p.setPartOfInstallation(bi);
}
}
}
for (Geometry geom : bi.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfInstallation(bi);
}
BridgeRoomFurniture furn = parseBridgeFurniture(gmlFurn);
rooms.add(furn);
}
return rooms;
}
private de.hft.stuttgart.citydoctor2.datastructure.BridgeConstructiveElement parseBridgeConstructiveElement(
org.citygml4j.core.model.bridge.BridgeConstructiveElement gmlBridgeCE){
de.hft.stuttgart.citydoctor2.datastructure.BridgeConstructiveElement cdBuildingCE = new BridgeConstructiveElement(gmlBridgeCE);
mapAbstractConstructiveElement(gmlBridgeCE, cdBuildingCE);
var dProp = gmlBridgeCE.getDeprecatedProperties();
parseAndAddAbstractGeometry(dProp.getLod1Geometry(), Lod.LOD1, cdBuildingCE, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod2Geometry(), Lod.LOD2, cdBuildingCE, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod3Geometry(), Lod.LOD3, cdBuildingCE, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod4Geometry(), Lod.LOD4, cdBuildingCE, Orientation.OUTWARD);
return bi;
return cdBuildingCE;
}
private Installation parseBridgeInstallation(BridgeInstallation gmlBridgeInst) {
Installation cdBridgeInst = new Installation();
cdBridgeInst.setGmlObject(gmlBridgeInst);
mapAbstractInstallation(gmlBridgeInst, cdBridgeInst);
var dProp = gmlBridgeInst.getDeprecatedProperties();
parseAndAddAbstractGeometry(dProp.getLod2Geometry(), Lod.LOD2, cdBridgeInst, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod3Geometry(), Lod.LOD3, cdBridgeInst, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod4Geometry(), Lod.LOD4, cdBridgeInst, Orientation.OUTWARD);
return cdBridgeInst;
}
private de.hft.stuttgart.citydoctor2.datastructure.BridgeRoom parseBridgeRoom(org.citygml4j.core.model.bridge.BridgeRoom gmlBridgeRoom) {
de.hft.stuttgart.citydoctor2.datastructure.BridgeRoom cdRoom = new BridgeRoom();
cdRoom.setGmlObject(gmlBridgeRoom);
mapAbstractUnoccupiedSpace(gmlBridgeRoom, cdRoom, Orientation.INWARD);
mapBoundedSpace(gmlBridgeRoom, cdRoom);
var dProp = gmlBridgeRoom.getDeprecatedProperties();
parseAndAddMultiSurface(dProp.getLod4MultiSurface(), Lod.LOD4, cdRoom);
parseAndAddSolid(dProp.getLod4Solid(), Lod.LOD4, cdRoom, Orientation.INWARD);
List<BridgeRoomFurniture> furniture = readBridgeFurnitureProperties(gmlBridgeRoom.getBridgeFurniture());
furniture.forEach(cdRoom::addFurniture);
List<Installation> installations = readBridgeInstallationProperties(gmlBridgeRoom.getBridgeInstallations());
installations.forEach(cdRoom::addInstallation);
return cdRoom;
}
private BridgeRoomFurniture parseBridgeFurniture(BridgeFurniture bridgeFurn) {
BridgeRoomFurniture cdFurn = new BridgeRoomFurniture();
mapAbstractFurniture(bridgeFurn, cdFurn);
var dProp = bridgeFurn.getDeprecatedProperties();
parseAndAddAbstractGeometry(dProp.getLod4Geometry(), Lod.LOD4, cdFurn, Orientation.OUTWARD);
return cdFurn;
}
@Override
public void visit(Tunnel tunnel) {
de.hft.stuttgart.citydoctor2.datastructure.Tunnel tu = new de.hft.stuttgart.citydoctor2.datastructure.Tunnel();
de.hft.stuttgart.citydoctor2.datastructure.Tunnel cdTunnel = new de.hft.stuttgart.citydoctor2.datastructure.Tunnel();
mapAbstractTunnel(tunnel, cdTunnel);
for (TunnelPartProperty tPartProperty : tunnel.getTunnelParts()) {
if (!tPartProperty.isSetObject()) {
var gmlTunnelpart = tPartProperty.getObject();
if (gmlTunnelpart == null) {
continue;
}
org.citygml4j.core.model.tunnel.TunnelPart gmlTunnelPart = tPartProperty.getObject();
TunnelPart tPart = new TunnelPart(tu);
readAbstractTunnel(gmlTunnelPart, tPart);
tu.addTunnelPart(tPart);
TunnelPart cdTunnelPart = new TunnelPart();
cdTunnelPart.setParent(cdTunnel);
mapAbstractTunnel(gmlTunnelpart, cdTunnelPart);
cdTunnel.addTunnelPart(cdTunnelPart);
}
readAbstractTunnel(tunnel, tu);
finishCityObjectConstruction(tu);
for (TunnelPart part : tu.getTunnelParts()) {
updateEdgesAndVertices(part);
}
model.addTunnel(tu);
finishFeatureConstruction(cdTunnel);
model.addTunnel(cdTunnel);
}
private void readAbstractTunnel(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
mapAbstractOccupiedSpace(gmlTunnel, cdTunnel, Orientation.OUTWARD);
private void mapAbstractTunnel(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
cdTunnel.setGmlObject(gmlTunnel);
mapAbstractOccupiedSpace(gmlTunnel, cdTunnel, Orientation.OUTWARD);
mapBoundedSpace(gmlTunnel, cdTunnel);
// parse deprecated geometries
parseAndAddMultiSurface(gmlTunnel.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, cdTunnel);
parseAndAddMultiSurface(gmlTunnel.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, cdTunnel);
parseAndAddSolid(gmlTunnel.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, cdTunnel, Orientation.OUTWARD);
parseTunnelInstallations(gmlTunnel, cdTunnel);
parseHollowSpaces(gmlTunnel, cdTunnel);
parseTunnelFurniture(gmlTunnel, cdTunnel);
parseTunnelConstructiveElements(gmlTunnel, cdTunnel);
parseTunnelBoundarySurfaces(gmlTunnel);
for (Installation ti : cdTunnel.getTunnelInstallations()) {
updateEdgesAndVertices(ti);
for (BoundarySurface bs : ti.getBoundarySurfaces()) {
updateEdgesAndVertices(bs);
for (Opening o : bs.getOpenings()) {
updateEdgesAndVertices(o);
}
}
}
}
var dProp = gmlTunnel.getDeprecatedProperties();
parseAndAddMultiSurface(dProp.getLod1MultiSurface(), Lod.LOD1, cdTunnel);
parseAndAddMultiSurface(dProp.getLod4MultiSurface(), Lod.LOD4, cdTunnel);
parseAndAddSolid(dProp.getLod4Solid(), Lod.LOD4, cdTunnel, Orientation.OUTWARD);
private void parseTunnelBoundarySurfaces(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel) {
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTunnel.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
updateEdgesAndVertices(bs);
for (Opening o : bs.getOpenings()) {
updateEdgesAndVertices(o);
}
}
List<Installation> installations = readTunnelInstallationProperties(gmlTunnel.getTunnelInstallations());
installations.forEach(cdTunnel::addInstallation);
List<TunnelHollow> hollows = readTunnelHollowSpaceProperties(gmlTunnel.getHollowSpaces());
hollows.forEach(cdTunnel::addRoom);
List<de.hft.stuttgart.citydoctor2.datastructure.TunnelConstructiveElement> elements = readTunnelConstructiveElementProperties(gmlTunnel.getTunnelConstructiveElements());
elements.forEach(cdTunnel::addConstructiveElement);
List<TunnelFurniture> furniture = readTunnelFurnitureProperties(gmlTunnel.getTunnelFurniture());
furniture.forEach(cdTunnel::addFurniture);
}
private void parseTunnelConstructiveElements(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
for (TunnelConstructiveElementProperty teProp : gmlTunnel.getTunnelConstructiveElements()) {
private List<de.hft.stuttgart.citydoctor2.datastructure.TunnelConstructiveElement> readTunnelConstructiveElementProperties(List<TunnelConstructiveElementProperty> properties) {
List<de.hft.stuttgart.citydoctor2.datastructure.TunnelConstructiveElement> elements = new ArrayList<>();
for (TunnelConstructiveElementProperty teProp : properties) {
var gmlTc = teProp.getObject();
if (gmlTc == null) {
continue;
}
TunnelConstructiveElement tc = mapTunnelConstructiveElement(gmlTc);
cdTunnel.addTunnelConstructiveElement(tc);
TunnelConstructiveElement tc = parseTunnelConstructiveElement(gmlTc);
elements.add(tc);
}
return elements;
}
private void parseTunnelFurniture(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
for (TunnelFurnitureProperty tfProp : gmlTunnel.getTunnelFurniture()) {
private List<de.hft.stuttgart.citydoctor2.datastructure.TunnelFurniture> readTunnelFurnitureProperties(List<TunnelFurnitureProperty> properties) {
List<de.hft.stuttgart.citydoctor2.datastructure.TunnelFurniture> furniture = new ArrayList<>();
for (TunnelFurnitureProperty tfProp : properties) {
var gmlTf = tfProp.getObject();
if (gmlTf == null) {
continue;
}
TunnelFurniture tf = mapTunnelFurniture(gmlTf);
cdTunnel.addTunnelFurniture(tf);
TunnelFurniture tf = parseTunnelFurniture(gmlTf);
furniture.add(tf);
}
return furniture;
}
private void parseHollowSpaces(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
for (HollowSpaceProperty thProp : gmlTunnel.getHollowSpaces()) {
private List<TunnelHollow> readTunnelHollowSpaceProperties(List<HollowSpaceProperty> properties) {
List<TunnelHollow> hollows = new ArrayList<>();
for (HollowSpaceProperty thProp : properties) {
var gmlTh = thProp.getObject();
if (gmlTh == null) {
continue;
}
TunnelHollow br = mapTunnelHollow(gmlTh);
cdTunnel.addTunnelHollow(br);
TunnelHollow br = parseTunnelHollow(gmlTh);
hollows.add(br);
}
return hollows;
}
private void parseTunnelInstallations(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
for (TunnelInstallationProperty tiProp : gmlTunnel.getTunnelInstallations()) {
private List<Installation> readTunnelInstallationProperties(List<TunnelInstallationProperty> properties) {
List<Installation> installations = new ArrayList<>();
for (TunnelInstallationProperty tiProp : properties) {
var gmlTi = tiProp.getObject();
if (gmlTi == null) {
// ignore empty properties
continue;
}
Installation ti = mapTunnelInstallation(gmlTi, Orientation.OUTWARD);
cdTunnel.addTunnelInstallation(ti);
Installation ti = parseTunnelInstallation(gmlTi);
installations.add(ti);
}
return installations;
}
private Installation mapTunnelInstallation(TunnelInstallation gmlTi, Orientation orientation) {
Installation ti = new Installation();
ti.setGmlObject(gmlTi);
mapAbstractOccupiedSpace(gmlTi, ti, Orientation.OUTWARD);
GeometryProperty<?> lod2Prop = gmlTi.getDeprecatedProperties().getLod2Geometry();
parseAndAddAbstractGeometry(lod2Prop, Lod.LOD2, ti, orientation);
GeometryProperty<?> lod3Prop = gmlTi.getDeprecatedProperties().getLod3Geometry();
parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, ti, orientation);
GeometryProperty<?> lod4Prop = gmlTi.getDeprecatedProperties().getLod4Geometry();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, ti, orientation);
private Installation parseTunnelInstallation(TunnelInstallation gmlTunnelInst) {
Installation cdTunnelInst = new Installation();
cdTunnelInst.setGmlObject(gmlTunnelInst);
mapAbstractInstallation(gmlTunnelInst, cdTunnelInst);
var dProp = gmlTunnelInst.getDeprecatedProperties();
parseAndAddAbstractGeometry(dProp.getLod2Geometry(), Lod.LOD2, cdTunnelInst, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod3Geometry(), Lod.LOD3, cdTunnelInst, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod4Geometry(), Lod.LOD4, cdTunnelInst, Orientation.OUTWARD);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTi.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
ti.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
p.setPartOfInstallation(ti);
}
}
}
for (Geometry geom : ti.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfInstallation(ti);
}
}
return ti;
return cdTunnelInst;
}
private TunnelHollow mapTunnelHollow(HollowSpace gmlHo) {
TunnelHollow tHollow = new TunnelHollow();
tHollow.setGmlObject(gmlHo);
mapAbstractUnoccupiedSpace(gmlHo, tHollow, Orientation.INWARD);
private TunnelHollow parseTunnelHollow(HollowSpace gmlHollow) {
TunnelHollow cdHollow = new TunnelHollow();
cdHollow.setGmlObject(gmlHollow);
mapAbstractUnoccupiedSpace(gmlHollow, cdHollow, Orientation.INWARD);
mapBoundedSpace(gmlHollow, cdHollow);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlHo.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
tHollow.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
}
}
}
for (TunnelInstallationProperty tiProp : gmlHo.getTunnelInstallations()) {
var gmlTi = tiProp.getObject();
if (gmlTi == null) {
// ignore empty properties
continue;
}
Installation bi = mapTunnelInstallation(gmlTi, Orientation.INWARD);
tHollow.addRoomInstallation(bi);
}
for (TunnelFurnitureProperty tfProp : gmlHo.getTunnelFurniture()) {
var gmlHref = tfProp.getHref();
if (gmlHref == null) {
continue;
}
tHollow.addFurnitureRef(tfProp);
}
return tHollow;
}
var dProp = gmlHollow.getDeprecatedProperties();
parseAndAddMultiSurface(dProp.getLod4MultiSurface(),Lod.LOD4, cdHollow);
parseAndAddSolid(dProp.getLod4Solid(),Lod.LOD4,cdHollow, Orientation.OUTWARD);
private TunnelFurniture mapTunnelFurniture(org.citygml4j.core.model.tunnel.TunnelFurniture gmlTf) {
TunnelFurniture tf = new TunnelFurniture();
tf.setGmlObject(gmlTf);
mapAbstractOccupiedSpace(gmlTf, tf, Orientation.OUTWARD);
List<Installation> installations = readTunnelInstallationProperties(gmlHollow.getTunnelInstallations());
installations.forEach(cdHollow::addInstallation);
List<TunnelFurniture> furniture = readTunnelFurnitureProperties(gmlHollow.getTunnelFurniture());
furniture.forEach(cdHollow::addFurniture);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTf.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
tf.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
}
}
}
return tf;
return cdHollow;
}
private TunnelConstructiveElement mapTunnelConstructiveElement(
org.citygml4j.core.model.tunnel.TunnelConstructiveElement gmlTe) {
TunnelConstructiveElement te = new TunnelConstructiveElement(gmlTe);
mapAbstractOccupiedSpace(gmlTe, te, Orientation.OUTWARD);
List<BoundarySurface> boundarySurfaces = mapConstructiveElementSurfaces(gmlTe);
for (BoundarySurface bs : boundarySurfaces) {
te.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
}
}
}
return te;
}
private TunnelFurniture parseTunnelFurniture(org.citygml4j.core.model.tunnel.TunnelFurniture tunnelFurn) {
TunnelFurniture cdTunnelFurn = new TunnelFurniture();
cdTunnelFurn.setGmlObject(tunnelFurn);
mapAbstractFurniture(tunnelFurn, cdTunnelFurn);
private List<BoundarySurface> mapConstructiveElementSurfaces(AbstractConstructiveElement ace) {
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : ace.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (AbstractFillingElementProperty fillProp : ace.getFillings()) {
if (!fillProp.isSetObject()) {
continue;
}
AbstractFillingElement filling = fillProp.getObject();
filling.accept(surfaceMapper);
}
return surfaceMapper.getSurfaces();
}
var dProp = tunnelFurn.getDeprecatedProperties();
parseAndAddAbstractGeometry(dProp.getLod4Geometry(), Lod.LOD4, cdTunnelFurn, Orientation.OUTWARD);
private void updatePartOfSurface(BridgeObject bo, SurfaceMapper surfaceMapper) {
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
bo.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
}
}
}
return cdTunnelFurn;
}
private void mapConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement ele,
BridgeConstructiveElement bce) {
mapAbstractConstructiveElement(ele, bce);
private TunnelConstructiveElement parseTunnelConstructiveElement(
org.citygml4j.core.model.tunnel.TunnelConstructiveElement gmlTunnelCE) {
TunnelConstructiveElement cdTunnelCE = new TunnelConstructiveElement(gmlTunnelCE);
mapAbstractConstructiveElement(gmlTunnelCE, cdTunnelCE);
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 (AbstractFillingElementProperty fillProp : ele.getFillings()) {
if (!fillProp.isSetObject()) {
return cdTunnelCE;
}
private List<AbstractConstructiveFillingElement> readAbstractFillingElements(List<AbstractFillingElementProperty> properties){
List<AbstractConstructiveFillingElement> fillings = new ArrayList<>();
for (AbstractFillingElementProperty fillProp : properties) {
var gmlFi = fillProp.getObject();
if (gmlFi == null) {
continue;
}
AbstractFillingElement filling = fillProp.getObject();
bce.addFilling(mapAbstractFillingElement(filling));
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
bce.addBoundarySurface(bs);
AbstractConstructiveFillingElement filling = parseAbstractFillingElement(gmlFi);
fillings.add(filling);
}
return fillings;
}
private AbstractConstructiveFillingElement mapAbstractFillingElement(AbstractFillingElement ele){
private AbstractConstructiveFillingElement parseAbstractFillingElement(AbstractFillingElement gmlFilling){
AbstractConstructiveFillingElement fill;
if (ele instanceof Door d){
if (gmlFilling instanceof Door d){
fill = new DoorObject(d);
} else if (ele instanceof Window w){
} else if (gmlFilling instanceof Window w){
fill = new WindowObject(w);
} else {
fill = new AbstractConstructiveFillingElement(ele) {
fill = new AbstractConstructiveFillingElement(gmlFilling) {
@Override
public String getDisplayText(){
return String.format("[Unknown filling element] %s", this.getGmlId().toString());
......@@ -891,17 +794,9 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
};
}
mapAbstractOccupiedSpace(ele,fill,Orientation.OUTWARD);
return fill;
}
mapAbstractOccupiedSpace(gmlFilling,fill,Orientation.OUTWARD);
private void mapAbstractConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement ele,
BridgeConstructiveElement bce) {
mapAbstractOccupiedSpace(ele, bce, Orientation.OUTWARD);
}
private void mapAbstractConstruction(AbstractConstruction ac, BridgeObject bo) {
mapAbstractOccupiedSpace(ac, bo, Orientation.OUTWARD);
return fill;
}
@Override
......@@ -909,7 +804,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
TopLevelTransportFeature top = TopLevelTransportFeature.from(track);
mapSectionsAndIntersections(track.getSections(), track.getIntersections(), top);
mapAbstractTransportationSpace(track, top);
finishTransportationMapping(top);
finishFeatureConstruction(top);
model.addTransportation(top);
}
@Override
......@@ -917,7 +813,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
TopLevelTransportFeature top = TopLevelTransportFeature.from(road);
mapSectionsAndIntersections(road.getSections(), road.getIntersections(), top);
mapAbstractTransportationSpace(road, top);
finishTransportationMapping(top);
finishFeatureConstruction(top);
model.addTransportation(top);
}
@Override
......@@ -925,7 +822,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
TopLevelTransportFeature top = TopLevelTransportFeature.from(waterway);
mapSectionsAndIntersections(waterway.getSections(), waterway.getIntersections(), top);
mapAbstractTransportationSpace(waterway, top);
finishTransportationMapping(top);
finishFeatureConstruction(top);
model.addTransportation(top);
}
@Override
......@@ -933,21 +831,24 @@ public class Citygml3FeatureMapper extends ObjectWalker {
TopLevelTransportFeature top = TopLevelTransportFeature.from(railway);
mapSectionsAndIntersections(railway.getSections(), railway.getIntersections(), top);
mapAbstractTransportationSpace(railway, top);
finishTransportationMapping(top);
finishFeatureConstruction(top);
model.addTransportation(top);
}
@Override
public void visit(Square square) {
TopLevelTransportFeature top = TopLevelTransportFeature.from(square);
mapAbstractTransportationSpace(square, top);
finishTransportationMapping(top);
finishFeatureConstruction(top);
model.addTransportation(top);
}
@Override
public void visit(TransportationComplex tc) {
TopLevelTransportFeature top = TopLevelTransportFeature.from(tc);
mapAbstractTransportationSpace(tc, top);
finishTransportationMapping(top);
finishFeatureConstruction(top);
model.addTransportation(top);
}
......@@ -982,16 +883,27 @@ public class Citygml3FeatureMapper extends ObjectWalker {
private void finishTransportationMapping(TransportationObject to) {
finishCityObjectConstruction(to);
finishFeatureConstruction(to);
model.addTransportation(to);
}
private void finishFeatureConstruction(CityObject co) {
resolveAndClearReferences(co);
co.accept(new CheckableUtilsVisitor() {
@Override
public void check(CityObject co) {
finishCityObjectConstruction(co);
}
});
co.setBbox(BoundingBox.of(co));
}
private void finishCityObjectConstruction(CityObject co) {
parseId(co.getGmlObject(), co);
co.clearGmlGeometries();
resolveAndClearReferences(co);
updateEdgesAndVertices(co);
co.setBbox(BoundingBox.of(co));
if (co.getGmlId() == null){
parseId(co.getGmlObject(), co);
}
}
private void mapAbstractTransportationSpace(AbstractTransportationSpace ats, TransportationSpace trsp) {
......@@ -1019,7 +931,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
TransportSection sect = new TransportSection(TransportSection.SectionType.SECTION);
sect.setGmlObject(sectionProp.getObject());
mapAbstractTransportationSpace(sectionProp.getObject(), sect);
finishCityObjectConstruction(sect);
finishFeatureConstruction(sect);
top.addSection(sect);
}
}
......@@ -1028,7 +940,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
TransportSection isect = new TransportSection(TransportSection.SectionType.INTERSECTION);
isect.setGmlObject(intersectionProp.getObject());
mapAbstractTransportationSpace(intersectionProp.getObject(), isect);
finishCityObjectConstruction(isect);
finishFeatureConstruction(isect);
top.addIntersection(isect);
}
}
......@@ -1046,7 +958,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
tso.addTrafficArea(tao);
}
}
finishCityObjectConstruction(tso);
}
private void mapAuxiliaryTrafficSpace(AuxiliaryTrafficSpace ats, TrafficSpaceObject tso) {
......@@ -1060,7 +971,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
tso.addTrafficArea(tao);
}
}
finishCityObjectConstruction(tso);
}
private void mapTrafficArea(TrafficArea ta, TrafficAreaObject tao) {
......@@ -1070,7 +980,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseAndAddMultiSurface(ta.getLod2MultiSurface(), Lod.LOD2, tao);
parseAndAddMultiSurface(ta.getLod3MultiSurface(), Lod.LOD3, tao);
parseAndAddMultiSurface(ta.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, tao);
finishCityObjectConstruction(tao);
}
private void mapAuxiliaryTrafficArea(AuxiliaryTrafficArea ats, TrafficAreaObject tao) {
......@@ -1080,7 +989,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseAndAddMultiSurface(ats.getLod2MultiSurface(), Lod.LOD2, tao);
parseAndAddMultiSurface(ats.getLod3MultiSurface(), Lod.LOD3, tao);
parseAndAddMultiSurface(ats.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, tao);
finishCityObjectConstruction(tao);
}
private void mapAbstractUnoccupiedSpace(AbstractUnoccupiedSpace aus, CityObject co, Orientation orientation) {
......@@ -1225,294 +1133,333 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
private void readAbstractBuilding(org.citygml4j.core.model.building.AbstractBuilding gmlAb,
AbstractBuilding cdBuilding) {
private void mapAbstractBuilding(org.citygml4j.core.model.building.AbstractBuilding gmlAb,
AbstractBuilding cdBuilding) {
mapAbstractOccupiedSpace(gmlAb, cdBuilding, Orientation.OUTWARD);
mapBoundedSpace(gmlAb, cdBuilding);
cdBuilding.setGmlObject(gmlAb);
// parse deprecated geometries
parseAndAddMultiSurface(gmlAb.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, cdBuilding);
parseAndAddMultiSurface(gmlAb.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, cdBuilding);
parseAndAddSolid(gmlAb.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, cdBuilding, Orientation.OUTWARD);
parseBuildingConstructiveElements(gmlAb, cdBuilding);
parseBuildingInstallations(gmlAb, cdBuilding);
parseBuildingRooms(gmlAb, cdBuilding);
parseBuildingSubdivisions(gmlAb, cdBuilding);
parseBoundarySurfaces(gmlAb, cdBuilding);
parseBuildingFurniture(gmlAb, cdBuilding);
}
private void parseBuildingFurniture(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
for (BuildingFurnitureProperty bfProp : gmlAb.getBuildingFurniture()) {
var dProp = gmlAb.getDeprecatedProperties();
parseAndAddMultiSurface(dProp.getLod1MultiSurface(), Lod.LOD1, cdBuilding);
parseAndAddMultiSurface(dProp.getLod4MultiSurface(), Lod.LOD4, cdBuilding);
parseAndAddSolid(dProp.getLod4Solid(), Lod.LOD4, cdBuilding, Orientation.OUTWARD);
List<BuildingConstructiveElement> elements = readBuildingConstructiveElementProperties(gmlAb.getBuildingConstructiveElements());
elements.forEach(cdBuilding::addConstructiveElement);
List<Installation> installations = readBuildingInstallationProperties(gmlAb.getBuildingInstallations());
installations.forEach(cdBuilding::addInstallation);
List<BuildingRoom> rooms = readBuildingRoomProperties(gmlAb.getBuildingRooms());
rooms.forEach(cdBuilding::addRoom);
List<BuildingRoomFurniture> furniture = readBuildingFurnitureProperties(gmlAb.getBuildingFurniture());
furniture.forEach(cdBuilding::addFurniture);
readBuildingSubdivisions(gmlAb, cdBuilding);
}
private List<BuildingRoomFurniture> readBuildingFurnitureProperties(List<BuildingFurnitureProperty> properties) {
List<BuildingRoomFurniture> furnitureList = new ArrayList<>();
for (BuildingFurnitureProperty bfProp : properties) {
var gmlBf = bfProp.getObject();
if (gmlBf == null) {
continue;
}
BuildingRoomFurniture bf = mapBuildingFurniture(gmlBf);
cdBuilding.addBuildingRoomFurniture(bf);
BuildingRoomFurniture bf = parseBuildingFurniture(gmlBf);
furnitureList.add(bf);
}
return furnitureList;
}
private void parseBoundarySurfaces(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
private void mapBoundedSpace(AbstractSpace gmlSpace, BoundedSpace space){
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlAb.getBoundaries()) {
for (AbstractSpaceBoundaryProperty surfaceProp : gmlSpace.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
updatePartOfSurface(cdBuilding, surfaceMapper);
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
space.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
}
}
updateEdgesAndVertices(bs);
for (Opening o : bs.getOpenings()) {
for(Opening o : bs.getOpenings()) {
updateEdgesAndVertices(o);
}
}
}
private void parseBuildingSubdivisions(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
private void readBuildingSubdivisions(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
Map<GmlId, de.hft.stuttgart.citydoctor2.datastructure.Storey> storeyMap = new HashMap<>();
Map<GmlId, de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit> unitMap = new HashMap<>();
for (AbstractBuildingSubdivisionProperty abs : gmlAb.getBuildingSubdivisions()) {
var gmlABS = abs.getObject();
if (gmlABS == null) {
continue;
}
if (gmlABS instanceof Storey gmlStorey) {
de.hft.stuttgart.citydoctor2.datastructure.Storey storey = mapBuildingStorey(gmlStorey);
de.hft.stuttgart.citydoctor2.datastructure.Storey storey = parseBuildingStorey(gmlStorey, storeyMap, unitMap);
cdBuilding.addStorey(storey);
} else if (gmlABS instanceof BuildingUnit gmlBU) {
de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit bu = mapBuildingUnit(gmlBU);
de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit bu = parseBuildingUnit(gmlBU, unitMap, storeyMap);
cdBuilding.addBuildingUnit(bu);
}
}
resolveBuildingSubdivisionsProperties(cdBuilding);
}
private void resolveBuildingSubdivisionsProperties(AbstractBuilding cdBuilding){
List<AbstractBuildingSubdivision> absList = new ArrayList<>(cdBuilding.getBuildingUnits());
absList.addAll(cdBuilding.getStoreys());
Map<GmlId, BuildingRoom> roomMap =
cdBuilding.getRooms().stream()
.collect(Collectors.toMap(GmlElement::getGmlId, room -> room));
Map<GmlId, BuildingConstructiveElement> bceMap =
cdBuilding.getConstructiveElements().stream()
.collect(Collectors.toMap(GmlElement::getGmlId, bce -> bce));
for(AbstractBuildingSubdivision abs: absList){
org.citygml4j.core.model.building.AbstractBuildingSubdivision gmlObject = abs.getGmlObject();
List<Installation> installations = readBuildingInstallationProperties(gmlObject.getBuildingInstallations());
installations.forEach(abs::addInstallation);
List<BuildingRoomFurniture> furniture = readBuildingFurnitureProperties(gmlObject.getBuildingFurniture());
furniture.forEach(abs::addFurniture);
for(BuildingConstructiveElementProperty bceProp : gmlObject.getBuildingConstructiveElements()) {
var gmlBce = bceProp.getObject();
if (gmlBce == null) {
continue;
}
BuildingConstructiveElement cdBce;
if (gmlBce.getId() != null && bceMap.containsKey(new GmlId(gmlBce.getId()))) {
cdBce = bceMap.get(new GmlId(gmlBce.getId()));
} else {
cdBce = parseBuildingConstructiveElement(gmlBce);
}
abs.addConstructiveElement(cdBce);
}
for(BuildingRoomProperty brProp: gmlObject.getBuildingRooms()) {
var gmlBR = brProp.getObject();
if (gmlBR == null) {
continue;
}
BuildingRoom cdBr;
if (gmlBR.getId() != null && roomMap.containsKey(new GmlId(gmlBR.getId()))) {
cdBr = roomMap.get(new GmlId(gmlBR.getId()));
} else {
cdBr = parseBuildingRoom(gmlBR);
}
abs.addRoom(cdBr);
}
}
}
private void parseBuildingConstructiveElements(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
for (BuildingConstructiveElementProperty bceProp : gmlAb.getBuildingConstructiveElements()) {
private List<BuildingConstructiveElement> readBuildingConstructiveElementProperties(List<BuildingConstructiveElementProperty> properties) {
List<BuildingConstructiveElement> elements = new ArrayList<>();
for (BuildingConstructiveElementProperty bceProp : properties) {
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);
de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement cdBce =
parseBuildingConstructiveElement(gmlBCE);
elements.add(cdBce);
}
return elements;
}
private void parseBuildingRooms(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
for (BuildingRoomProperty brProp : gmlAb.getBuildingRooms()) {
private de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement parseBuildingConstructiveElement(
org.citygml4j.core.model.building.BuildingConstructiveElement gmlBuildingCE) {
de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement cdBuildingCE =
new de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement(gmlBuildingCE);
mapAbstractConstructiveElement(gmlBuildingCE, cdBuildingCE);
return cdBuildingCE;
}
private List<BuildingRoom> readBuildingRoomProperties(List<BuildingRoomProperty> properties) {
List<BuildingRoom> rooms = new ArrayList<>();
for (BuildingRoomProperty brProp : properties) {
var gmlBr = brProp.getObject();
if (gmlBr == null) {
continue;
}
BuildingRoom br = mapBuildingRoom(gmlBr);
cdBuilding.addBuildingRoom(br);
BuildingRoom br = parseBuildingRoom(gmlBr);
rooms.add(br);
}
return rooms;
}
private void parseBuildingInstallations(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
for (BuildingInstallationProperty biProp : gmlAb.getBuildingInstallations()) {
private List<Installation> readBuildingInstallationProperties(List<BuildingInstallationProperty> properties) {
List<Installation> installations = new ArrayList<>();
for (BuildingInstallationProperty biProp : properties) {
var gmlBi = biProp.getObject();
if (gmlBi == null) {
// ignore empty properties
continue;
}
Installation bi = mapBuildingInstallation(gmlBi);
cdBuilding.addBuildingInstallation(bi);
}
for (Installation bi : cdBuilding.getBuildingInstallations()) {
updateEdgesAndVertices(bi);
for (BoundarySurface bs : bi.getBoundarySurfaces()) {
updateEdgesAndVertices(bs);
for (Opening o : bs.getOpenings()) {
updateEdgesAndVertices(o);
}
}
Installation bi = parseBuildingInstallation(gmlBi);
installations.add(bi);
}
return installations;
}
private BuildingRoom mapBuildingRoom(org.citygml4j.core.model.building.BuildingRoom gmlBr) {
BuildingRoom br = new BuildingRoom();
br.setGmlObject(gmlBr);
mapAbstractUnoccupiedSpace(gmlBr, br, Orientation.INWARD);
private BuildingRoom parseBuildingRoom(org.citygml4j.core.model.building.BuildingRoom buildingRoom) {
BuildingRoom cdRoom = new BuildingRoom();
cdRoom.setGmlObject(buildingRoom);
mapAbstractUnoccupiedSpace(buildingRoom, cdRoom, Orientation.INWARD);
mapBoundedSpace(buildingRoom, cdRoom);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBr.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
br.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
}
}
}
for (BuildingInstallationProperty biProp : gmlBr.getBuildingInstallations()) {
var gmlBi = biProp.getObject();
if (gmlBi == null) {
// ignore empty properties
continue;
}
Installation bi = mapBuildingInstallation(gmlBi);
br.addRoomInstallation(bi);
}
for (BuildingFurnitureProperty bfProp : gmlBr.getBuildingFurniture()) {
var gmlHref = bfProp.getHref();
if (gmlHref == null) {
continue;
}
br.addFurnitureRef(bfProp);
}
var dProp = buildingRoom.getDeprecatedProperties();
parseAndAddMultiSurface(dProp.getLod4MultiSurface(), Lod.LOD4, cdRoom);
parseAndAddSolid(dProp.getLod4Solid(),Lod.LOD4, cdRoom, Orientation.INWARD);
List<BuildingRoomFurniture> furniture = readBuildingFurnitureProperties(buildingRoom.getBuildingFurniture());
furniture.forEach(cdRoom::addFurniture);
List<Installation> installations = readBuildingInstallationProperties(buildingRoom.getBuildingInstallations());
installations.forEach(cdRoom::addInstallation);
return br;
return cdRoom;
}
private BuildingRoomFurniture mapBuildingFurniture(BuildingFurniture gmlAF) {
BuildingRoomFurniture bf = new BuildingRoomFurniture();
bf.setGmlObject(gmlAF);
mapAbstractOccupiedSpace(gmlAF, bf, Orientation.OUTWARD);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlAF.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
bf.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
}
}
}
return bf;
private BuildingRoomFurniture parseBuildingFurniture(BuildingFurniture buildingFurn) {
BuildingRoomFurniture cdFurn = new BuildingRoomFurniture();
cdFurn.setGmlObject(buildingFurn);
mapAbstractFurniture(buildingFurn, cdFurn);
var dProp = buildingFurn.getDeprecatedProperties();
parseAndAddAbstractGeometry(dProp.getLod4Geometry(), Lod.LOD4, cdFurn, Orientation.OUTWARD);
return cdFurn;
}
private void mapBuildingConstructiveElement(de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement bce, BuildingConstructiveElement ele) {
mapAbstractOccupiedSpace(ele, bce, Orientation.OUTWARD);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : ele.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
private void mapAbstractFurniture(org.citygml4j.core.model.construction.AbstractFurniture gmlAf, AbstractFurniture cdAf) {
mapAbstractOccupiedSpace(gmlAf, cdAf, Orientation.OUTWARD);
mapBoundedSpace(gmlAf, cdAf);
}
private void mapAbstractConstructiveElement(AbstractConstructiveElement gmlAce,
de.hft.stuttgart.citydoctor2.datastructure.AbstractConstructiveElement cdAce){
mapAbstractOccupiedSpace(gmlAce, cdAce, Orientation.OUTWARD);
mapBoundedSpace(gmlAce, cdAce);
List<AbstractConstructiveFillingElement> fillings = readAbstractFillingElements(gmlAce.getFillings());
fillings.forEach(cdAce::addFilling);
}
private de.hft.stuttgart.citydoctor2.datastructure.Storey parseBuildingStorey(
Storey gmlStorey, Map<GmlId, de.hft.stuttgart.citydoctor2.datastructure.Storey> storeyMap,
Map<GmlId, de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit> unitMap) {
de.hft.stuttgart.citydoctor2.datastructure.Storey cdStorey = shallowParseBuildingStorey(gmlStorey);
storeyMap.put(cdStorey.getGmlId(), cdStorey);
for (BuildingUnitProperty buProp : gmlStorey.getBuildingUnits()) {
var gmlBu = buProp.getObject();
if (gmlBu == null) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (AbstractFillingElementProperty fillProp : ele.getFillings()) {
if (!fillProp.isSetObject()) {
continue;
de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit bu;
if (gmlBu.getId() == null) {
bu = shallowParseBuildingUnit(gmlBu);
} else {
bu = parseBuildingUnit(gmlBu, unitMap, storeyMap);
}
AbstractFillingElement filling = fillProp.getObject();
bce.addFilling(mapAbstractFillingElement(filling));
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
bce.addBoundarySurface(bs);
cdStorey.addBuildingUnit(bu);
}
return cdStorey;
}
private de.hft.stuttgart.citydoctor2.datastructure.Storey mapBuildingStorey(Storey gmlStorey) {
de.hft.stuttgart.citydoctor2.datastructure.Storey storey = new de.hft.stuttgart.citydoctor2.datastructure.Storey();
storey.setGmlObject(gmlStorey);
mapAbstractSpace(gmlStorey, storey, Orientation.INWARD);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlStorey.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
private de.hft.stuttgart.citydoctor2.datastructure.Storey shallowParseBuildingStorey(Storey gmlStorey) {
de.hft.stuttgart.citydoctor2.datastructure.Storey cdStorey = new de.hft.stuttgart.citydoctor2.datastructure.Storey();
cdStorey.setGmlObject(gmlStorey);
mapAbstractSpace(gmlStorey, cdStorey, Orientation.INWARD);
mapBoundedSpace(gmlStorey, cdStorey);
return cdStorey;
}
private de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit parseBuildingUnit(
BuildingUnit gmlBUnit, Map<GmlId, de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit> unitMap,
Map<GmlId, de.hft.stuttgart.citydoctor2.datastructure.Storey> storeyMap) {
de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit cdBUnit = shallowParseBuildingUnit(gmlBUnit);
unitMap.put(cdBUnit.getGmlId(), cdBUnit);
for (StoreyProperty sProp : gmlBUnit.getStoreys()) {
var gmlStorey = sProp.getObject();
if (gmlStorey == null) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
storey.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
}
de.hft.stuttgart.citydoctor2.datastructure.Storey storey;
if (gmlStorey.getId() == null) {
storey = shallowParseBuildingStorey(gmlStorey);
} else {
storey = parseBuildingStorey(gmlStorey, storeyMap, unitMap);
}
cdBUnit.addStorey(storey);
}
return storey;
return cdBUnit;
}
private de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit mapBuildingUnit(BuildingUnit gmlBU) {
de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit bu = new de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit();
bu.setGmlObject(gmlBU);
mapAbstractSpace(gmlBU, bu, Orientation.OUTWARD);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBU.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
private de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit shallowParseBuildingUnit(BuildingUnit gmlBUnit) {
de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit cdBUnit = new de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit();
cdBUnit.setGmlObject(gmlBUnit);
mapAbstractSpace(gmlBUnit, cdBUnit, Orientation.OUTWARD);
mapBoundedSpace(gmlBUnit, cdBUnit);
for (BuildingFurnitureProperty bfProp : gmlBUnit.getBuildingFurniture()) {
var gmlBf = bfProp.getObject();
if (gmlBf == null) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
BuildingRoomFurniture bf = parseBuildingFurniture(gmlBf);
cdBUnit.addFurniture(bf);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
bu.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
}
for (BuildingInstallationProperty biProp : gmlBUnit.getBuildingInstallations()){
var gmlBi = biProp.getObject();
if (gmlBi == null) {
continue;
}
Installation bi = parseBuildingInstallation(gmlBi);
cdBUnit.addInstallation(bi);
}
return bu;
return cdBUnit;
}
private void updatePartOfSurface(AbstractBuilding cdBuilding, SurfaceMapper surfaceMapper) {
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
cdBuilding.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
}
}
}
}
private Installation parseBuildingInstallation(org.citygml4j.core.model.building.BuildingInstallation buildingInst) {
Installation cdInst = new Installation();
cdInst.setGmlObject(buildingInst);
mapAbstractInstallation(buildingInst, cdInst);
private Installation mapBuildingInstallation(org.citygml4j.core.model.building.BuildingInstallation gmlBi) {
Installation bi = new Installation();
bi.setGmlObject(gmlBi);
mapAbstractOccupiedSpace(gmlBi, bi, Orientation.OUTWARD);
GeometryProperty<?> lod2Prop = gmlBi.getDeprecatedProperties().getLod2Geometry();
parseAndAddAbstractGeometry(lod2Prop, Lod.LOD2, bi, Orientation.OUTWARD);
GeometryProperty<?> lod3Prop = gmlBi.getDeprecatedProperties().getLod3Geometry();
parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, bi, Orientation.OUTWARD);
GeometryProperty<?> lod4Prop = gmlBi.getDeprecatedProperties().getLod4Geometry();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi, Orientation.OUTWARD);
var dProp = buildingInst.getDeprecatedProperties();
parseAndAddAbstractGeometry(dProp.getLod2Geometry(), Lod.LOD2, cdInst, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod3Geometry(), Lod.LOD3, cdInst, Orientation.OUTWARD);
parseAndAddAbstractGeometry(dProp.getLod4Geometry(), Lod.LOD4, cdInst, Orientation.OUTWARD);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
bi.addBoundarySurface(bs);
return cdInst;
}
private void mapAbstractInstallation(AbstractInstallation abstractInst, Installation cdInst) {
mapAbstractOccupiedSpace(abstractInst, cdInst, Orientation.OUTWARD);
mapBoundedSpace(abstractInst, cdInst);
for (BoundarySurface bs : cdInst.getBoundarySurfaces()) {
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
p.setPartOfInstallation(bi);
p.setPartOfInstallation(cdInst);
}
}
}
for (Geometry geom : bi.getGeometries()) {
for (Geometry geom : cdInst.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfInstallation(bi);
p.setPartOfInstallation(cdInst);
}
}
return bi;
}
private void parseAndAddAbstractGeometry(GeometryProperty<?> geomProp, Lod lod, CityObject co, Orientation orientation) {
......
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