"...energy-ade-3-citygml4j.git" did not exist on "40fef55834d2c59e92c4c19af3fa8e965fa1d8dc"
Commit 0f3d9a85 authored by Riegel's avatar Riegel
Browse files

Merge branch 'dev' into 'master'

CityDoctor Release Version 3.16.0

See merge request !11
parents b7b8f5fe b2d40f78
Pipeline #10323 passed with stage
in 1 minute and 25 seconds
......@@ -22,7 +22,6 @@ package de.hft.stuttgart.citydoctor2.datastructure;
* The available opening types in CityGML
*
* @author Matthias Betz
*
*/
public enum OpeningType {
......
......@@ -18,17 +18,16 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.List;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon;
import java.io.Serial;
import java.util.List;
/**
* Interface for concrete and linked polygons.
*
* @author Matthias Betz
*
*/
public abstract class Polygon extends GmlElement {
......@@ -36,6 +35,7 @@ public abstract class Polygon extends GmlElement {
private static final long serialVersionUID = -613942946364706513L;
public abstract Vector3d calculateNormalNormalized();
public abstract Vector3d calculateNormal();
public abstract TesselatedPolygon tesselate();
......
package de.hft.stuttgart.citydoctor2.datastructure;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.Serial;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Reference object for handling of implicit geometries with a relative geometry
*
* @author Riegel
*/
public class RelativeGeometry extends Geometry {
private static final Logger logger = LogManager.getLogger(RelativeGeometry.class);
@Serial
private static final long serialVersionUID = -686112245455298977L;
private static Map<Geometry, RelativeGeometry> relativeGeometries = new ConcurrentHashMap<>();
public static RelativeGeometry of(Geometry geom) {
if (relativeGeometries.containsKey(geom)) {
return relativeGeometries.get(geom);
}
RelativeGeometry relGeo = new RelativeGeometry(geom.getType(), geom.getLod());
geom.getPolygons().forEach(relGeo::addPolygon);
relGeo.updateEdgesAndVertices();
relativeGeometries.put(geom, relGeo);
return relGeo;
}
private RelativeGeometry(GeometryType type, Lod lod) {
super(type, lod);
}
}
......@@ -18,19 +18,18 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
import org.citygml4j.core.model.relief.ReliefFeature;
import org.citygml4j.core.util.geometry.GeometryFactory;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.relief.ReliefFeature;
import org.citygml4j.core.util.geometry.GeometryFactory;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class ReliefObject extends CityObject {
......
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.util.geometry.GeometryFactory;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class Storey extends AbstractBuildingSubdivision {
@Serial
private static final long serialVersionUID = 5162814691642668089L;
private final List<BuildingUnit> buildingUnits = new ArrayList<>();
@Override
public Copyable createCopyInstance() {
return new Storey();
}
@Override
public void unsetGmlGeometries() {
super.unsetGmlGeometries();
for (BuildingUnit buildingUnit : buildingUnits) {
buildingUnit.unsetGmlGeometries();
}
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config);
for (BuildingUnit buildingUnit : buildingUnits) {
buildingUnit.reCreateGeometries(factory, config);
}
}
@Override
public void accept(Check c) {
super.accept(c);
for (BuildingUnit buildingUnit : buildingUnits) {
buildingUnit.accept(c);
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (BuildingUnit buildingUnit : buildingUnits) {
buildingUnit.collectContainedErrors(errors);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (BuildingUnit buildingUnit : buildingUnits) {
buildingUnit.clearAllContainedCheckResults();
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (BuildingUnit buildingUnit : buildingUnits) {
if (buildingUnit.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (BuildingUnit buildingUnit : buildingUnits) {
if (buildingUnit.containsAnyError()) {
return true;
}
}
return false;
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (BuildingUnit buildingUnit : buildingUnits) {
buildingUnit.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (BuildingUnit buildingUnit : buildingUnits) {
buildingUnit.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
for (BuildingUnit buildingUnit : buildingUnits) {
buildingUnit.collectInstances(handler);
}
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
Storey originalSt = (Storey) original;
for (BuildingUnit buildingUnit : originalSt.buildingUnits) {
buildingUnits.add(handler.getCopyInstance(buildingUnit));
}
this.abs = originalSt.abs;
}
}
......@@ -22,7 +22,6 @@ package de.hft.stuttgart.citydoctor2.datastructure;
* Availabel bridge types in CityGML
*
* @author Matthias Betz
*
*/
public enum SurfaceFeatureType {
......
......@@ -18,10 +18,9 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.relief.TINRelief;
......@@ -31,9 +30,9 @@ import org.xmlobjects.gml.model.geometry.primitives.Triangle;
import org.xmlobjects.gml.model.geometry.primitives.TriangleArrayProperty;
import org.xmlobjects.gml.model.geometry.primitives.TriangulatedSurface;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class TinObject extends CityObject {
......
......@@ -18,10 +18,13 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.model.core.AbstractSpace;
import org.citygml4j.core.model.transportation.AbstractTransportationSpace;
......@@ -31,19 +34,14 @@ import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
/**
* Representation of a transportation object.
*
* @author Matthias Betz
*
*/
public class TransportationObject extends CityObject {
......@@ -70,6 +68,9 @@ public class TransportationObject extends CityObject {
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
switch (type) {
......@@ -236,7 +237,7 @@ public class TransportationObject extends CityObject {
@Override
public void unsetGmlGeometries() {
switch (type) {
case ROAD, TRACK, RAILWAY, SQUARE,TRANSPORTATION_COMPLEX:
case ROAD, TRACK, RAILWAY, SQUARE, TRANSPORTATION_COMPLEX:
AbstractTransportationSpace tc = (AbstractTransportationSpace) ato;
tc.getDeprecatedProperties().setLod1MultiSurface(null);
tc.setLod2MultiSurface(null);
......
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.model.tunnel.TunnelInstallation;
import org.citygml4j.core.model.tunnel.TunnelInstallationProperty;
import org.citygml4j.core.util.geometry.GeometryFactory;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class Tunnel extends AbstractTunnel {
@Serial
private static final long serialVersionUID = 5316281216192555555L;
private List<TunnelPart> tunnelParts = new ArrayList<>();
public List<TunnelPart> getTunnelParts() {
return tunnelParts;
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config);
for (TunnelPart tp : tunnelParts) {
tp.reCreateGeometries(factory, config);
}
}
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (TunnelPart tp : tunnelParts) {
tp.accept(c);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (TunnelPart tp : tunnelParts) {
tp.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (TunnelPart tp : tunnelParts) {
tp.collectContainedErrors(errors);
}
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (TunnelPart tp : tunnelParts) {
if (tp.containsAnyError()) {
return true;
}
}
return false;
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (TunnelPart tp : tunnelParts) {
if (tp.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
public void addTunnelPart(TunnelPart tunnelPart) {
tunnelParts.add(tunnelPart);
}
@Override
public String toString() {
return "Tunnel [id=" + getGmlId() + "]";
}
public void anonymize() {
for (Geometry geom : getGeometries()) {
geom.anonymize();
}
org.citygml4j.core.model.tunnel.Tunnel gmlT = new org.citygml4j.core.model.tunnel.Tunnel();
gmlT.setId(GmlId.generateId().getGmlString());
for (Installation ti : getTunnelInstallations()) {
ti.anonymize();
gmlT.getTunnelInstallations().add(new TunnelInstallationProperty((TunnelInstallation) ti.getGmlObject()));
}
for (BoundarySurface bs : getBoundarySurfaces()) {
bs.anonymize();
gmlT.addBoundary(new AbstractSpaceBoundaryProperty(bs.getGmlObject()));
}
setCityGmlBuilding(gmlT);
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (TunnelPart tp : tunnelParts) {
tp.clearMetaInformation();
}
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (TunnelPart tp : tunnelParts) {
tp.prepareForChecking();
}
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
Tunnel originalTunnel = (Tunnel) original;
for (TunnelPart originalTp : originalTunnel.tunnelParts) {
tunnelParts.add(handler.getCopyInstance(originalTp));
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
for (TunnelPart tp : tunnelParts) {
handler.addInstance(tp);
}
}
@Override
public Copyable createCopyInstance() {
return new Tunnel();
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class TunnelConstructiveElement extends CityObject {
private static final Logger logger = LogManager.getLogger(TunnelConstructiveElement.class);
private static final String CANNOT_ADD = "Cannot add ";
@Serial
private static final long serialVersionUID = 7353233899458901155L;
private final org.citygml4j.core.model.tunnel.TunnelConstructiveElement gmlTunnelElement;
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
public TunnelConstructiveElement(org.citygml4j.core.model.tunnel.TunnelConstructiveElement gmlObject) {
this.gmlTunnelElement = gmlObject;
}
@Override
public Copyable createCopyInstance() {
return new TunnelConstructiveElement(gmlTunnelElement);
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
// only handles CityGML2 for now
// unknown which CityGML is handled here
// need context information to decide
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
switch (geom.getType()) {
case SOLID:
Solid solid = CityGmlUtils.createSolid(geom, factory, config);
setSolidAccordingToLod(geom, solid);
break;
case MULTI_SURFACE:
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms);
break;
}
}
for (BoundarySurface bs : boundarySurfaceList) {
reCreateBoundarySurface(factory, config, bs);
}
}
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.accept(c);
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (BoundarySurface bs : boundarySurfaceList) {
bs.collectContainedErrors(errors);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearAllContainedCheckResults();
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.containsAnyError()) {
return true;
}
}
return false;
}
private void reCreateBoundarySurface(GeometryFactory factory, ParserConfiguration config, BoundarySurface bs) {
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : gmlTunnelElement.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from TunnelConstructiveElement", bs.getGmlId());
gmlTunnelElement.getBoundaries().remove(bsp);
break;
}
}
return;
}
bs.reCreateGeometries(factory, config);
}
private void setSolidAccordingToLod(Geometry geom, Solid solid) {
switch (geom.getLod()) {
case LOD1:
gmlTunnelElement.setLod1Solid(new SolidProperty(solid));
break;
case LOD2:
gmlTunnelElement.setLod2Solid(new SolidProperty(solid));
break;
case LOD3:
gmlTunnelElement.setLod3Solid(new SolidProperty(solid));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " solid to buildings");
}
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) {
case LOD0:
gmlTunnelElement.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
gmlTunnelElement.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
gmlTunnelElement.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " multi surface to buildings");
}
}
@Override
public org.citygml4j.core.model.tunnel.TunnelConstructiveElement getGmlObject() {
return gmlTunnelElement;
}
@Override
public void unsetGmlGeometries() {
gmlTunnelElement.setLod0MultiSurface(null);
gmlTunnelElement.setLod2MultiSurface(null);
gmlTunnelElement.setLod3MultiSurface(null);
gmlTunnelElement.setLod1Solid(null);
gmlTunnelElement.setLod2Solid(null);
gmlTunnelElement.setLod3Solid(null);
for (BoundarySurface bs : boundarySurfaceList) {
bs.unsetGmlGeometries();
}
}
@Override
public FeatureType getFeatureType() {
return FeatureType.TUNNEL_CONSTRUCTION_ELEMENT;
}
public void addBoundarySurface(BoundarySurface bs) {
boundarySurfaceList.add(bs);
bs.setParent(this);
}
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaceList;
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (BoundarySurface bs : boundarySurfaceList) {
bs.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(boundarySurfaceList);
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
TunnelConstructiveElement originalTce = (TunnelConstructiveElement) original;
for (BoundarySurface originalTs : originalTce.boundarySurfaceList) {
boundarySurfaceList.add(handler.getCopyInstance(originalTs));
}
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
public class TunnelFurniture extends AbstractFurniture {
@Serial
private static final long serialVersionUID = -4667219019432204174L;
public void setGmlObject(org.citygml4j.core.model.tunnel.TunnelFurniture gmlObject) {
super.setGmlObject(gmlObject);
}
@Override
public Copyable createCopyInstance() {
return new BuildingRoomFurniture();
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.tunnel.TunnelFurnitureProperty;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class TunnelHollow extends AbstractRoom {
@Serial
private static final long serialVersionUID = -276088332165299253L;
private final List<TunnelFurnitureProperty> furnitureRefs = new ArrayList<>(2);
private CityObject parent;
public void setGmlObject(org.citygml4j.core.model.tunnel.HollowSpace gmlHollowSpace) {
super.cgmlRoom = gmlHollowSpace;
}
public void setParent(CityObject parent) {
this.parent = parent;
}
public void addFurnitureRef(TunnelFurnitureProperty furnitureRef) {
furnitureRefs.add(furnitureRef);
}
public List<TunnelFurnitureProperty> getFurnitureRefs() {
return furnitureRefs;
}
public CityObject getParent() {
return parent;
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
TunnelHollow oHollow = (TunnelHollow) original;
parent = handler.getCopyInstance(oHollow.getParent());
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(parent);
}
@Override
public Copyable createCopyInstance() {
return new TunnelHollow();
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
public class TunnelPart extends AbstractTunnel {
@Serial
private static final long serialVersionUID = 8200322261958679163L;
private Tunnel parent;
public TunnelPart(Tunnel parent) {
this.parent = parent;
parent.addTunnelPart(this);
}
public Tunnel getParent() {
return parent;
}
@Override
public FeatureType getFeatureType() {
return FeatureType.TUNNEL_PART;
}
@Override
public String toString() {
return "TunnelPart [id=" + getGmlId() + "]";
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
TunnelPart originalPart = (TunnelPart) original;
parent = handler.getCopyInstance(originalPart.parent);
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(parent);
}
@Override
public Copyable createCopyInstance() {
return new TunnelPart();
}
private TunnelPart() {
}
}
......@@ -18,9 +18,10 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.Collections;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.model.vegetation.AbstractVegetationObject;
import org.citygml4j.core.model.vegetation.PlantCover;
......@@ -33,16 +34,13 @@ import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
import java.util.Collections;
/**
* Representation of CityGML vegetation objects
*
* @author Matthias Betz
*
*/
public class Vegetation extends CityObject {
......@@ -68,6 +66,9 @@ public class Vegetation extends CityObject {
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
if (type == VegetationType.SOLITARY_VEGETATION_OBJECT) {
......
......@@ -18,22 +18,21 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import de.hft.stuttgart.citydoctor2.utils.SerializablePair;
import java.io.Serial;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import de.hft.stuttgart.citydoctor2.utils.SerializablePair;
/**
* Contains the vertex information of a point in a linear ring
*
* @author Matthias Betz
*
*/
public class Vertex extends Vector3d implements Copyable {
......
......@@ -18,27 +18,25 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.model.waterbody.WaterBody;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
/**
* Represents cityGML water body objects.
*
* @author Matthias Betz
*
*/
public class WaterObject extends CityObject {
......
......@@ -18,35 +18,32 @@
*/
package de.hft.stuttgart.citydoctor2.mapper.citygml3;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.*;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.Localization;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.locationtech.proj4j.BasicCoordinateTransform;
import org.locationtech.proj4j.ProjCoordinate;
import org.xmlobjects.gml.model.geometry.primitives.AbstractRing;
import org.xmlobjects.gml.model.geometry.primitives.AbstractRingProperty;
import org.xmlobjects.gml.model.geometry.complexes.CompositeSurface;
import org.xmlobjects.gml.model.geometry.primitives.Polygon;
import org.xmlobjects.gml.model.geometry.primitives.Ring;
import org.xmlobjects.gml.model.geometry.primitives.*;
import org.xmlobjects.gml.visitor.GeometryWalker;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.Localization;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Citygml3GeometryMapper extends GeometryWalker {
private static final Logger logger = LogManager.getLogger(Citygml3GeometryMapper.class);
private final List<ConcretePolygon> polygons = new ArrayList<>();
private final List<CompositeCollection> composites = new ArrayList<>();
private LinearRing currentRing = null;
private final ParserConfiguration config;
private final ProjCoordinate p1 = new ProjCoordinate();
......@@ -62,7 +59,7 @@ public class Citygml3GeometryMapper extends GeometryWalker {
public void visit(Polygon polygon) {
parsePolygon(polygon.getId(), polygon.getExterior(), polygon.getInterior());
if (polygon.getExterior() == null) {
logger.warn(String.format("No exterior: %s" ,polygon.getId()));
logger.warn(String.format("No exterior: %s", polygon.getId()));
}
}
......@@ -95,6 +92,35 @@ public class Citygml3GeometryMapper extends GeometryWalker {
}
}
@Override
public void visit(CompositeSurface cs) {
if (cs.getSurfaceMembers() != null && cs.getSurfaceMembers().isEmpty()) {
logger.warn("CompositeSurface %s is empty", cs.getId());
return;
}
List<SurfaceProperty> surfaceMember = cs.getSurfaceMembers();
Citygml3GeometryMapper recursiveMapper = new Citygml3GeometryMapper(config, vertexMap);
CompositeCollection comp = new CompositeCollection();
if (cs.getId() == null) {
comp.setGmlId(GmlId.generateId());
} else {
comp.setGmlId(new GmlId(cs.getId()));
}
for (SurfaceProperty prop : surfaceMember) {
if (prop.getObject() != null) {
AbstractSurface as = prop.getObject();
as.accept(recursiveMapper);
}
}
List<ConcretePolygon> compPolys = recursiveMapper.getPolygons();
compPolys.forEach(comp::addCompositeMember);
comp.addAllChildComposites(recursiveMapper.getComposites());
composites.add(comp);
polygons.addAll(compPolys);
}
@Override
public void visit(org.xmlobjects.gml.model.geometry.primitives.LinearRing gmlRing) {
if (gmlRing.getSrsDimension() != null && gmlRing.getSrsDimension() != 3) {
......@@ -177,4 +203,8 @@ public class Citygml3GeometryMapper extends GeometryWalker {
return polygons;
}
public List<CompositeCollection> getComposites() {
return composites;
}
}
......@@ -18,23 +18,9 @@
*/
package de.hft.stuttgart.citydoctor2.mapper.citygml3;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.citygml4j.core.model.construction.AbstractConstructionSurface;
import org.citygml4j.core.model.construction.AbstractFillingSurface;
import org.citygml4j.core.model.construction.AbstractFillingSurfaceProperty;
import org.citygml4j.core.model.construction.CeilingSurface;
import org.citygml4j.core.model.construction.DoorSurface;
import org.citygml4j.core.model.construction.FloorSurface;
import org.citygml4j.core.model.construction.GroundSurface;
import org.citygml4j.core.model.construction.InteriorWallSurface;
import org.citygml4j.core.model.construction.OuterCeilingSurface;
import org.citygml4j.core.model.construction.OuterFloorSurface;
import org.citygml4j.core.model.construction.RoofSurface;
import org.citygml4j.core.model.construction.WallSurface;
import org.citygml4j.core.model.construction.WindowSurface;
import de.hft.stuttgart.citydoctor2.datastructure.*;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import org.citygml4j.core.model.construction.*;
import org.citygml4j.core.model.core.AbstractThematicSurface;
import org.citygml4j.core.model.core.ClosureSurface;
import org.citygml4j.core.visitor.ObjectWalker;
......@@ -43,32 +29,26 @@ import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.primitives.AbstractSurface;
import org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty;
import de.hft.stuttgart.citydoctor2.datastructure.BoundarySurface;
import de.hft.stuttgart.citydoctor2.datastructure.BoundarySurfaceType;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Opening;
import de.hft.stuttgart.citydoctor2.datastructure.OpeningType;
import de.hft.stuttgart.citydoctor2.datastructure.SurfaceFeatureType;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class SurfaceMapper extends ObjectWalker {
private final List<BoundarySurface> surfaces = new ArrayList<>();
private final Map<String, ConcretePolygon> polygonMap;
private final Map<String, CompositeCollection> compositeMap;
private final List<ResolvableReference> references;
private final Map<Vertex, Vertex> vertexMap;
private final ParserConfiguration config;
public SurfaceMapper(Map<String, ConcretePolygon> polygonMap, List<ResolvableReference> references,
Map<Vertex, Vertex> vertexMap, ParserConfiguration config) {
Map<String, CompositeCollection> compositeMap, Map<Vertex, Vertex> vertexMap,
ParserConfiguration config) {
this.polygonMap = polygonMap;
this.references = references;
this.vertexMap = vertexMap;
this.compositeMap = compositeMap;
this.config = config;
}
......@@ -95,7 +75,7 @@ public class SurfaceMapper extends ObjectWalker {
Opening o;
if (afs instanceof DoorSurface ds) {
o = new Opening(OpeningType.DOOR, SurfaceFeatureType.BUILDING, cdSurface, ds);
} else if (afs instanceof WindowSurface ws){
} else if (afs instanceof WindowSurface ws) {
o = new Opening(OpeningType.WINDOW, SurfaceFeatureType.BUILDING, cdSurface, ws);
} else {
o = new Opening(OpeningType.UNKNOWN, SurfaceFeatureType.BUILDING, cdSurface, afs);
......@@ -133,6 +113,7 @@ public class SurfaceMapper extends ObjectWalker {
return geom;
}
private void readSurfaceMember(Geometry geom, Citygml3GeometryMapper geometryMapper,
List<SurfaceProperty> surfaceMember) {
for (SurfaceProperty prop : surfaceMember) {
......@@ -147,12 +128,18 @@ public class SurfaceMapper extends ObjectWalker {
}
List<ConcretePolygon> polygons = geometryMapper.getPolygons();
List<CompositeCollection> composites = geometryMapper.getComposites();
for (CompositeCollection cc : composites) {
references.add(new ResolvableReference(cc.getGmlId().toString(), geom));
compositeMap.put(cc.getGmlId().getGmlString(), cc);
}
for (ConcretePolygon concretePoly : polygons) {
geom.addPolygon(concretePoly);
if (concretePoly.hasExistingGmlId()) {
polygonMap.put(concretePoly.getGmlId().getGmlString(), concretePoly);
}
}
}
@Override
......
package de.hft.stuttgart.citydoctor2.math;
import Jama.Matrix;
import de.hft.stuttgart.citydoctor2.datastructure.*;
import de.hft.stuttgart.citydoctor2.utils.Copy;
import org.citygml4j.core.model.core.ImplicitGeometry;
import org.citygml4j.core.model.core.TransformationMatrix4x4;
import org.xmlobjects.gml.model.geometry.primitives.Point;
import org.xmlobjects.gml.model.geometry.primitives.PointProperty;
import org.xmlobjects.util.copy.CopyBuilder;
import java.util.*;
/**
* Adapter class for CityGML-TransformationMatrix4x4
*/
public class TransformationMatrix {
private final TransformationMatrix4x4 originalTM4x4;
private Matrix tMatrix;
/**
* The {@code TransformationMatrix} class is an adapter for applying the {@link TransformationMatrix4x4} of implicitGeometries to geometries
* of CityDoctor's internal model.
* @param transformationMatrix the transformation matrix.
* @param pointProperty the reference point for the translation of the geometry's position.
*/
public TransformationMatrix(TransformationMatrix4x4 transformationMatrix, PointProperty pointProperty) {
originalTM4x4 = transformationMatrix;
setupMatrix();
incorporateRefPoint(pointProperty);
}
/**
* The {@code TransformationMatrix} class is an adapter for applying the {@link TransformationMatrix4x4} of implicitGeometries to geometries
* of CityDoctor's internal model.
* @param implicitGeometry the implicitGeometry containing the TransformationMatrix and ReferencePoint.
*/
public TransformationMatrix(ImplicitGeometry implicitGeometry) {
originalTM4x4 = implicitGeometry.getTransformationMatrix();
setupMatrix();
incorporateRefPoint(implicitGeometry.getReferencePoint());
}
private void setupMatrix() {
double[][] matrix = new double[4][4];
CopyBuilder copyBuilder = new CopyBuilder();
TransformationMatrix4x4 tmMatrix = (TransformationMatrix4x4) originalTM4x4.deepCopy(copyBuilder);
List<Double> tmValues = tmMatrix.toRowMajorList();
for (int i = 0; i < 4 ; i++){
for (int j = 0; j < 4 ; j++){
matrix[i][j] = tmValues.get(i*4+j);
}
}
tMatrix = new Matrix(matrix);
}
private void incorporateRefPoint(PointProperty pointProperty) {
Point refPoint = pointProperty.getObject();
List<Double> refCoord = refPoint.getPos().toCoordinateList3D();
double [][] tArray = tMatrix.getArray();
tArray[0][3] = refCoord.get(0);
tArray[1][3] = refCoord.get(1);
tArray[2][3] = refCoord.get(2);
}
/**
* Transforms a vector with the transformation matrix.
* @param referenceGeom reference geometry to transform.
* @return A transformed copy of {@code referenceGeom}.
*/
public Geometry transformGeometry(Geometry referenceGeom) {
// Create deep copy of reference geom
Geometry geom = Copy.copy(referenceGeom);
Map<Vertex, Boolean> visitedVertices = new IdentityHashMap<>();
Set<Vertex> visitedVerticesSet = Collections.newSetFromMap(visitedVertices);
// Transform all vertices
for (Polygon polygon : geom.getPolygons()){
for (Vertex vertex : polygon.getExteriorRing().getVertices()){
if (!visitedVerticesSet.contains(vertex)){
transformVector3D(vertex);
visitedVerticesSet.add(vertex);
}
}
for (LinearRing ring : polygon.getInnerRings()){
for (Vertex vertex : ring.getVertices()){
if (!visitedVerticesSet.contains(vertex)){
transformVector3D(vertex);
visitedVerticesSet.add(vertex);
}
}
}
}
geom.updateEdgesAndVertices();
return geom;
}
public void transformVector3D(Vector3d vector) {
double[] tfVector = new double[]{vector.getX(), vector.getY(), vector.getZ(), 1d};
Matrix vectorMatrix = new Matrix(tfVector,4);
Matrix res = tMatrix.times(vectorMatrix);
double[] resultVector = res.getRowPackedCopy();
vector.setX(resultVector[0]);
vector.setY(resultVector[1]);
vector.setZ(resultVector[2]);
}
}
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