Commit a1602768 authored by Matthias Betz's avatar Matthias Betz
Browse files

general cleanup of code

2 merge requests!28Version 3.17.0 Release,!24cleanup code
Pipeline #10955 passed with stage
in 1 minute and 9 seconds
Showing with 1317 additions and 1296 deletions
+1317 -1296
...@@ -124,7 +124,10 @@ public abstract class AbstractFurniture extends CityObject { ...@@ -124,7 +124,10 @@ public abstract class AbstractFurniture extends CityObject {
public void setParent(CityObject co) { public void setParent(CityObject co) {
parent = co; parent = co;
} }
public CityObject getParent() {
return parent;
}
@Override @Override
public void unsetGmlGeometries() { public void unsetGmlGeometries() {
......
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.List;
import org.citygml4j.core.model.core.ImplicitGeometry;
import de.hft.stuttgart.citydoctor2.check.Check; import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError; import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId; import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.math.TransformationMatrix; import de.hft.stuttgart.citydoctor2.math.TransformationMatrix;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.ImplicitGeometry;
import java.io.Serial;
import java.util.List;
/** /**
* Datastructure for representation and resolving of implicit geometries * Datastructure for representation and resolving of implicit geometries
...@@ -18,7 +17,6 @@ import java.util.List; ...@@ -18,7 +17,6 @@ import java.util.List;
*/ */
public class ImplicitGeometryHolder extends Geometry { public class ImplicitGeometryHolder extends Geometry {
private static final Logger logger = LogManager.getLogger(ImplicitGeometryHolder.class);
@Serial @Serial
private static final long serialVersionUID = -8938931081577196349L; private static final long serialVersionUID = -8938931081577196349L;
......
...@@ -14,68 +14,66 @@ import java.util.Map; ...@@ -14,68 +14,66 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/** /**
* Reference object for handling of implicit geometries with a library object contained in an external file * Reference object for handling of implicit geometries with a library object
* contained in an external file
* *
* @author Riegel * @author Riegel
*/ */
public class LibraryObject extends Geometry { public class LibraryObject extends Geometry {
private static final Logger logger = LogManager.getLogger(LibraryObject.class); private static final Logger logger = LogManager.getLogger(LibraryObject.class);
@Serial @Serial
private static final long serialVersionUID = -50293435187454911L; private static final long serialVersionUID = -50293435187454911L;
private final String filepath;
private final ParserConfiguration config;
private static Map<String, LibraryObject> libraryObjects = new ConcurrentHashMap<>();
public static LibraryObject of(Path path, ParserConfiguration config) { private static Map<String, LibraryObject> libraryObjects = new ConcurrentHashMap<>();
if (libraryObjects.containsKey(path.toString())) {
return libraryObjects.get(path.toString());
}
Geometry protoGeom = parseFile(path, config);
if (protoGeom == null) {
return null;
}
LibraryObject libOb = new LibraryObject(protoGeom.getType(), protoGeom.getLod(), path, config);
protoGeom.getPolygons().forEach(libOb::addPolygon);
libOb.updateEdgesAndVertices();
libraryObjects.put(path.toString(), libOb);
return libOb;
}
private LibraryObject(GeometryType type, Lod lod, Path path, ParserConfiguration config) { public static LibraryObject of(Path path, ParserConfiguration config) {
super(type, lod); if (libraryObjects.containsKey(path.toString())) {
this.filepath = path.toString(); return libraryObjects.get(path.toString());
this.config = config; }
} Geometry protoGeom = parseFile(path, config);
if (protoGeom == null) {
return null;
}
LibraryObject libOb = new LibraryObject(protoGeom.getType(), protoGeom.getLod());
protoGeom.getPolygons().forEach(libOb::addPolygon);
libOb.updateEdgesAndVertices();
libraryObjects.put(path.toString(), libOb);
return libOb;
}
private LibraryObject(GeometryType type, Lod lod) {
super(type, lod);
}
private static Geometry parseFile(Path path, ParserConfiguration config) { private static Geometry parseFile(Path path, ParserConfiguration config) {
Geometry geo = null; Geometry geo = null;
if (path.toFile().exists()) { if (path.toFile().exists()) {
try { try {
CityGmlParser.gagLogger(true); CityGmlParser.gagLogger(true);
CityDoctorModel model = CityGmlParser.parseCityGmlFile(path.toString(), config); CityDoctorModel model = CityGmlParser.parseCityGmlFile(path.toString(), config);
List<CityObject> objects = model.createFeatureStream().toList(); List<CityObject> objects = model.createFeatureStream().toList();
if (objects.isEmpty()) { if (objects.isEmpty()) {
throw new InvalidGmlFileException("Referenced library-object's gml file does not contain a CityGML object!"); throw new InvalidGmlFileException(
} else if (objects.size() > 1) { "Referenced library-object's gml file does not contain a CityGML object!");
throw new InvalidGmlFileException("Referenced library-object's gml file contains more than one CityGML object!"); } else if (objects.size() > 1) {
} throw new InvalidGmlFileException(
geo = objects.get(0).getHighestLodGeometry(); "Referenced library-object's gml file contains more than one CityGML object!");
} catch (CityGmlParseException e) { }
logger.error(String.format( geo = objects.get(0).getHighestLodGeometry();
"Encountered an error while parsing library object %s", path)); } catch (CityGmlParseException e) {
logger.error(e.getStackTrace()); logger.error("Encountered an error while parsing library object {}", path);
} catch (InvalidGmlFileException e) { logger.error(e.getStackTrace());
logger.error(e.getStackTrace()); } catch (InvalidGmlFileException e) {
} finally { logger.error(e.getStackTrace());
// Failsafe to remove gag should parsing fail } finally {
CityGmlParser.gagLogger(false); // Failsafe to remove gag should parsing fail
} CityGmlParser.gagLogger(false);
} else { }
logger.error(String.format("Implicit geometry references non-existing library object file %s.", path)); } else {
} logger.error("Implicit geometry references non-existing library object file {}.", path);
return geo; }
} return geo;
}
} }
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.Serial; import java.io.Serial;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
...@@ -15,27 +11,23 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -15,27 +11,23 @@ import java.util.concurrent.ConcurrentHashMap;
*/ */
public class RelativeGeometry extends Geometry { public class RelativeGeometry extends Geometry {
private static final Logger logger = LogManager.getLogger(RelativeGeometry.class); @Serial
@Serial private static final long serialVersionUID = -686112245455298977L;
private static final long serialVersionUID = -686112245455298977L;
private static Map<Geometry, RelativeGeometry> relativeGeometries = new ConcurrentHashMap<>();
private static Map<Geometry, RelativeGeometry> relativeGeometries = new ConcurrentHashMap<>();
public static RelativeGeometry of(Geometry geom) {
public static RelativeGeometry of(Geometry geom) { if (relativeGeometries.containsKey(geom)) {
if (relativeGeometries.containsKey(geom)) { return relativeGeometries.get(geom);
return relativeGeometries.get(geom); }
} RelativeGeometry relGeo = new RelativeGeometry(geom.getType(), geom.getLod());
RelativeGeometry relGeo = new RelativeGeometry(geom.getType(), geom.getLod()); geom.getPolygons().forEach(relGeo::addPolygon);
geom.getPolygons().forEach(relGeo::addPolygon); relGeo.updateEdgesAndVertices();
relGeo.updateEdgesAndVertices(); relativeGeometries.put(geom, relGeo);
relativeGeometries.put(geom, relGeo); return relGeo;
return relGeo; }
}
private RelativeGeometry(GeometryType type, Lod lod) {
super(type, lod);
private RelativeGeometry(GeometryType type, Lod lod) { }
super(type, lod);
}
} }
...@@ -60,6 +60,8 @@ public class TunnelConstructiveElement extends CityObject { ...@@ -60,6 +60,8 @@ public class TunnelConstructiveElement extends CityObject {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config); MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms); setMultiSurfaceAccordingToLod(geom, ms);
break; break;
case COMPOSITE_SURFACE:
throw new IllegalStateException("Tunnel constructive element cannot have a composite surface geometry");
} }
} }
for (BoundarySurface bs : boundarySurfaceList) { for (BoundarySurface bs : boundarySurfaceList) {
......
...@@ -72,1187 +72,1226 @@ import java.util.Map; ...@@ -72,1187 +72,1226 @@ import java.util.Map;
public class Citygml3FeatureMapper extends ObjectWalker { public class Citygml3FeatureMapper extends ObjectWalker {
private static final Logger logger = LogManager.getLogger(Citygml3FeatureMapper.class); private static final Logger logger = LogManager.getLogger(Citygml3FeatureMapper.class);
private final CityDoctorModel model; private final CityDoctorModel model;
private final ParserConfiguration config; private final ParserConfiguration config;
private final Path directory; private final Path directory;
private final double neighborDistance; private final double neighborDistance;
private Map<String, ConcretePolygon> polygonMap = new HashMap<>(); private Map<String, ConcretePolygon> polygonMap = new HashMap<>();
private Map<String, CompositeCollection> compositeMap = new HashMap<>(); private Map<String, CompositeCollection> compositeMap = new HashMap<>();
private List<ResolvableReference> references = new ArrayList<>(); private List<ResolvableReference> references = new ArrayList<>();
private Map<Vertex, Vertex> vertexMap = new HashMap<>(); private Map<Vertex, Vertex> vertexMap = new HashMap<>();
public Citygml3FeatureMapper(ParserConfiguration config, Path path) { public Citygml3FeatureMapper(ParserConfiguration config, Path path) {
this.config = config; this.config = config;
this.directory = path.getParent(); this.directory = path.getParent();
model = new CityDoctorModel(config, path.toFile()); model = new CityDoctorModel(config, path.toFile());
neighborDistance = 1.8d / Math.pow(10, config.getNumberOfRoundingPlaces()); neighborDistance = 1.8d / Math.pow(10, config.getNumberOfRoundingPlaces());
} }
public static void parseId(AbstractGML gml, GmlElement gmlElement) { public static void parseId(AbstractGML gml, GmlElement gmlElement) {
String id = gml.getId(); String id = gml.getId();
if (id != null) { if (id != null) {
gmlElement.setGmlId(new GmlId(id)); gmlElement.setGmlId(new GmlId(id));
} }
} }
@Override @Override
public void visit(AbstractSpace space) { public void visit(AbstractSpace space) {
// if we are here, an AbstractSpace thing was read that is not handled in the // if we are here, an AbstractSpace thing was read that is not handled in the
// other methods // other methods
} }
@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();
cf.setGmlObject(gmlCityFurniture); cf.setGmlObject(gmlCityFurniture);
mapAbstractOccupiedSpace(gmlCityFurniture, cf); mapAbstractOccupiedSpace(gmlCityFurniture, cf);
resolveAndClearReferences(); resolveAndClearReferences();
cf.unsetGmlGeometries(); cf.unsetGmlGeometries();
updateEdgesAndVertices(cf); updateEdgesAndVertices(cf);
model.addCityFurniture(cf); model.addCityFurniture(cf);
} }
@Override @Override
public void visit(org.citygml4j.core.model.generics.GenericOccupiedSpace gos) { public void visit(org.citygml4j.core.model.generics.GenericOccupiedSpace gos) {
GenericCityObject gco = new GenericCityObject(); GenericCityObject gco = new GenericCityObject();
gco.setGmlObject(gos); gco.setGmlObject(gos);
GeometryProperty<?> agLod1 = gos.getDeprecatedProperties().getLod1Geometry(); GeometryProperty<?> agLod1 = gos.getDeprecatedProperties().getLod1Geometry();
GeometryProperty<?> agLod4 = gos.getDeprecatedProperties().getLod4Geometry(); GeometryProperty<?> agLod4 = gos.getDeprecatedProperties().getLod4Geometry();
if (agLod1 != null && agLod1.getObject() != null && if (agLod1 != null && agLod1.getObject() != null && agLod1.getObject() instanceof MultiSurface ms) {
agLod1.getObject() instanceof MultiSurface ms) { gco.addGeometry(parseMultiSurface(ms, Lod.LOD1));
gco.addGeometry(parseMultiSurface(ms, Lod.LOD1)); }
} if (agLod4 != null && agLod4.getObject() != null) {
if (agLod4 != null && agLod4.getObject() != null) { if (agLod4.getObject() instanceof MultiSurface ms) {
if (agLod4.getObject() instanceof MultiSurface ms) { gco.addGeometry(parseMultiSurface(ms, Lod.LOD4));
gco.addGeometry(parseMultiSurface(ms, Lod.LOD4)); } else if (agLod4.getObject() instanceof AbstractSolid solid) {
} else if (agLod4.getObject() instanceof AbstractSolid solid) { gco.addGeometry(parseSolid(solid, Lod.LOD4));
gco.addGeometry(parseSolid(solid, Lod.LOD4)); }
} }
} mapAbstractOccupiedSpace(gos, gco);
mapAbstractOccupiedSpace(gos, gco); resolveAndClearReferences();
resolveAndClearReferences(); gco.unsetGmlGeometries();
gco.unsetGmlGeometries(); updateEdgesAndVertices(gco);
updateEdgesAndVertices(gco); model.addGenericCityObject(gco);
model.addGenericCityObject(gco); }
}
@Override
@Override public void visit(org.citygml4j.core.model.building.Building gmlBuilding) {
public void visit(org.citygml4j.core.model.building.Building gmlBuilding) { Building cdBuilding = new Building();
Building cdBuilding = new Building(); readAbstractBuilding(gmlBuilding, cdBuilding);
readAbstractBuilding(gmlBuilding, cdBuilding); for (BuildingPartProperty bpProp : gmlBuilding.getBuildingParts()) {
for (BuildingPartProperty bpProp : gmlBuilding.getBuildingParts()) { if (!bpProp.isSetObject()) {
if (!bpProp.isSetObject()) { continue;
continue; }
} BuildingPart part = new BuildingPart(cdBuilding);
BuildingPart part = new BuildingPart(cdBuilding); readAbstractBuilding(bpProp.getObject(), part);
readAbstractBuilding(bpProp.getObject(), part); }
} model.addBuilding(cdBuilding);
model.addBuilding(cdBuilding); }
}
@Override
@Override public void visit(WaterBody waterBody) {
public void visit(WaterBody waterBody) { WaterObject wo = new WaterObject();
WaterObject wo = new WaterObject(); wo.setGmlObject(waterBody);
wo.setGmlObject(waterBody); mapAbstractOccupiedSpace(waterBody, wo);
mapAbstractOccupiedSpace(waterBody, wo); parseAndAddMultiSurface(waterBody.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, wo);
parseAndAddMultiSurface(waterBody.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, wo); parseAndAddSolid(waterBody.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, wo);
parseAndAddSolid(waterBody.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, wo);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); for (AbstractSpaceBoundaryProperty surfaceProp : waterBody.getBoundaries()) {
for (AbstractSpaceBoundaryProperty surfaceProp : waterBody.getBoundaries()) { if (!surfaceProp.isSetObject()) {
if (!surfaceProp.isSetObject()) { continue;
continue; }
} AbstractSpaceBoundary surface = surfaceProp.getObject();
AbstractSpaceBoundary surface = surfaceProp.getObject(); surface.accept(surfaceMapper);
surface.accept(surfaceMapper); }
} for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { wo.addBoundarySurface(bs);
wo.addBoundarySurface(bs); }
}
resolveAndClearReferences();
resolveAndClearReferences(); wo.unsetGmlGeometries();
wo.unsetGmlGeometries(); updateEdgesAndVertices(wo);
updateEdgesAndVertices(wo); for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { updateEdgesAndVertices(bs);
updateEdgesAndVertices(bs); }
} model.addWater(wo);
model.addWater(wo); }
}
@Override
@Override public void visit(LandUse landUse) {
public void visit(LandUse landUse) { LandObject lo = new LandObject(landUse);
LandObject lo = new LandObject(landUse);
mapAbstractThematicSurface(landUse, lo);
mapAbstractThematicSurface(landUse, lo);
finishCityObjectConstruction(lo);
finishCityObjectConstruction(lo); model.addLand(lo);
model.addLand(lo); }
}
@Override
@Override public void visit(PlantCover plantCover) {
public void visit(PlantCover plantCover) { Vegetation veg = new Vegetation(VegetationType.PLANT_COVER);
Vegetation veg = new Vegetation(VegetationType.PLANT_COVER); veg.setGmlObject(plantCover);
veg.setGmlObject(plantCover); mapAbstractVegetationObject(plantCover, veg);
mapAbstractVegetationObject(plantCover, veg);
parseAndAddMultiSurface(plantCover.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, veg);
parseAndAddMultiSurface(plantCover.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, veg); parseAndAddMultiSurface(plantCover.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, veg);
parseAndAddMultiSurface(plantCover.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, veg);
finishCityObjectConstruction(veg);
finishCityObjectConstruction(veg); model.addVegetation(veg);
model.addVegetation(veg); }
}
@Override
@Override public void visit(SolitaryVegetationObject solitaryVegetationObject) {
public void visit(SolitaryVegetationObject solitaryVegetationObject) { Vegetation veg = new Vegetation(VegetationType.SOLITARY_VEGETATION_OBJECT);
Vegetation veg = new Vegetation(VegetationType.SOLITARY_VEGETATION_OBJECT); veg.setGmlObject(solitaryVegetationObject);
veg.setGmlObject(solitaryVegetationObject); mapAbstractVegetationObject(solitaryVegetationObject, veg);
mapAbstractVegetationObject(solitaryVegetationObject, veg);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod1Geometry(), Lod.LOD1,
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod1Geometry(), Lod.LOD1, veg); veg);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod2Geometry(), Lod.LOD2, veg); parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod2Geometry(), Lod.LOD2,
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod3Geometry(), Lod.LOD3, veg); veg);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod4Geometry(), Lod.LOD4, veg); parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod3Geometry(), Lod.LOD3,
veg);
finishCityObjectConstruction(veg); parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod4Geometry(), Lod.LOD4,
model.addVegetation(veg); veg);
}
finishCityObjectConstruction(veg);
private void mapAbstractVegetationObject(AbstractVegetationObject avo, Vegetation veg) { model.addVegetation(veg);
mapAbstractOccupiedSpace(avo, veg); }
}
private void mapAbstractVegetationObject(AbstractVegetationObject avo, Vegetation veg) {
private void mapAbstractOccupiedSpace(AbstractOccupiedSpace aos, CityObject co) { mapAbstractOccupiedSpace(avo, veg);
mapAbstractPhysicalSpace(aos, co); }
parseImplicitGeometry(aos, co);
} private void mapAbstractOccupiedSpace(AbstractOccupiedSpace aos, CityObject co) {
mapAbstractPhysicalSpace(aos, co);
private void mapAbstractPhysicalSpace(AbstractPhysicalSpace aps, CityObject co) { parseImplicitGeometry(aos, co);
mapAbstractSpace(aps, co); }
}
private void mapAbstractPhysicalSpace(AbstractPhysicalSpace aps, CityObject co) {
private void mapAbstractSpace(AbstractSpace as, CityObject co) { mapAbstractSpace(aps, co);
mapAbstractFeature(as, co); }
parseAndAddMultiSurface(as.getLod0MultiSurface(), Lod.LOD0, co);
parseAndAddMultiSurface(as.getLod2MultiSurface(), Lod.LOD2, co); private void mapAbstractSpace(AbstractSpace as, CityObject co) {
parseAndAddMultiSurface(as.getLod3MultiSurface(), Lod.LOD3, co); mapAbstractFeature(as, co);
parseAndAddSolid(as.getLod1Solid(), Lod.LOD1, co); parseAndAddMultiSurface(as.getLod0MultiSurface(), Lod.LOD0, co);
parseAndAddSolid(as.getLod2Solid(), Lod.LOD2, co); parseAndAddMultiSurface(as.getLod2MultiSurface(), Lod.LOD2, co);
parseAndAddSolid(as.getLod3Solid(), Lod.LOD3, co); parseAndAddMultiSurface(as.getLod3MultiSurface(), Lod.LOD3, co);
parseAndAddGenericAttributes(as, co); parseAndAddSolid(as.getLod1Solid(), Lod.LOD1, co);
} parseAndAddSolid(as.getLod2Solid(), Lod.LOD2, co);
parseAndAddSolid(as.getLod3Solid(), Lod.LOD3, co);
private void parseAndAddGenericAttributes(AbstractSpace as, CityObject co) { parseAndAddGenericAttributes(as, co);
for (AbstractGenericAttributeProperty aga : as.getGenericAttributes()) { }
co.addGenericAttribute(new GenericAttribute(aga));
} private void parseAndAddGenericAttributes(AbstractSpace as, CityObject co) {
} for (AbstractGenericAttributeProperty aga : as.getGenericAttributes()) {
co.addGenericAttribute(new GenericAttribute(aga));
@Override }
public void visit(Bridge bridge) { }
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, bridge);
@Override
public void visit(Bridge bridge) {
// parse deprecated geometries BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, bridge);
parseAndAddMultiSurface(bridge.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, bo);
parseAndAddMultiSurface(bridge.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, bo); // parse deprecated geometries
parseAndAddSolid(bridge.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, bo); parseAndAddMultiSurface(bridge.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, bo);
parseAndAddMultiSurface(bridge.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, bo);
mapAbstractBridge(bridge, bo); parseAndAddSolid(bridge.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, bo);
for (BridgePartProperty bPartProperty : bridge.getBridgeParts()) {
if (!bPartProperty.isSetObject()) { mapAbstractBridge(bridge, bo);
continue; for (BridgePartProperty bPartProperty : bridge.getBridgeParts()) {
} if (!bPartProperty.isSetObject()) {
BridgePart gmlBridgePart = bPartProperty.getObject(); continue;
BridgeObject bPart = new BridgeObject(BridgeType.BRIDGE_PART, gmlBridgePart); }
mapAbstractBridge(gmlBridgePart, bPart); BridgePart gmlBridgePart = bPartProperty.getObject();
bo.addBridgePart(bPart); BridgeObject bPart = new BridgeObject(BridgeType.BRIDGE_PART, gmlBridgePart);
} mapAbstractBridge(gmlBridgePart, bPart);
resolveAndClearReferences(); bo.addBridgePart(bPart);
updateEdgesAndVertices(bo); }
for (BridgeObject part : bo.getParts()) { resolveAndClearReferences();
updateEdgesAndVertices(part); updateEdgesAndVertices(bo);
} for (BridgeObject part : bo.getParts()) {
for (BridgeConstructiveElement ele : bo.getConstructiveElements()) { updateEdgesAndVertices(part);
updateEdgesAndVertices(ele); }
for (BoundarySurface bs : ele.getBoundarySurfaces()) { for (BridgeConstructiveElement ele : bo.getConstructiveElements()) {
updateEdgesAndVertices(bs); updateEdgesAndVertices(ele);
} for (BoundarySurface bs : ele.getBoundarySurfaces()) {
} updateEdgesAndVertices(bs);
for (Installation bi : bo.getBridgeInstallations()) { }
updateEdgesAndVertices(bi); }
for (BoundarySurface bs : bi.getBoundarySurfaces()) { for (Installation bi : bo.getBridgeInstallations()) {
updateEdgesAndVertices(bs); updateEdgesAndVertices(bi);
} for (BoundarySurface bs : bi.getBoundarySurfaces()) {
} updateEdgesAndVertices(bs);
model.addBridge(bo); }
} }
model.addBridge(bo);
private void mapAbstractBridge(AbstractBridge ab, BridgeObject bo) { }
mapAbstractConstruction(ab, bo);
for (BridgeConstructiveElementProperty eleProp : ab.getBridgeConstructiveElements()) { private void mapAbstractBridge(AbstractBridge ab, BridgeObject bo) {
if (!eleProp.isSetObject()) { mapAbstractConstruction(ab, bo);
continue; for (BridgeConstructiveElementProperty eleProp : ab.getBridgeConstructiveElements()) {
} if (!eleProp.isSetObject()) {
org.citygml4j.core.model.bridge.BridgeConstructiveElement constructiveElement = eleProp.getObject(); continue;
BridgeConstructiveElement cdEle = new BridgeConstructiveElement(constructiveElement); }
mapConstructiveElement(constructiveElement, cdEle); org.citygml4j.core.model.bridge.BridgeConstructiveElement constructiveElement = eleProp.getObject();
bo.addConstructiveElement(cdEle); BridgeConstructiveElement cdEle = new BridgeConstructiveElement(constructiveElement);
} mapConstructiveElement(constructiveElement, cdEle);
bo.addConstructiveElement(cdEle);
List<BridgeInstallationProperty> bridgeInstallations = ab.getBridgeInstallations(); }
for (BridgeInstallationProperty installationProp : bridgeInstallations) {
var gmlBi = installationProp.getObject(); List<BridgeInstallationProperty> bridgeInstallations = ab.getBridgeInstallations();
if (gmlBi == null) { for (BridgeInstallationProperty installationProp : bridgeInstallations) {
// ignore empty properties var gmlBi = installationProp.getObject();
continue; if (gmlBi == null) {
} // ignore empty properties
Installation bi = mapBridgeInstallation(gmlBi); continue;
bo.addBridgeInstallation(bi); }
} Installation bi = mapBridgeInstallation(gmlBi);
bo.addBridgeInstallation(bi);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); }
for (AbstractSpaceBoundaryProperty surfaceProp : ab.getBoundaries()) {
if (!surfaceProp.isSetObject()) { SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
continue; for (AbstractSpaceBoundaryProperty surfaceProp : ab.getBoundaries()) {
} if (!surfaceProp.isSetObject()) {
AbstractSpaceBoundary surface = surfaceProp.getObject(); continue;
surface.accept(surfaceMapper); }
} AbstractSpaceBoundary surface = surfaceProp.getObject();
updatePartOfSurface(bo, surfaceMapper); surface.accept(surfaceMapper);
}
for (BoundarySurface bs : bo.getBoundarySurfaces()) { updatePartOfSurface(bo, surfaceMapper);
updateEdgesAndVertices(bs);
} for (BoundarySurface bs : bo.getBoundarySurfaces()) {
updateEdgesAndVertices(bs);
bo.unsetGmlGeometries(); }
}
bo.unsetGmlGeometries();
private Installation mapBridgeInstallation(BridgeInstallation gmlBi) { }
Installation bi = new Installation();
bi.setGmlObject(gmlBi); private Installation mapBridgeInstallation(BridgeInstallation gmlBi) {
mapAbstractOccupiedSpace(gmlBi, bi); Installation bi = new Installation();
GeometryProperty<?> lod2Prop = gmlBi.getDeprecatedProperties().getLod2Geometry(); bi.setGmlObject(gmlBi);
parseAndAddAbstractGeometry(lod2Prop, Lod.LOD2, bi); mapAbstractOccupiedSpace(gmlBi, bi);
GeometryProperty<?> lod3Prop = gmlBi.getDeprecatedProperties().getLod3Geometry(); GeometryProperty<?> lod2Prop = gmlBi.getDeprecatedProperties().getLod2Geometry();
parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, bi); parseAndAddAbstractGeometry(lod2Prop, Lod.LOD2, bi);
GeometryProperty<?> lod4Prop = gmlBi.getDeprecatedProperties().getLod4Geometry(); GeometryProperty<?> lod3Prop = gmlBi.getDeprecatedProperties().getLod3Geometry();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi); parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, bi);
bi.unsetGmlGeometries(); GeometryProperty<?> lod4Prop = gmlBi.getDeprecatedProperties().getLod4Geometry();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); bi.unsetGmlGeometries();
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) {
if (!surfaceProp.isSetObject()) { SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
continue; for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) {
} if (!surfaceProp.isSetObject()) {
AbstractSpaceBoundary surface = surfaceProp.getObject(); continue;
surface.accept(surfaceMapper); }
} AbstractSpaceBoundary surface = surfaceProp.getObject();
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { surface.accept(surfaceMapper);
bi.addBoundarySurface(bs); }
for (Geometry geom : bs.getGeometries()) { for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
for (Polygon p : geom.getPolygons()) { bi.addBoundarySurface(bs);
p.setPartOfSurface(bs); for (Geometry geom : bs.getGeometries()) {
p.setPartOfInstallation(bi); for (Polygon p : geom.getPolygons()) {
} p.setPartOfSurface(bs);
} p.setPartOfInstallation(bi);
} }
for (Geometry geom : bi.getGeometries()) { }
for (Polygon p : geom.getPolygons()) { }
p.setPartOfInstallation(bi); for (Geometry geom : bi.getGeometries()) {
} for (Polygon p : geom.getPolygons()) {
} p.setPartOfInstallation(bi);
}
return bi; }
}
return bi;
@Override }
public void visit(Tunnel tunnel) {
de.hft.stuttgart.citydoctor2.datastructure.Tunnel tu = new de.hft.stuttgart.citydoctor2.datastructure.Tunnel(); @Override
for (TunnelPartProperty tPartProperty : tunnel.getTunnelParts()) { public void visit(Tunnel tunnel) {
if (!tPartProperty.isSetObject()) { de.hft.stuttgart.citydoctor2.datastructure.Tunnel tu = new de.hft.stuttgart.citydoctor2.datastructure.Tunnel();
continue; for (TunnelPartProperty tPartProperty : tunnel.getTunnelParts()) {
} if (!tPartProperty.isSetObject()) {
org.citygml4j.core.model.tunnel.TunnelPart gmlTunnelPart = tPartProperty.getObject(); continue;
TunnelPart tPart = new TunnelPart(tu); }
readAbstractTunnel(gmlTunnelPart, tPart); org.citygml4j.core.model.tunnel.TunnelPart gmlTunnelPart = tPartProperty.getObject();
tu.addTunnelPart(tPart); TunnelPart tPart = new TunnelPart(tu);
} readAbstractTunnel(gmlTunnelPart, tPart);
readAbstractTunnel(tunnel, tu); tu.addTunnelPart(tPart);
resolveAndClearReferences(); }
updateEdgesAndVertices(tu); readAbstractTunnel(tunnel, tu);
for (TunnelPart part : tu.getTunnelParts()) { resolveAndClearReferences();
updateEdgesAndVertices(part); updateEdgesAndVertices(tu);
} for (TunnelPart part : tu.getTunnelParts()) {
model.addTunnel(tu); updateEdgesAndVertices(part);
}
} model.addTunnel(tu);
private void readAbstractTunnel(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) { }
mapAbstractOccupiedSpace(gmlTunnel, cdTunnel);
cdTunnel.setGmlObject(gmlTunnel); private void readAbstractTunnel(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
mapAbstractOccupiedSpace(gmlTunnel, cdTunnel);
// parse deprecated geometries cdTunnel.setGmlObject(gmlTunnel);
parseAndAddMultiSurface(gmlTunnel.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, cdTunnel);
parseAndAddMultiSurface(gmlTunnel.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, cdTunnel); // parse deprecated geometries
parseAndAddSolid(gmlTunnel.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, cdTunnel); parseAndAddMultiSurface(gmlTunnel.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, cdTunnel);
parseAndAddMultiSurface(gmlTunnel.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, cdTunnel);
for (TunnelInstallationProperty tiProp : gmlTunnel.getTunnelInstallations()) { parseAndAddSolid(gmlTunnel.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, cdTunnel);
var gmlTi = tiProp.getObject();
if (gmlTi == null) { parseTunnelInstallations(gmlTunnel, cdTunnel);
// ignore empty properties parseHollowSpaces(gmlTunnel, cdTunnel);
continue; parseTunnelFurniture(gmlTunnel, cdTunnel);
} parseTunnelConstructiveElements(gmlTunnel, cdTunnel);
Installation ti = mapTunnelInstallation(gmlTi); parseTunnelBoundarySurfaces(gmlTunnel);
cdTunnel.addTunnelInstallation(ti); for (Installation ti : cdTunnel.getTunnelInstallations()) {
} updateEdgesAndVertices(ti);
for (BoundarySurface bs : ti.getBoundarySurfaces()) {
for (HollowSpaceProperty thProp : gmlTunnel.getHollowSpaces()) { updateEdgesAndVertices(bs);
var gmlTh = thProp.getObject(); for (Opening o : bs.getOpenings()) {
if (gmlTh == null) { updateEdgesAndVertices(o);
continue; }
} }
TunnelHollow br = mapTunnelHollow(gmlTh); }
cdTunnel.addTunnelHollow(br);
}
for (Installation ti : cdTunnel.getTunnelInstallations()) { cdTunnel.unsetGmlGeometries();
updateEdgesAndVertices(ti); resolveAndClearReferences();
for (BoundarySurface bs : ti.getBoundarySurfaces()) { updateEdgesAndVertices(cdTunnel);
updateEdgesAndVertices(bs); }
for (Opening o : bs.getOpenings()) {
updateEdgesAndVertices(o); 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()) {
for (TunnelFurnitureProperty tfProp : gmlTunnel.getTunnelFurniture()) { continue;
var gmlTf = tfProp.getObject(); }
if (gmlTf == null) { AbstractSpaceBoundary surface = surfaceProp.getObject();
continue; surface.accept(surfaceMapper);
} }
TunnelFurniture tf = mapTunnelFurniture(gmlTf); for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
cdTunnel.addTunnelFurniture(tf); updateEdgesAndVertices(bs);
} for (Opening o : bs.getOpenings()) {
updateEdgesAndVertices(o);
for (TunnelConstructiveElementProperty teProp : gmlTunnel.getTunnelConstructiveElements()) { }
var gmlTc = teProp.getObject(); }
if (gmlTc == null) { }
continue;
} private void parseTunnelConstructiveElements(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
TunnelConstructiveElement tc = mapTunnelConstructiveElement(gmlTc); for (TunnelConstructiveElementProperty teProp : gmlTunnel.getTunnelConstructiveElements()) {
cdTunnel.addTunnelConstructiveElement(tc); var gmlTc = teProp.getObject();
} if (gmlTc == null) {
continue;
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); }
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTunnel.getBoundaries()) { TunnelConstructiveElement tc = mapTunnelConstructiveElement(gmlTc);
if (!surfaceProp.isSetObject()) { cdTunnel.addTunnelConstructiveElement(tc);
continue; }
} }
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper); private void parseTunnelFurniture(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
} for (TunnelFurnitureProperty tfProp : gmlTunnel.getTunnelFurniture()) {
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { var gmlTf = tfProp.getObject();
updateEdgesAndVertices(bs); if (gmlTf == null) {
for (Opening o : bs.getOpenings()) { continue;
updateEdgesAndVertices(o); }
} TunnelFurniture tf = mapTunnelFurniture(gmlTf);
} cdTunnel.addTunnelFurniture(tf);
}
}
cdTunnel.unsetGmlGeometries();
resolveAndClearReferences(); private void parseHollowSpaces(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
updateEdgesAndVertices(cdTunnel); for (HollowSpaceProperty thProp : gmlTunnel.getHollowSpaces()) {
} var gmlTh = thProp.getObject();
if (gmlTh == null) {
private Installation mapTunnelInstallation(TunnelInstallation gmlTi) { continue;
Installation ti = new Installation(); }
ti.setGmlObject(gmlTi); TunnelHollow br = mapTunnelHollow(gmlTh);
mapAbstractOccupiedSpace(gmlTi, ti); cdTunnel.addTunnelHollow(br);
GeometryProperty<?> lod2Prop = gmlTi.getDeprecatedProperties().getLod2Geometry(); }
parseAndAddAbstractGeometry(lod2Prop, Lod.LOD2, ti); }
GeometryProperty<?> lod3Prop = gmlTi.getDeprecatedProperties().getLod3Geometry();
parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, ti); private void parseTunnelInstallations(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
GeometryProperty<?> lod4Prop = gmlTi.getDeprecatedProperties().getLod4Geometry(); for (TunnelInstallationProperty tiProp : gmlTunnel.getTunnelInstallations()) {
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, ti); var gmlTi = tiProp.getObject();
ti.unsetGmlGeometries(); if (gmlTi == null) {
// ignore empty properties
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); continue;
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTi.getBoundaries()) { }
if (!surfaceProp.isSetObject()) { Installation ti = mapTunnelInstallation(gmlTi);
continue; cdTunnel.addTunnelInstallation(ti);
} }
AbstractSpaceBoundary surface = surfaceProp.getObject(); }
surface.accept(surfaceMapper);
} private Installation mapTunnelInstallation(TunnelInstallation gmlTi) {
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { Installation ti = new Installation();
ti.addBoundarySurface(bs); ti.setGmlObject(gmlTi);
for (Geometry geom : bs.getGeometries()) { mapAbstractOccupiedSpace(gmlTi, ti);
for (Polygon p : geom.getPolygons()) { GeometryProperty<?> lod2Prop = gmlTi.getDeprecatedProperties().getLod2Geometry();
p.setPartOfSurface(bs); parseAndAddAbstractGeometry(lod2Prop, Lod.LOD2, ti);
p.setPartOfInstallation(ti); GeometryProperty<?> lod3Prop = gmlTi.getDeprecatedProperties().getLod3Geometry();
} parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, ti);
} GeometryProperty<?> lod4Prop = gmlTi.getDeprecatedProperties().getLod4Geometry();
} parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, ti);
for (Geometry geom : ti.getGeometries()) { ti.unsetGmlGeometries();
for (Polygon p : geom.getPolygons()) {
p.setPartOfInstallation(ti); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
} for (AbstractSpaceBoundaryProperty surfaceProp : gmlTi.getBoundaries()) {
} if (!surfaceProp.isSetObject()) {
continue;
return ti; }
} AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
private TunnelHollow mapTunnelHollow(HollowSpace gmlHo) { }
TunnelHollow tHollow = new TunnelHollow(); for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
tHollow.setGmlObject(gmlHo); ti.addBoundarySurface(bs);
mapAbstractUnoccupiedSpace(gmlHo, tHollow); for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); p.setPartOfSurface(bs);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlHo.getBoundaries()) { p.setPartOfInstallation(ti);
if (!surfaceProp.isSetObject()) { }
continue; }
} }
AbstractSpaceBoundary surface = surfaceProp.getObject(); for (Geometry geom : ti.getGeometries()) {
surface.accept(surfaceMapper); for (Polygon p : geom.getPolygons()) {
} p.setPartOfInstallation(ti);
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { }
tHollow.addBoundarySurface(bs); }
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) { return ti;
p.setPartOfSurface(bs); }
}
} private TunnelHollow mapTunnelHollow(HollowSpace gmlHo) {
} TunnelHollow tHollow = new TunnelHollow();
for (TunnelInstallationProperty tiProp : gmlHo.getTunnelInstallations()) { tHollow.setGmlObject(gmlHo);
var gmlTi = tiProp.getObject(); mapAbstractUnoccupiedSpace(gmlHo, tHollow);
if (gmlTi == null) {
// ignore empty properties SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
continue; for (AbstractSpaceBoundaryProperty surfaceProp : gmlHo.getBoundaries()) {
} if (!surfaceProp.isSetObject()) {
Installation bi = mapTunnelInstallation(gmlTi); continue;
tHollow.addRoomInstallation(bi); }
} AbstractSpaceBoundary surface = surfaceProp.getObject();
for (TunnelFurnitureProperty tfProp : gmlHo.getTunnelFurniture()) { surface.accept(surfaceMapper);
var gmlHref = tfProp.getHref(); }
if (gmlHref == null) { for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
continue; tHollow.addBoundarySurface(bs);
} for (Geometry geom : bs.getGeometries()) {
tHollow.addFurnitureRef(tfProp); for (Polygon p : geom.getPolygons()) {
} p.setPartOfSurface(bs);
return tHollow; }
} }
}
private TunnelFurniture mapTunnelFurniture(org.citygml4j.core.model.tunnel.TunnelFurniture gmlTf) { for (TunnelInstallationProperty tiProp : gmlHo.getTunnelInstallations()) {
TunnelFurniture tf = new TunnelFurniture(); var gmlTi = tiProp.getObject();
tf.setGmlObject(gmlTf); if (gmlTi == null) {
mapAbstractOccupiedSpace(gmlTf, tf); // ignore empty properties
tf.unsetGmlGeometries(); continue;
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); }
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTf.getBoundaries()) { Installation bi = mapTunnelInstallation(gmlTi);
if (!surfaceProp.isSetObject()) { tHollow.addRoomInstallation(bi);
continue; }
} for (TunnelFurnitureProperty tfProp : gmlHo.getTunnelFurniture()) {
AbstractSpaceBoundary surface = surfaceProp.getObject(); var gmlHref = tfProp.getHref();
surface.accept(surfaceMapper); if (gmlHref == null) {
} continue;
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { }
tf.addBoundarySurface(bs); tHollow.addFurnitureRef(tfProp);
for (Geometry geom : bs.getGeometries()) { }
for (Polygon p : geom.getPolygons()) { return tHollow;
p.setPartOfSurface(bs); }
}
} private TunnelFurniture mapTunnelFurniture(org.citygml4j.core.model.tunnel.TunnelFurniture gmlTf) {
} TunnelFurniture tf = new TunnelFurniture();
return tf; tf.setGmlObject(gmlTf);
} mapAbstractOccupiedSpace(gmlTf, tf);
tf.unsetGmlGeometries();
private TunnelConstructiveElement mapTunnelConstructiveElement(org.citygml4j.core.model.tunnel.TunnelConstructiveElement gmlTe) { SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
TunnelConstructiveElement te = new TunnelConstructiveElement(gmlTe); for (AbstractSpaceBoundaryProperty surfaceProp : gmlTf.getBoundaries()) {
mapAbstractOccupiedSpace(gmlTe, te); if (!surfaceProp.isSetObject()) {
te.unsetGmlGeometries(); continue;
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); }
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTe.getBoundaries()) { AbstractSpaceBoundary surface = surfaceProp.getObject();
if (!surfaceProp.isSetObject()) { surface.accept(surfaceMapper);
continue; }
} for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
AbstractSpaceBoundary surface = surfaceProp.getObject(); tf.addBoundarySurface(bs);
surface.accept(surfaceMapper); for (Geometry geom : bs.getGeometries()) {
} for (Polygon p : geom.getPolygons()) {
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { p.setPartOfSurface(bs);
te.addBoundarySurface(bs); }
for (Geometry geom : bs.getGeometries()) { }
for (Polygon p : geom.getPolygons()) { }
p.setPartOfSurface(bs); return tf;
} }
}
} private TunnelConstructiveElement mapTunnelConstructiveElement(
return te; org.citygml4j.core.model.tunnel.TunnelConstructiveElement gmlTe) {
} TunnelConstructiveElement te = new TunnelConstructiveElement(gmlTe);
mapAbstractOccupiedSpace(gmlTe, te);
private void updatePartOfSurface(BridgeObject bo, SurfaceMapper surfaceMapper) { te.unsetGmlGeometries();
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
bo.addBoundarySurface(bs); for (AbstractSpaceBoundaryProperty surfaceProp : gmlTe.getBoundaries()) {
for (Geometry geom : bs.getGeometries()) { if (!surfaceProp.isSetObject()) {
for (Polygon p : geom.getPolygons()) { continue;
p.setPartOfSurface(bs); }
} AbstractSpaceBoundary surface = surfaceProp.getObject();
} surface.accept(surfaceMapper);
} }
} for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
te.addBoundarySurface(bs);
private void mapConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement ele, BridgeConstructiveElement bce) { for (Geometry geom : bs.getGeometries()) {
mapAbstractConstructiveElement(ele, bce); for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); }
for (AbstractSpaceBoundaryProperty surfaceProp : ele.getBoundaries()) { }
if (!surfaceProp.isSetObject()) { }
continue; return te;
} }
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper); private void updatePartOfSurface(BridgeObject bo, SurfaceMapper surfaceMapper) {
} for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { bo.addBoundarySurface(bs);
bce.addBoundarySurface(bs); for (Geometry geom : bs.getGeometries()) {
} for (Polygon p : geom.getPolygons()) {
} p.setPartOfSurface(bs);
}
private void mapAbstractConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement ele, BridgeConstructiveElement bce) { }
mapAbstractOccupiedSpace(ele, bce); }
} }
private void mapAbstractConstruction(AbstractConstruction ac, BridgeObject bo) { private void mapConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement ele,
mapAbstractOccupiedSpace(ac, bo); BridgeConstructiveElement bce) {
} mapAbstractConstructiveElement(ele, bce);
@Override SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
public void visit(AuxiliaryTrafficArea ata) { for (AbstractSpaceBoundaryProperty surfaceProp : ele.getBoundaries()) {
TransportationObject to = new TransportationObject(TransportationType.AUXILLIARY_TRAFFIC_AREA); if (!surfaceProp.isSetObject()) {
mapAbstractThematicSurface(ata, to); continue;
finishTransportationMapping(to); }
} AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
@Override }
public void visit(TrafficArea ta) { for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
TransportationObject to = new TransportationObject(TransportationType.TRAFFIC_AREA); bce.addBoundarySurface(bs);
mapAbstractThematicSurface(ta, to); }
finishTransportationMapping(to); }
}
private void mapAbstractConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement ele,
@Override BridgeConstructiveElement bce) {
public void visit(Road road) { mapAbstractOccupiedSpace(ele, bce);
TransportationObject to = new TransportationObject(TransportationType.ROAD); }
mapAbstractTransportationSpace(road, to);
finishTransportationMapping(to); private void mapAbstractConstruction(AbstractConstruction ac, BridgeObject bo) {
} mapAbstractOccupiedSpace(ac, bo);
}
private void mapAbstractThematicSurface(AbstractThematicSurface ats, CityObject co) {
mapAbstractSpaceBoundary(ats, co); @Override
parseAndAddMultiSurface(ats.getLod0MultiSurface(), Lod.LOD0, co); public void visit(AuxiliaryTrafficArea ata) {
parseAndAddMultiSurface(ats.getLod1MultiSurface(), Lod.LOD1, co); TransportationObject to = new TransportationObject(TransportationType.AUXILLIARY_TRAFFIC_AREA);
parseAndAddMultiSurface(ats.getLod2MultiSurface(), Lod.LOD2, co); mapAbstractThematicSurface(ata, to);
parseAndAddMultiSurface(ats.getLod3MultiSurface(), Lod.LOD3, co); finishTransportationMapping(to);
parseAndAddMultiSurface(ats.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, co); }
}
@Override
private void mapAbstractSpaceBoundary(AbstractSpaceBoundary asb, CityObject co) { public void visit(TrafficArea ta) {
mapAbstractCityObject(asb, co); TransportationObject to = new TransportationObject(TransportationType.TRAFFIC_AREA);
} mapAbstractThematicSurface(ta, to);
finishTransportationMapping(to);
private void mapAbstractCityObject(AbstractCityObject aco, CityObject to) { }
mapAbstractFeatureWithLifespan(aco, to);
} @Override
public void visit(Road road) {
private void mapAbstractFeatureWithLifespan(AbstractFeatureWithLifespan afwl, CityObject to) { TransportationObject to = new TransportationObject(TransportationType.ROAD);
mapAbstractFeature(afwl, to); mapAbstractTransportationSpace(road, to);
} finishTransportationMapping(to);
}
private void mapAbstractFeature(AbstractFeature af, CityObject to) {
mapAbstractGML(af, to); private void mapAbstractThematicSurface(AbstractThematicSurface ats, CityObject co) {
} mapAbstractSpaceBoundary(ats, co);
parseAndAddMultiSurface(ats.getLod0MultiSurface(), Lod.LOD0, co);
private void mapAbstractGML(AbstractGML ag, CityObject to) { parseAndAddMultiSurface(ats.getLod1MultiSurface(), Lod.LOD1, co);
parseId(ag, to); parseAndAddMultiSurface(ats.getLod2MultiSurface(), Lod.LOD2, co);
} parseAndAddMultiSurface(ats.getLod3MultiSurface(), Lod.LOD3, co);
parseAndAddMultiSurface(ats.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, co);
@Override }
public void visit(Railway railway) {
TransportationObject to = new TransportationObject(TransportationType.RAILWAY); private void mapAbstractSpaceBoundary(AbstractSpaceBoundary asb, CityObject co) {
mapAbstractTransportationSpace(railway, to); mapAbstractCityObject(asb, co);
finishTransportationMapping(to); }
}
private void mapAbstractCityObject(AbstractCityObject aco, CityObject to) {
@Override mapAbstractFeatureWithLifespan(aco, to);
public void visit(Square square) { }
TransportationObject to = new TransportationObject(TransportationType.SQUARE);
mapAbstractTransportationSpace(square, to); private void mapAbstractFeatureWithLifespan(AbstractFeatureWithLifespan afwl, CityObject to) {
finishTransportationMapping(to); mapAbstractFeature(afwl, to);
} }
@Override private void mapAbstractFeature(AbstractFeature af, CityObject to) {
public void visit(Track track) { mapAbstractGML(af, to);
TransportationObject to = new TransportationObject(TransportationType.TRACK); }
mapAbstractTransportationSpace(track, to);
finishTransportationMapping(to); private void mapAbstractGML(AbstractGML ag, CityObject to) {
} parseId(ag, to);
}
@Override
public void visit(TransportationComplex transportationComplex) { @Override
TransportationObject to = new TransportationObject(TransportationType.TRANSPORTATION_COMPLEX); public void visit(Railway railway) {
mapAbstractTransportationSpace(transportationComplex, to); TransportationObject to = new TransportationObject(TransportationType.RAILWAY);
finishTransportationMapping(to); mapAbstractTransportationSpace(railway, to);
} finishTransportationMapping(to);
}
private void finishTransportationMapping(TransportationObject to) {
finishCityObjectConstruction(to); @Override
model.addTransportation(to); public void visit(Square square) {
} TransportationObject to = new TransportationObject(TransportationType.SQUARE);
mapAbstractTransportationSpace(square, to);
private void finishCityObjectConstruction(CityObject co) { finishTransportationMapping(to);
co.unsetGmlGeometries(); }
resolveAndClearReferences();
updateEdgesAndVertices(co); @Override
} public void visit(Track track) {
TransportationObject to = new TransportationObject(TransportationType.TRACK);
private void mapAbstractTransportationSpace(AbstractTransportationSpace ats, TransportationObject to) { mapAbstractTransportationSpace(track, to);
to.setGmlObject(ats); finishTransportationMapping(to);
parseAbstractTransportationSpaceGeometries(ats, to); }
for (TrafficSpaceProperty tsp : ats.getTrafficSpaces()) {
if (tsp.isSetObject()) { @Override
TransportationObject trafficSpace = new TransportationObject(TransportationType.TRAFFIC_SPACE); public void visit(TransportationComplex transportationComplex) {
mapTrafficSpace(tsp.getObject(), trafficSpace); TransportationObject to = new TransportationObject(TransportationType.TRANSPORTATION_COMPLEX);
finishTransportationMapping(trafficSpace); mapAbstractTransportationSpace(transportationComplex, to);
to.getChildren().add(trafficSpace); finishTransportationMapping(to);
} }
}
for (AuxiliaryTrafficSpaceProperty auxTrafficProp : ats.getAuxiliaryTrafficSpaces()) { private void finishTransportationMapping(TransportationObject to) {
if (auxTrafficProp.isSetObject()) { finishCityObjectConstruction(to);
TransportationObject trafficSpace = parseAuxiliaryTrafficSpace(auxTrafficProp.getObject()); model.addTransportation(to);
finishTransportationMapping(trafficSpace); }
to.addChild(trafficSpace);
} private void finishCityObjectConstruction(CityObject co) {
} co.unsetGmlGeometries();
} resolveAndClearReferences();
updateEdgesAndVertices(co);
private void mapTrafficSpace(TrafficSpace ts, TransportationObject to) { }
mapAbstractUnoccupiedSpace(ts, to);
} private void mapAbstractTransportationSpace(AbstractTransportationSpace ats, TransportationObject to) {
to.setGmlObject(ats);
private void mapAbstractUnoccupiedSpace(AbstractUnoccupiedSpace aus, CityObject co) { parseAbstractTransportationSpaceGeometries(ats, to);
mapAbstractPhysicalSpace(aus, co); for (TrafficSpaceProperty tsp : ats.getTrafficSpaces()) {
} if (tsp.isSetObject()) {
TransportationObject trafficSpace = new TransportationObject(TransportationType.TRAFFIC_SPACE);
private TransportationObject parseAuxiliaryTrafficSpace(AuxiliaryTrafficSpace ats) { mapTrafficSpace(tsp.getObject(), trafficSpace);
TransportationObject to = new TransportationObject(TransportationType.AUXILLIARY_TRAFFIC_SPACE); finishTransportationMapping(trafficSpace);
parseAbstractSpaceGeometries(ats, to); to.getChildren().add(trafficSpace);
finishCityObjectConstruction(to); }
return to; }
} for (AuxiliaryTrafficSpaceProperty auxTrafficProp : ats.getAuxiliaryTrafficSpaces()) {
if (auxTrafficProp.isSetObject()) {
private void parseAbstractTransportationSpaceGeometries(AbstractTransportationSpace space, CityObject co) { TransportationObject trafficSpace = parseAuxiliaryTrafficSpace(auxTrafficProp.getObject());
parseAndAddMultiSurface(space.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, co); finishTransportationMapping(trafficSpace);
parseAndAddMultiSurface(space.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, co); to.addChild(trafficSpace);
} }
}
private void parseAbstractSpaceGeometries(AbstractSpace as, CityObject co) { }
parseAndAddMultiSurface(as.getLod0MultiSurface(), Lod.LOD0, co);
parseAndAddMultiSurface(as.getLod2MultiSurface(), Lod.LOD2, co); private void mapTrafficSpace(TrafficSpace ts, TransportationObject to) {
parseAndAddMultiSurface(as.getLod3MultiSurface(), Lod.LOD3, co); mapAbstractUnoccupiedSpace(ts, to);
parseAndAddSolid(as.getLod1Solid(), Lod.LOD1, co); }
parseAndAddSolid(as.getLod2Solid(), Lod.LOD2, co);
parseAndAddSolid(as.getLod3Solid(), Lod.LOD3, co); private void mapAbstractUnoccupiedSpace(AbstractUnoccupiedSpace aus, CityObject co) {
mapAbstractPhysicalSpace(aus, co);
} }
private void parseAndAddMultiSurface(MultiSurfaceProperty msp, Lod lod, CityObject co) { private TransportationObject parseAuxiliaryTrafficSpace(AuxiliaryTrafficSpace ats) {
if (msp == null || msp.getObject() == null) { TransportationObject to = new TransportationObject(TransportationType.AUXILLIARY_TRAFFIC_SPACE);
return; parseAbstractSpaceGeometries(ats, to);
} finishCityObjectConstruction(to);
Geometry geom = parseMultiSurface(msp.getObject(), lod); return to;
co.addGeometry(geom); }
}
private void parseAbstractTransportationSpaceGeometries(AbstractTransportationSpace space, CityObject co) {
private void parseAndAddSolid(SolidProperty sp, Lod lod, CityObject co) { parseAndAddMultiSurface(space.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, co);
if (sp == null || sp.getObject() == null) { parseAndAddMultiSurface(space.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, co);
return; }
}
Geometry geom = parseSolid(sp.getObject(), lod); private void parseAbstractSpaceGeometries(AbstractSpace as, CityObject co) {
if (geom != null) { parseAndAddMultiSurface(as.getLod0MultiSurface(), Lod.LOD0, co);
co.addGeometry(geom); parseAndAddMultiSurface(as.getLod2MultiSurface(), Lod.LOD2, co);
} parseAndAddMultiSurface(as.getLod3MultiSurface(), Lod.LOD3, co);
} parseAndAddSolid(as.getLod1Solid(), Lod.LOD1, co);
parseAndAddSolid(as.getLod2Solid(), Lod.LOD2, co);
private void parseAndAddCompositeSurface(MultiSurfaceProperty ms, Lod lod, CityObject co) { parseAndAddSolid(as.getLod3Solid(), Lod.LOD3, co);
if (ms == null || ms.getObject() == null) {
return; }
}
List<SurfaceProperty> surfaces = ms.getObject().getSurfaceMember(); private void parseAndAddMultiSurface(MultiSurfaceProperty msp, Lod lod, CityObject co) {
for (SurfaceProperty surface : surfaces) { if (msp == null || msp.getObject() == null) {
if (surface.getObject() instanceof CompositeSurface cs) { return;
Geometry geom = parseCompositeSurface(cs, lod); }
if (geom != null) { Geometry geom = parseMultiSurface(msp.getObject(), lod);
co.addGeometry(geom); co.addGeometry(geom);
} }
}
} private void parseAndAddSolid(SolidProperty sp, Lod lod, CityObject co) {
if (sp == null || sp.getObject() == null) {
} return;
}
private void parseImplicitGeometry(AbstractOccupiedSpace aos, CityObject co) { Geometry geom = parseSolid(sp.getObject(), lod);
for (int i = 1; i <= 3; i++) { if (geom != null) {
if (aos.getImplicitRepresentation(i) == null) { co.addGeometry(geom);
continue; }
} }
if (aos.getImplicitRepresentation(i).getObject() != null) {
ImplicitGeometry impGeom = aos.getImplicitRepresentation(i).getObject(); // private void parseAndAddCompositeSurface(MultiSurfaceProperty ms, Lod lod, CityObject co) {
ImplicitGeometryHolder igh = resolveImplicitGeometry(impGeom, i); // if (ms == null || ms.getObject() == null) {
if (igh != null) { // return;
co.addGeometry(igh); // }
} // List<SurfaceProperty> surfaces = ms.getObject().getSurfaceMember();
} else if (aos.getImplicitRepresentation(i).getHref() != null) { // for (SurfaceProperty surface : surfaces) {
// Hrefs of ImplicitGeometries point to its RelativeGeometry. // if (surface.getObject() instanceof CompositeSurface cs) {
// Can be ignored for CD since the Href is only used for repeating the RelativeGeometry at different LODs // Geometry geom = parseCompositeSurface(cs, lod);
} // co.addGeometry(geom);
// }
// }
} // }
} private void parseImplicitGeometry(AbstractOccupiedSpace aos, CityObject co) {
for (int i = 1; i <= 3; i++) {
private ImplicitGeometryHolder resolveImplicitGeometry(ImplicitGeometry ig, int lodInt) { if (aos.getImplicitRepresentation(i) == null) {
ImplicitGeometryHolder igh = null; continue;
if (ig.getLibraryObject() != null) { }
Path libraryObjectPath = directory.resolve(ig.getLibraryObject()); if (aos.getImplicitRepresentation(i).getObject() != null) {
LibraryObject libObj = LibraryObject.of(libraryObjectPath, config); ImplicitGeometry impGeom = aos.getImplicitRepresentation(i).getObject();
if (libObj != null) { ImplicitGeometryHolder igh = resolveImplicitGeometry(impGeom, i);
igh = new ImplicitGeometryHolder(ig, libObj); if (igh != null) {
} co.addGeometry(igh);
} else if (ig.getRelativeGeometry() != null) { }
AbstractGeometry aGeom = ig.getRelativeGeometry().getObject(); } else if (aos.getImplicitRepresentation(i).getHref() != null) {
Geometry geom = null; // Hrefs of ImplicitGeometries point to its RelativeGeometry.
Lod lod = Lod.values()[lodInt]; // Can be ignored for CD since the Href is only used for repeating the
RelativeGeometry relGeo = null; // RelativeGeometry at different LODs
if (aGeom instanceof MultiSurface ms) { }
geom = parseMultiSurface(ms, lod);
} else if (aGeom instanceof Solid s) { }
geom = parseSolid(s, lod);
} else if (aGeom instanceof CompositeSurface cs) { }
geom = parseCompositeSurface(cs, lod);
} private ImplicitGeometryHolder resolveImplicitGeometry(ImplicitGeometry ig, int lodInt) {
if (geom != null) { ImplicitGeometryHolder igh = null;
relGeo = RelativeGeometry.of(geom); if (ig.getLibraryObject() != null) {
igh = new ImplicitGeometryHolder(ig, relGeo); Path libraryObjectPath = directory.resolve(ig.getLibraryObject());
} LibraryObject libObj = LibraryObject.of(libraryObjectPath, config);
if (libObj != null) {
} else { igh = new ImplicitGeometryHolder(ig, libObj);
logger.error(String.format("Implicit geometry of GML-ID %s has no referenced geometry.", ig.getId())); }
} } else if (ig.getRelativeGeometry() != null) {
return igh; AbstractGeometry aGeom = ig.getRelativeGeometry().getObject();
} Geometry geom = null;
Lod lod = Lod.values()[lodInt];
private void resolveAndClearReferences() { RelativeGeometry relGeo = null;
for (ResolvableReference ref : references) { if (aGeom instanceof MultiSurface ms) {
String href = ref.href(); geom = parseMultiSurface(ms, lod);
if (href.startsWith("#")) { } else if (aGeom instanceof Solid s) {
href = href.substring(1); geom = parseSolid(s, lod);
} } else if (aGeom instanceof CompositeSurface cs) {
Geometry geom = ref.geometry(); geom = parseCompositeSurface(cs, lod);
CompositeCollection comp = compositeMap.get(href); }
if (comp != null) { if (geom != null) {
comp.getCompositeMembers().forEach(geom::addPolygon); relGeo = RelativeGeometry.of(geom);
} else { igh = new ImplicitGeometryHolder(ig, relGeo);
ConcretePolygon concPoly = polygonMap.get(href); }
if (concPoly == null) {
if (logger.isWarnEnabled()) { } else {
logger.warn(Localization.getText("FeatureMapper.polygonUnreferenced"), href); logger.error("Implicit geometry of GML-ID {} has no referenced geometry.", ig.getId());
} }
} else { return igh;
LinkedPolygon lPoly = new LinkedPolygon(concPoly, geom); }
if (geom.getParent() instanceof BoundarySurface bs) {
lPoly.setPartOfSurface(bs); private void resolveAndClearReferences() {
if (bs.getParent() instanceof Installation bi) { for (ResolvableReference ref : references) {
lPoly.setPartOfInstallation(bi); String href = ref.href();
} if (href.startsWith("#")) {
} href = href.substring(1);
geom.addPolygon(lPoly); }
} Geometry geom = ref.geometry();
} CompositeCollection comp = compositeMap.get(href);
} if (comp != null) {
// composite collection, add each containing polygon to the geometry
// clear storage for polygons and vertices comp.getCompositeMembers().forEach(geom::addPolygon);
// probably faster than .clear() ? } else {
references = new ArrayList<>(); handlePolygonReference(href, geom);
vertexMap = new HashMap<>(); }
polygonMap = new HashMap<>(); }
}
// clear storage for polygons and vertices
private void readAbstractBuilding(org.citygml4j.core.model.building.AbstractBuilding gmlAb, references = new ArrayList<>();
AbstractBuilding cdBuilding) { vertexMap = new HashMap<>();
mapAbstractOccupiedSpace(gmlAb, cdBuilding); polygonMap = new HashMap<>();
cdBuilding.setGmlObject(gmlAb); }
// parse deprecated geometries private void handlePolygonReference(String href, Geometry geom) {
parseAndAddMultiSurface(gmlAb.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, cdBuilding); ConcretePolygon concPoly = polygonMap.get(href);
parseAndAddMultiSurface(gmlAb.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, cdBuilding); if (concPoly == null) {
parseAndAddSolid(gmlAb.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, cdBuilding); if (logger.isWarnEnabled()) {
logger.warn(Localization.getText("FeatureMapper.polygonUnreferenced"), href);
for (BuildingInstallationProperty biProp : gmlAb.getBuildingInstallations()) { }
var gmlBi = biProp.getObject(); } else {
if (gmlBi == null) { LinkedPolygon lPoly = new LinkedPolygon(concPoly, geom);
// ignore empty properties if (geom.getParent() instanceof BoundarySurface bs) {
continue; lPoly.setPartOfSurface(bs);
} if (bs.getParent() instanceof Installation bi) {
Installation bi = mapBuildingInstallation(gmlBi); lPoly.setPartOfInstallation(bi);
cdBuilding.addBuildingInstallation(bi); }
} }
geom.addPolygon(lPoly);
for (BuildingRoomProperty brProp : gmlAb.getBuildingRooms()) { }
var gmlBr = brProp.getObject(); }
if (gmlBr == null) {
continue; private void readAbstractBuilding(org.citygml4j.core.model.building.AbstractBuilding gmlAb,
} AbstractBuilding cdBuilding) {
BuildingRoom br = mapBuildingRoom(gmlBr); mapAbstractOccupiedSpace(gmlAb, cdBuilding);
cdBuilding.addBuildingRoom(br); cdBuilding.setGmlObject(gmlAb);
}
// parse deprecated geometries
for (AbstractBuildingSubdivisionProperty abs : gmlAb.getBuildingSubdivisions()) { parseAndAddMultiSurface(gmlAb.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, cdBuilding);
var gmlABS = abs.getObject(); parseAndAddMultiSurface(gmlAb.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, cdBuilding);
if (gmlABS == null) { parseAndAddSolid(gmlAb.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, cdBuilding);
continue;
} parseBuildingInstallations(gmlAb, cdBuilding);
if (gmlABS instanceof Storey gmlStorey) { parseBuildingRooms(gmlAb, cdBuilding);
de.hft.stuttgart.citydoctor2.datastructure.Storey storey = mapBuildingStorey(gmlStorey); parseBuildingSubdivisions(gmlAb, cdBuilding);
cdBuilding.addStorey(storey); parseBoundarySurfaces(gmlAb, cdBuilding);
} else if (gmlABS instanceof BuildingUnit gmlBU) { parseBuildingFurniture(gmlAb, cdBuilding);
de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit bu = mapBuildingUnit(gmlBU); }
cdBuilding.addBuildingUnit(bu);
} private void parseBuildingFurniture(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
} for (BuildingFurnitureProperty bfProp : gmlAb.getBuildingFurniture()) {
var gmlBf = bfProp.getObject();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); if (gmlBf == null) {
for (AbstractSpaceBoundaryProperty surfaceProp : gmlAb.getBoundaries()) { continue;
if (!surfaceProp.isSetObject()) { }
continue; BuildingRoomFurniture bf = mapBuildingFurniture(gmlBf);
} cdBuilding.addBuildingRoomFurniture(bf);
AbstractSpaceBoundary surface = surfaceProp.getObject(); }
surface.accept(surfaceMapper); }
}
updatePartOfSurface(cdBuilding, surfaceMapper); private void parseBoundarySurfaces(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
cdBuilding.unsetGmlGeometries(); for (AbstractSpaceBoundaryProperty surfaceProp : gmlAb.getBoundaries()) {
resolveAndClearReferences(); if (!surfaceProp.isSetObject()) {
updateEdgesAndVertices(cdBuilding); continue;
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { }
updateEdgesAndVertices(bs); AbstractSpaceBoundary surface = surfaceProp.getObject();
for (Opening o : bs.getOpenings()) { surface.accept(surfaceMapper);
updateEdgesAndVertices(o); }
} updatePartOfSurface(cdBuilding, surfaceMapper);
}
for (Installation bi : cdBuilding.getBuildingInstallations()) { cdBuilding.unsetGmlGeometries();
updateEdgesAndVertices(bi); resolveAndClearReferences();
for (BoundarySurface bs : bi.getBoundarySurfaces()) { updateEdgesAndVertices(cdBuilding);
updateEdgesAndVertices(bs); for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
for (Opening o : bs.getOpenings()) { updateEdgesAndVertices(bs);
updateEdgesAndVertices(o); for (Opening o : bs.getOpenings()) {
} updateEdgesAndVertices(o);
} }
} }
for (BuildingFurnitureProperty bfProp : gmlAb.getBuildingFurniture()) { }
var gmlBf = bfProp.getObject();
if (gmlBf == null) { private void parseBuildingSubdivisions(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
continue; for (AbstractBuildingSubdivisionProperty abs : gmlAb.getBuildingSubdivisions()) {
} var gmlABS = abs.getObject();
BuildingRoomFurniture bf = mapBuildingFurniture(gmlBf); if (gmlABS == null) {
cdBuilding.addBuildingRoomFurniture(bf); continue;
} }
} if (gmlABS instanceof Storey gmlStorey) {
de.hft.stuttgart.citydoctor2.datastructure.Storey storey = mapBuildingStorey(gmlStorey);
private BuildingRoom mapBuildingRoom(org.citygml4j.core.model.building.BuildingRoom gmlBr) { cdBuilding.addStorey(storey);
} else if (gmlABS instanceof BuildingUnit gmlBU) {
BuildingRoom br = new BuildingRoom(); de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit bu = mapBuildingUnit(gmlBU);
br.setGmlObject(gmlBr); cdBuilding.addBuildingUnit(bu);
mapAbstractUnoccupiedSpace(gmlBr, br); }
}
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); }
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBr.getBoundaries()) {
if (!surfaceProp.isSetObject()) { private void parseBuildingRooms(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
continue; for (BuildingRoomProperty brProp : gmlAb.getBuildingRooms()) {
} var gmlBr = brProp.getObject();
AbstractSpaceBoundary surface = surfaceProp.getObject(); if (gmlBr == null) {
surface.accept(surfaceMapper); continue;
} }
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { BuildingRoom br = mapBuildingRoom(gmlBr);
br.addBoundarySurface(bs); cdBuilding.addBuildingRoom(br);
for (Geometry geom : bs.getGeometries()) { }
for (Polygon p : geom.getPolygons()) { }
p.setPartOfSurface(bs);
} private void parseBuildingInstallations(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
} for (BuildingInstallationProperty biProp : gmlAb.getBuildingInstallations()) {
} var gmlBi = biProp.getObject();
for (BuildingInstallationProperty biProp : gmlBr.getBuildingInstallations()) { if (gmlBi == null) {
var gmlBi = biProp.getObject(); // ignore empty properties
if (gmlBi == null) { continue;
// ignore empty properties }
continue; Installation bi = mapBuildingInstallation(gmlBi);
} cdBuilding.addBuildingInstallation(bi);
Installation bi = mapBuildingInstallation(gmlBi); }
br.addRoomInstallation(bi); for (Installation bi : cdBuilding.getBuildingInstallations()) {
} updateEdgesAndVertices(bi);
for (BuildingFurnitureProperty bfProp : gmlBr.getBuildingFurniture()) { for (BoundarySurface bs : bi.getBoundarySurfaces()) {
var gmlHref = bfProp.getHref(); updateEdgesAndVertices(bs);
if (gmlHref == null) { for (Opening o : bs.getOpenings()) {
continue; updateEdgesAndVertices(o);
} }
br.addFurnitureRef(bfProp); }
} }
}
return br; private BuildingRoom mapBuildingRoom(org.citygml4j.core.model.building.BuildingRoom gmlBr) {
}
BuildingRoom br = new BuildingRoom();
private BuildingRoomFurniture mapBuildingFurniture(BuildingFurniture gmlAF) { br.setGmlObject(gmlBr);
BuildingRoomFurniture bf = new BuildingRoomFurniture(); mapAbstractUnoccupiedSpace(gmlBr, br);
bf.setGmlObject(gmlAF);
mapAbstractOccupiedSpace(gmlAF, bf); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
bf.unsetGmlGeometries(); for (AbstractSpaceBoundaryProperty surfaceProp : gmlBr.getBoundaries()) {
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); if (!surfaceProp.isSetObject()) {
for (AbstractSpaceBoundaryProperty surfaceProp : gmlAF.getBoundaries()) { continue;
if (!surfaceProp.isSetObject()) { }
continue; AbstractSpaceBoundary surface = surfaceProp.getObject();
} surface.accept(surfaceMapper);
AbstractSpaceBoundary surface = surfaceProp.getObject(); }
surface.accept(surfaceMapper); for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
} br.addBoundarySurface(bs);
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { for (Geometry geom : bs.getGeometries()) {
bf.addBoundarySurface(bs); for (Polygon p : geom.getPolygons()) {
for (Geometry geom : bs.getGeometries()) { p.setPartOfSurface(bs);
for (Polygon p : geom.getPolygons()) { }
p.setPartOfSurface(bs); }
} }
} for (BuildingInstallationProperty biProp : gmlBr.getBuildingInstallations()) {
} var gmlBi = biProp.getObject();
return bf; if (gmlBi == null) {
// ignore empty properties
} continue;
}
private de.hft.stuttgart.citydoctor2.datastructure.Storey mapBuildingStorey(Storey gmlStorey) { Installation bi = mapBuildingInstallation(gmlBi);
de.hft.stuttgart.citydoctor2.datastructure.Storey storey = new de.hft.stuttgart.citydoctor2.datastructure.Storey(); br.addRoomInstallation(bi);
storey.setGmlObject(gmlStorey); }
mapAbstractSpace(gmlStorey, storey); for (BuildingFurnitureProperty bfProp : gmlBr.getBuildingFurniture()) {
storey.unsetGmlGeometries(); var gmlHref = bfProp.getHref();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); if (gmlHref == null) {
for (AbstractSpaceBoundaryProperty surfaceProp : gmlStorey.getBoundaries()) { continue;
if (!surfaceProp.isSetObject()) { }
continue; br.addFurnitureRef(bfProp);
} }
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper); return br;
} }
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
storey.addBoundarySurface(bs); private BuildingRoomFurniture mapBuildingFurniture(BuildingFurniture gmlAF) {
for (Geometry geom : bs.getGeometries()) { BuildingRoomFurniture bf = new BuildingRoomFurniture();
for (Polygon p : geom.getPolygons()) { bf.setGmlObject(gmlAF);
p.setPartOfSurface(bs); mapAbstractOccupiedSpace(gmlAF, bf);
} bf.unsetGmlGeometries();
} SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
} for (AbstractSpaceBoundaryProperty surfaceProp : gmlAF.getBoundaries()) {
return storey; if (!surfaceProp.isSetObject()) {
} continue;
}
private de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit mapBuildingUnit(BuildingUnit gmlBU) { AbstractSpaceBoundary surface = surfaceProp.getObject();
de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit bu = new de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit(); surface.accept(surfaceMapper);
bu.setGmlObject(gmlBU); }
mapAbstractSpace(gmlBU, bu); for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
bu.unsetGmlGeometries(); bf.addBoundarySurface(bs);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); for (Geometry geom : bs.getGeometries()) {
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBU.getBoundaries()) { for (Polygon p : geom.getPolygons()) {
if (!surfaceProp.isSetObject()) { p.setPartOfSurface(bs);
continue; }
} }
AbstractSpaceBoundary surface = surfaceProp.getObject(); }
surface.accept(surfaceMapper); return bf;
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { }
bu.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) { private de.hft.stuttgart.citydoctor2.datastructure.Storey mapBuildingStorey(Storey gmlStorey) {
for (Polygon p : geom.getPolygons()) { de.hft.stuttgart.citydoctor2.datastructure.Storey storey = new de.hft.stuttgart.citydoctor2.datastructure.Storey();
p.setPartOfSurface(bs); storey.setGmlObject(gmlStorey);
} mapAbstractSpace(gmlStorey, storey);
} storey.unsetGmlGeometries();
} SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
return bu; for (AbstractSpaceBoundaryProperty surfaceProp : gmlStorey.getBoundaries()) {
} if (!surfaceProp.isSetObject()) {
continue;
private void updatePartOfSurface(AbstractBuilding cdBuilding, SurfaceMapper surfaceMapper) { }
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { AbstractSpaceBoundary surface = surfaceProp.getObject();
cdBuilding.addBoundarySurface(bs); surface.accept(surfaceMapper);
for (Geometry geom : bs.getGeometries()) { }
for (Polygon p : geom.getPolygons()) { for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
p.setPartOfSurface(bs); storey.addBoundarySurface(bs);
} for (Geometry geom : bs.getGeometries()) {
} for (Polygon p : geom.getPolygons()) {
} p.setPartOfSurface(bs);
} }
}
private Installation mapBuildingInstallation(org.citygml4j.core.model.building.BuildingInstallation gmlBi) { }
Installation bi = new Installation(); return storey;
bi.setGmlObject(gmlBi); }
mapAbstractOccupiedSpace(gmlBi, bi);
GeometryProperty<?> lod2Prop = gmlBi.getDeprecatedProperties().getLod2Geometry(); private de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit mapBuildingUnit(BuildingUnit gmlBU) {
parseAndAddAbstractGeometry(lod2Prop, Lod.LOD2, bi); de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit bu = new de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit();
GeometryProperty<?> lod3Prop = gmlBi.getDeprecatedProperties().getLod3Geometry(); bu.setGmlObject(gmlBU);
parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, bi); mapAbstractSpace(gmlBU, bu);
GeometryProperty<?> lod4Prop = gmlBi.getDeprecatedProperties().getLod4Geometry(); bu.unsetGmlGeometries();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
bi.unsetGmlGeometries(); for (AbstractSpaceBoundaryProperty surfaceProp : gmlBU.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config); continue;
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) { }
if (!surfaceProp.isSetObject()) { AbstractSpaceBoundary surface = surfaceProp.getObject();
continue; surface.accept(surfaceMapper);
} }
AbstractSpaceBoundary surface = surfaceProp.getObject(); for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
surface.accept(surfaceMapper); bu.addBoundarySurface(bs);
} for (Geometry geom : bs.getGeometries()) {
for (BoundarySurface bs : surfaceMapper.getSurfaces()) { for (Polygon p : geom.getPolygons()) {
bi.addBoundarySurface(bs); p.setPartOfSurface(bs);
for (Geometry geom : bs.getGeometries()) { }
for (Polygon p : geom.getPolygons()) { }
p.setPartOfSurface(bs); }
p.setPartOfInstallation(bi); return bu;
} }
}
} private void updatePartOfSurface(AbstractBuilding cdBuilding, SurfaceMapper surfaceMapper) {
for (Geometry geom : bi.getGeometries()) { for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
for (Polygon p : geom.getPolygons()) { cdBuilding.addBoundarySurface(bs);
p.setPartOfInstallation(bi); for (Geometry geom : bs.getGeometries()) {
} for (Polygon p : geom.getPolygons()) {
} p.setPartOfSurface(bs);
}
return bi; }
} }
}
private void parseAndAddAbstractGeometry(GeometryProperty<?> geomProp, Lod lod, CityObject co) {
if (geomProp == null || geomProp.getObject() == null) { private Installation mapBuildingInstallation(org.citygml4j.core.model.building.BuildingInstallation gmlBi) {
return; Installation bi = new Installation();
} bi.setGmlObject(gmlBi);
AbstractGeometry abstractGeometry = geomProp.getObject(); mapAbstractOccupiedSpace(gmlBi, bi);
if (abstractGeometry instanceof MultiSurface ms) { GeometryProperty<?> lod2Prop = gmlBi.getDeprecatedProperties().getLod2Geometry();
Geometry geom = parseMultiSurface(ms, lod); parseAndAddAbstractGeometry(lod2Prop, Lod.LOD2, bi);
co.addGeometry(geom); GeometryProperty<?> lod3Prop = gmlBi.getDeprecatedProperties().getLod3Geometry();
} else if (abstractGeometry instanceof Solid solid) { parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, bi);
Geometry geom = parseSolid(solid, lod); GeometryProperty<?> lod4Prop = gmlBi.getDeprecatedProperties().getLod4Geometry();
if (geom != null) { parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi);
co.addGeometry(geom); bi.unsetGmlGeometries();
}
} else { SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
logger.warn("Cannot handle geometry type {}, ignoring", abstractGeometry.getClass().getSimpleName()); for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) {
} if (!surfaceProp.isSetObject()) {
} continue;
}
private Geometry parseSolid(AbstractSolid abstractSolid, Lod lod) { AbstractSpaceBoundary surface = surfaceProp.getObject();
if (abstractSolid instanceof Solid s) { surface.accept(surfaceMapper);
return handleSolidGeometry(s, lod); }
} else { for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
logger.warn("Cannot handle solid class {}, can only process pure solids", bi.addBoundarySurface(bs);
abstractSolid.getClass().getSimpleName()); for (Geometry geom : bs.getGeometries()) {
return null; for (Polygon p : geom.getPolygons()) {
} p.setPartOfSurface(bs);
} p.setPartOfInstallation(bi);
}
private Geometry handleSolidGeometry(Solid solid, Lod lod) { }
ShellProperty exteriorProperty = solid.getExterior(); }
if (exteriorProperty == null || exteriorProperty.getObject() == null) { for (Geometry geom : bi.getGeometries()) {
logger.warn("Found solid {} without exterior hull, ignoring", solid.getId()); for (Polygon p : geom.getPolygons()) {
return null; p.setPartOfInstallation(bi);
} }
Geometry geom = new Geometry(GeometryType.SOLID, lod); }
Shell exterior = solid.getExterior().getObject();
Citygml3GeometryMapper geometryMapper = new Citygml3GeometryMapper(config, vertexMap); return bi;
readSurfaceMember(geom, geometryMapper, exterior.getSurfaceMembers()); }
return geom;
} private void parseAndAddAbstractGeometry(GeometryProperty<?> geomProp, Lod lod, CityObject co) {
if (geomProp == null || geomProp.getObject() == null) {
private Geometry parseMultiSurface(MultiSurface ms, Lod lod) { return;
Geometry geom = new Geometry(GeometryType.MULTI_SURFACE, lod); }
Citygml3GeometryMapper geometryMapper = new Citygml3GeometryMapper(config, vertexMap); AbstractGeometry abstractGeometry = geomProp.getObject();
readSurfaceMember(geom, geometryMapper, ms.getSurfaceMember()); if (abstractGeometry instanceof MultiSurface ms) {
return geom; Geometry geom = parseMultiSurface(ms, lod);
} co.addGeometry(geom);
} else if (abstractGeometry instanceof Solid solid) {
private void readSurfaceMember(Geometry geom, Citygml3GeometryMapper geometryMapper, Geometry geom = parseSolid(solid, lod);
List<SurfaceProperty> surfaceMember) { if (geom != null) {
for (SurfaceProperty prop : surfaceMember) { co.addGeometry(geom);
if (prop.getHref() != null) { }
references.add(new ResolvableReference(prop.getHref(), geom)); } else {
continue; logger.warn("Cannot handle geometry type {}, ignoring", abstractGeometry.getClass().getSimpleName());
} }
if (prop.getObject() != null) { }
AbstractSurface as = prop.getObject();
as.accept(geometryMapper); private Geometry parseSolid(AbstractSolid abstractSolid, Lod lod) {
} if (abstractSolid instanceof Solid s) {
} return handleSolidGeometry(s, lod);
} else {
List<ConcretePolygon> polygons = geometryMapper.getPolygons(); logger.warn("Cannot handle solid class {}, can only process pure solids",
abstractSolid.getClass().getSimpleName());
for (ConcretePolygon concretePoly : polygons) { return null;
geom.addPolygon(concretePoly); }
if (concretePoly.hasExistingGmlId()) { }
polygonMap.put(concretePoly.getGmlId().getGmlString(), concretePoly);
} private Geometry handleSolidGeometry(Solid solid, Lod lod) {
} ShellProperty exteriorProperty = solid.getExterior();
} if (exteriorProperty == null || exteriorProperty.getObject() == null) {
logger.warn("Found solid {} without exterior hull, ignoring", solid.getId());
private Geometry parseCompositeSurface(CompositeSurface cs, Lod lod) { return null;
Geometry geom = new Geometry(GeometryType.COMPOSITE_SURFACE, lod); }
Citygml3GeometryMapper geometryMapper = new Citygml3GeometryMapper(config, vertexMap); Geometry geom = new Geometry(GeometryType.SOLID, lod);
readSurfaceMember(geom, geometryMapper, cs.getSurfaceMembers()); Shell exterior = solid.getExterior().getObject();
return geom; Citygml3GeometryMapper geometryMapper = new Citygml3GeometryMapper(config, vertexMap);
} readSurfaceMember(geom, geometryMapper, exterior.getSurfaceMembers());
return geom;
private void updateEdgesAndVertices(CityObject co) { }
// searching for neighboring vertices, replacing them with one single vertex to
// avoid later problems with edges and manifold problems private Geometry parseMultiSurface(MultiSurface ms, Lod lod) {
for (Geometry geom : co.getGeometries()) { Geometry geom = new Geometry(GeometryType.MULTI_SURFACE, lod);
KDTree tree = new KDTree(); Citygml3GeometryMapper geometryMapper = new Citygml3GeometryMapper(config, vertexMap);
for (Polygon poly : geom.getPolygons()) { readSurfaceMember(geom, geometryMapper, ms.getSurfaceMember());
LinearRing lr = poly.getExteriorRing(); return geom;
updateRing(tree, lr); }
for (LinearRing innerRing : poly.getInnerRings()) {
updateRing(tree, innerRing); private void readSurfaceMember(Geometry geom, Citygml3GeometryMapper geometryMapper,
} List<SurfaceProperty> surfaceMember) {
} for (SurfaceProperty prop : surfaceMember) {
if (!config.useLowMemoryConsumption()) { if (prop.getHref() != null) {
// no low memory consumption mode meaning create all meta information in references.add(new ResolvableReference(prop.getHref(), geom));
// geometry continue;
geom.updateEdgesAndVertices(); }
} if (prop.getObject() != null) {
} AbstractSurface as = prop.getObject();
} as.accept(geometryMapper);
}
private void updateRing(KDTree tree, LinearRing lr) { }
for (int i = 0; i < lr.getVertices().size(); i++) {
Vertex v = lr.getVertices().get(i); List<ConcretePolygon> polygons = geometryMapper.getPolygons();
List<Vertex> nodesInRange = tree.getNodesInRange(v, neighborDistance);
if (nodesInRange.isEmpty()) { for (ConcretePolygon concretePoly : polygons) {
tree.add(v); geom.addPolygon(concretePoly);
} else { if (concretePoly.hasExistingGmlId()) {
// replace other vertex with any neighboring one polygonMap.put(concretePoly.getGmlId().getGmlString(), concretePoly);
Vertex original = nodesInRange.get(0); }
lr.setVertex(i, original); }
} }
}
} private Geometry parseCompositeSurface(CompositeSurface cs, Lod lod) {
Geometry geom = new Geometry(GeometryType.COMPOSITE_SURFACE, lod);
public void setCityModel(CityModel cModel) { Citygml3GeometryMapper geometryMapper = new Citygml3GeometryMapper(config, vertexMap);
model.setCityModel(cModel); readSurfaceMember(geom, geometryMapper, cs.getSurfaceMembers());
} return geom;
}
public CityDoctorModel getModel() {
return model; private void updateEdgesAndVertices(CityObject co) {
} // searching for neighboring vertices, replacing them with one single vertex to
// avoid later problems with edges and manifold problems
public void setCityGMLVersion(CityGMLVersion cityGMLVersion) { for (Geometry geom : co.getGeometries()) {
model.setParsedCityGMLVersion(cityGMLVersion); KDTree tree = new KDTree();
} for (Polygon poly : geom.getPolygons()) {
LinearRing lr = poly.getExteriorRing();
updateRing(tree, lr);
for (LinearRing innerRing : poly.getInnerRings()) {
updateRing(tree, innerRing);
}
}
if (!config.useLowMemoryConsumption()) {
// no low memory consumption mode meaning create all meta information in
// geometry
geom.updateEdgesAndVertices();
}
}
}
private void updateRing(KDTree tree, LinearRing lr) {
for (int i = 0; i < lr.getVertices().size(); i++) {
Vertex v = lr.getVertices().get(i);
List<Vertex> nodesInRange = tree.getNodesInRange(v, neighborDistance);
if (nodesInRange.isEmpty()) {
tree.add(v);
} else {
// replace other vertex with any neighboring one
Vertex original = nodesInRange.get(0);
lr.setVertex(i, original);
}
}
}
public void setCityModel(CityModel cModel) {
model.setCityModel(cModel);
}
public CityDoctorModel getModel() {
return model;
}
public void setCityGMLVersion(CityGMLVersion cityGMLVersion) {
model.setParsedCityGMLVersion(cityGMLVersion);
}
} }
...@@ -31,7 +31,6 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -31,7 +31,6 @@ import java.util.concurrent.atomic.AtomicInteger;
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.core.AbstractCityObjectProperty; import org.citygml4j.core.model.core.AbstractCityObjectProperty;
import org.citygml4j.core.model.core.AbstractFeatureProperty; import org.citygml4j.core.model.core.AbstractFeatureProperty;
import org.citygml4j.core.model.core.CityModel; import org.citygml4j.core.model.core.CityModel;
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>de.hft.stuttgart</groupId> <groupId>de.hft.stuttgart</groupId>
...@@ -65,11 +65,11 @@ ...@@ -65,11 +65,11 @@
<groupId>net.sf.saxon</groupId> <groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId> <artifactId>Saxon-HE</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.yaml</groupId> <groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId> <artifactId>snakeyaml</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<resources> <resources>
<resource> <resource>
......
...@@ -65,23 +65,19 @@ public class SvrlContentHandler implements ContentHandler { ...@@ -65,23 +65,19 @@ public class SvrlContentHandler implements ContentHandler {
public void setDocumentLocator(Locator locator) { public void setDocumentLocator(Locator locator) {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void startDocument() throws SAXException { public void startDocument() throws SAXException {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void endDocument() throws SAXException { public void endDocument() throws SAXException {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void startPrefixMapping(String prefix, String uri) throws SAXException { public void startPrefixMapping(String prefix, String uri) throws SAXException {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void endPrefixMapping(String prefix) throws SAXException { public void endPrefixMapping(String prefix) throws SAXException {
// not needed // not needed
...@@ -133,17 +129,14 @@ public class SvrlContentHandler implements ContentHandler { ...@@ -133,17 +129,14 @@ public class SvrlContentHandler implements ContentHandler {
buffer.append(ch, start, length); buffer.append(ch, start, length);
} }
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void processingInstruction(String target, String data) throws SAXException { public void processingInstruction(String target, String data) throws SAXException {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void skippedEntity(String name) throws SAXException { public void skippedEntity(String name) throws SAXException {
// not needed // not needed
......
...@@ -27,19 +27,16 @@ import de.hft.stuttgart.citydoctor2.check.Check; ...@@ -27,19 +27,16 @@ import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError; import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId; import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.check.CheckResult; import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.RequirementType;
import de.hft.stuttgart.citydoctor2.check.GeometrySelfIntersection; import de.hft.stuttgart.citydoctor2.check.GeometrySelfIntersection;
import de.hft.stuttgart.citydoctor2.check.Requirement; import de.hft.stuttgart.citydoctor2.check.Requirement;
import de.hft.stuttgart.citydoctor2.check.RequirementType;
import de.hft.stuttgart.citydoctor2.check.ResultStatus; import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.check.error.SolidSelfIntError; import de.hft.stuttgart.citydoctor2.check.error.SolidSelfIntError;
import de.hft.stuttgart.citydoctor2.checks.util.CollectionUtils; import de.hft.stuttgart.citydoctor2.checks.util.CollectionUtils;
import de.hft.stuttgart.citydoctor2.checks.util.SelfIntersectionUtil; import de.hft.stuttgart.citydoctor2.checks.util.SelfIntersectionUtil;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry; import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType; import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.math.Segment3d;
import de.hft.stuttgart.citydoctor2.utils.PolygonIntersection; import de.hft.stuttgart.citydoctor2.utils.PolygonIntersection;
import de.hft.stuttgart.citydoctor2.utils.PolygonIntersection.IntersectionType;
/** /**
* Check for self intersecting solids * Check for self intersecting solids
......
...@@ -160,6 +160,7 @@ public class CityDoctorController { ...@@ -160,6 +160,7 @@ public class CityDoctorController {
buildLand(model); buildLand(model);
buildCityFurniture(model); buildCityFurniture(model);
buildOtherCityObjects(model); buildOtherCityObjects(model);
buildTunnel(model.getTunnels());
} }
private void resetFeatureChunks() { private void resetFeatureChunks() {
......
package de.hft.stuttgart.citydoctor2.gui.tree; package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.datastructure.AbstractRoom;
import de.hft.stuttgart.citydoctor2.datastructure.CityFurniture; import de.hft.stuttgart.citydoctor2.datastructure.CityFurniture;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus; import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer; import de.hft.stuttgart.citydoctor2.gui.Renderer;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.image.*?> <?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<HBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" spacing="5.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"> <HBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" spacing="5.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<HBox spacing="5.0" HBox.hgrow="NEVER"> <HBox spacing="5.0" HBox.hgrow="NEVER">
<children> <children>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<?import javafx.geometry.*?> <?import javafx.geometry.*?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<BorderPane fx:id="mainPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="400.0" minWidth="400.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"> <BorderPane fx:id="mainPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="400.0" minWidth="400.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<center> <center>
<SplitPane fx:id="mainContainer" dividerPositions="0.47069431920649235" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="300.0" prefHeight="600.0" prefWidth="1100.0"> <SplitPane fx:id="mainContainer" dividerPositions="0.47069431920649235" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="300.0" prefHeight="600.0" prefWidth="1100.0">
<items> <items>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>de.hft.stuttgart</groupId> <groupId>de.hft.stuttgart</groupId>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0">
>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.hft.stuttgart</groupId> <groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId> <artifactId>CityDoctorParent</artifactId>
......
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