Commit ffe66fd4 authored by Riegel's avatar Riegel
Browse files

Merge branch 'dev_visitor_rework' into 'dev'

Visitor rework

See merge request !30
parents d12da32a 120466a0
Pipeline #11077 passed with stage
in 1 minute and 20 seconds
...@@ -19,11 +19,10 @@ ...@@ -19,11 +19,10 @@
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
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.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler; import de.hft.stuttgart.citydoctor2.utils.visitors.GmlGeometryRebuilder;
import de.hft.stuttgart.citydoctor2.utils.Copyable; import de.hft.stuttgart.citydoctor2.utils.visitors.UnsetGeometriesVisitor;
import javafx.scene.paint.Color;
import org.citygml4j.core.model.core.AbstractCityObject; import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.util.geometry.GeometryFactory; import org.citygml4j.core.util.geometry.GeometryFactory;
...@@ -44,20 +43,30 @@ public abstract class CityObject extends GmlElement { ...@@ -44,20 +43,30 @@ public abstract class CityObject extends GmlElement {
@Serial @Serial
private static final long serialVersionUID = 651712070755024188L; private static final long serialVersionUID = 651712070755024188L;
private final List<Geometry> geometryList = new ArrayList<>(); private final List<Geometry> geometryList = new ArrayList<>();
private final List<GenericAttribute> genericAttributeList = new ArrayList<>(); private final List<GenericAttribute> genericAttributeList = new ArrayList<>();
/**
* Recreates the CityGML4j geometry in this object's datastructure using the CityDoctor geometries.
* The original CityGML4j geometry is deleted after parsing to reduce the memory overhead of {@link CityObject CityObjects}.
* <p/>
* Recreation of the geometries is needed for writing validation results to the QualityADE, as well as for the export
* of repaired geometries from CityDoctor's internal datastructure.
* @param factory the GeometryFactory used for creation of CityGml4j geometry objects
* @param config the configuration settings of the parser
*/
public final void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
this.accept(new GmlGeometryRebuilder(factory, config));
}
/** /**
* Recreates the CityGML4j geometry in this object. The CityGML4j geometry is * Rebuilds the CityGML4j geometries of this object.
* deleted from the data structure as was mapped to the city doctor data
* structure. For writing CityGML files the geometry has to be restored. Also
* maps changes to geometry back to CityGML4j
* *
* @param factory needed to create CityGML4j data structures * @param factory the GeometryFactory used for creation of CityGml4j geometry objects
* @param config contains information whether a city doctor point was * @param config the configuration settings of the parser
* transformed to a different coordinate system. It would need to
* be transformed to the original coordinate system
*/ */
public abstract void reCreateGeometries(GeometryFactory factory, ParserConfiguration config); public abstract void rebuildGeometries(GeometryFactory factory, ParserConfiguration config);
/** /**
* Getter for the CityGML4j data object * Getter for the CityGML4j data object
...@@ -67,29 +76,58 @@ public abstract class CityObject extends GmlElement { ...@@ -67,29 +76,58 @@ public abstract class CityObject extends GmlElement {
public abstract AbstractCityObject getGmlObject(); public abstract AbstractCityObject getGmlObject();
/** /**
* Remove the CityGML4j geometries from the data structure to save memory. * Remove the CityGML4j geometries from this CityObject to reduce memory overhead.
*/ */
public abstract void unsetGmlGeometries(); public abstract void unsetGmlGeometries();
/**
* Removes all CityGML4J geometries from this CityObject and child objects of its datastructure to reduce
* the memory overhead.
*/
public final void clearGmlGeometries() {
this.accept(new UnsetGeometriesVisitor());
}
/**
* Adds a Geometry to this object.
* @param geom the Geometry to add.
*/
public void addGeometry(Geometry geom) { public void addGeometry(Geometry geom) {
Objects.requireNonNull(geom); Objects.requireNonNull(geom);
geometryList.add(geom); geometryList.add(geom);
geom.setParent(this); geom.setParent(this);
} }
/**
* Returns all Geometries of this object.
* @return a list of the Geometries.
*/
public List<Geometry> getGeometries() { public List<Geometry> getGeometries() {
return geometryList; return geometryList;
} }
/**
* Removes a Geometry from this object.
* @param lod the {@link Lod} of the Geometry.
*/
public void removeGeometry(Lod lod) { public void removeGeometry(Lod lod) {
geometryList.removeIf(geom -> geom.getLod() == lod); geometryList.removeIf(geom -> geom.getLod() == lod);
} }
/**
* Removes a Geometry from this object.
* @param lod the {@link Lod} of the Geometry.
* @param type the {@link GeometryType} of the Geometry.
*/
public void removeGeometry(Lod lod, GeometryType type) { public void removeGeometry(Lod lod, GeometryType type) {
geometryList.removeIf(geom -> geom.getLod() == lod && geom.getType() == type); geometryList.removeIf(geom -> geom.getLod() == lod && geom.getType() == type);
} }
/**
* Returns the Geometry with the highest LOD of this object. If multiple Geometries share the highest LOD, the one
* that was added first will be returned.
* @return the Geometry with the highest LOD
*/
public Geometry getHighestLodGeometry() { public Geometry getHighestLodGeometry() {
Geometry highestLodGeometry = null; Geometry highestLodGeometry = null;
Lod highestLod = null; Lod highestLod = null;
...@@ -103,18 +141,47 @@ public abstract class CityObject extends GmlElement { ...@@ -103,18 +141,47 @@ public abstract class CityObject extends GmlElement {
} }
/** /**
* Returns the top-level CityObject (like Building or Tunnel) belonging to this object. * Returns the top-level CityObject (e.g. Building, Tunnel, Vegetation etc.) belonging to this object.
*/ */
public abstract CityObject getTopLevelCityObject(); public abstract CityObject getTopLevelCityObject();
/**
* Returns a String representation of this object for display in the featuretab TreeViews in the format of
* "[FeatureType] Gml-ID"
* @return the String representation.
*/
public String getDisplayText() {
return String.format("[%s] %s", this.getClass().getSimpleName(), this.getGmlId().toString());
}
/**
* Returns the color for rendering of this object's polygons.
* @return color for this object
*/
public Color getRenderColor() {
return Color.WHITE;
}
/**
* Adds a GenericAttribute to this object.
* @param genericAttribute the attribute to add.
*/
public void addGenericAttribute(GenericAttribute genericAttribute) { public void addGenericAttribute(GenericAttribute genericAttribute) {
genericAttributeList.add(genericAttribute); genericAttributeList.add(genericAttribute);
} }
/**
* Returns all GenericAttributes of this object.
* @return a list of the GenericAttributes.
*/
public List<GenericAttribute> getGenericAttributes() { public List<GenericAttribute> getGenericAttributes() {
return genericAttributeList; return genericAttributeList;
} }
/**
* Returns the CityGML FeatureType of this object.
* @return this object's FeatureType.
*/
public abstract FeatureType getFeatureType(); public abstract FeatureType getFeatureType();
@Override @Override
...@@ -128,50 +195,6 @@ public abstract class CityObject extends GmlElement { ...@@ -128,50 +195,6 @@ public abstract class CityObject extends GmlElement {
} }
} }
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (Geometry geom : geometryList) {
if (geom.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public void clearAllContainedCheckResults() {
super.clearCheckResults();
for (Geometry geom : geometryList) {
geom.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (Geometry geom : geometryList) {
geom.collectContainedErrors(errors);
}
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (Geometry geom : geometryList) {
if (geom.containsAnyError()) {
return true;
}
}
return false;
}
public Geometry getGeometry(GeometryType type, Lod lod) { public Geometry getGeometry(GeometryType type, Lod lod) {
for (Geometry geom : geometryList) { for (Geometry geom : geometryList) {
if (geom.getType() == type && geom.getLod() == lod) { if (geom.getType() == type && geom.getLod() == lod) {
...@@ -181,33 +204,5 @@ public abstract class CityObject extends GmlElement { ...@@ -181,33 +204,5 @@ public abstract class CityObject extends GmlElement {
return null; return null;
} }
@Override
public void prepareForChecking() {
for (Geometry geom : geometryList) {
geom.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
for (Geometry geom : geometryList) {
geom.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
for (Geometry geom : geometryList) {
handler.addInstance(geom);
}
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
CityObject originalCo = (CityObject) original;
for (Geometry geom : originalCo.geometryList) {
geometryList.add(handler.getCopyInstance(geom));
}
}
} }
...@@ -19,14 +19,11 @@ ...@@ -19,14 +19,11 @@
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
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.CheckId;
import de.hft.stuttgart.citydoctor2.check.Checkable; import de.hft.stuttgart.citydoctor2.check.Checkable;
import de.hft.stuttgart.citydoctor2.math.Vector3d; import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.tesselation.JoglTesselator; import de.hft.stuttgart.citydoctor2.tesselation.JoglTesselator;
import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon; import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler; import javafx.scene.paint.Color;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial; import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -184,6 +181,7 @@ public class ConcretePolygon extends Polygon { ...@@ -184,6 +181,7 @@ public class ConcretePolygon extends Polygon {
*/ */
@Override @Override
public void accept(Check c) { public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) { if (c.canExecute(this)) {
c.check(this); c.check(this);
} }
...@@ -195,7 +193,6 @@ public class ConcretePolygon extends Polygon { ...@@ -195,7 +193,6 @@ public class ConcretePolygon extends Polygon {
lr.accept(c); lr.accept(c);
} }
} }
setValidated(true);
} }
@Override @Override
...@@ -215,93 +212,6 @@ public class ConcretePolygon extends Polygon { ...@@ -215,93 +212,6 @@ public class ConcretePolygon extends Polygon {
return exterior.isRingConnectedViaPoint(other.getExteriorRing()); return exterior.isRingConnectedViaPoint(other.getExteriorRing());
} }
/*
* (non-Javadoc)
*
* @see de.hft.stuttgart.citydoctor2.datastructure.Polygon#containsAnyError()
*/
@Override
public boolean containsAnyError() {
if (super.containsAnyError()) {
return true;
}
if (exterior != null && exterior.containsAnyError()) {
return true;
}
if (innerRings != null) {
for (LinearRing lr : innerRings) {
if (lr.containsAnyError()) {
return true;
}
}
}
return false;
}
/*
* (non-Javadoc)
*
* @see
* de.hft.stuttgart.citydoctor2.datastructure.Polygon#collectContainedErrors(
* java.util.List)
*/
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
if (exterior != null) {
exterior.collectContainedErrors(errors);
}
if (innerRings != null) {
for (LinearRing lr : innerRings) {
lr.collectContainedErrors(errors);
}
}
}
/*
* (non-Javadoc)
*
* @see de.hft.stuttgart.citydoctor2.datastructure.Polygon#
* clearAllContainedCheckResults()
*/
@Override
public void clearAllContainedCheckResults() {
super.clearCheckResults();
if (exterior != null) {
exterior.clearAllContainedCheckResults();
}
if (innerRings != null) {
for (LinearRing lr : innerRings) {
lr.clearAllContainedCheckResults();
}
}
}
/*
* (non-Javadoc)
*
* @see de.hft.stuttgart.citydoctor2.datastructure.Polygon#containsError(de.hft.
* stuttgart.citydoctor2.check.CheckId)
*/
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
if (exterior != null && exterior.containsError(checkIdentifier)) {
return true;
}
if (innerRings != null) {
for (LinearRing lr : innerRings) {
if (lr.containsError(checkIdentifier)) {
return true;
}
}
}
return false;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
...@@ -479,51 +389,10 @@ public class ConcretePolygon extends Polygon { ...@@ -479,51 +389,10 @@ public class ConcretePolygon extends Polygon {
} }
@Override @Override
public void prepareForChecking() { public void prepareLowMemoryUsageMode() {
parent.prepareForChecking(); parent.updateEdgesAndVertices();
} }
@Override
public void clearMetaInformation() {
parent.clearMetaInformation();
}
@Override
public void collectInstances(CopyHandler handler) {
handler.addInstance(exterior);
if (innerRings != null) {
for (LinearRing lr : innerRings) {
handler.addInstance(lr);
}
}
handler.addInstance(partOfSurface);
handler.addInstance(partfOfInstallation);
handler.addInstance(parent);
handler.addInstance(linkedFromPolygon);
}
@Override
public Copyable createCopyInstance() {
return new ConcretePolygon();
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
ConcretePolygon originalPoly = (ConcretePolygon) original;
exterior = handler.getCopyInstance(originalPoly.exterior);
if (originalPoly.innerRings != null) {
innerRings = new ArrayList<>(originalPoly.innerRings.size());
for (LinearRing originalRing : originalPoly.innerRings) {
innerRings.add(handler.getCopyInstance(originalRing));
}
}
parent = handler.getCopyInstance(originalPoly.parent);
partfOfInstallation = handler.getCopyInstance(originalPoly.partfOfInstallation);
partOfSurface = handler.getCopyInstance(originalPoly.partOfSurface);
linkedFromPolygon = handler.getCopyInstance(originalPoly.linkedFromPolygon);
}
@Override @Override
public void remove() { public void remove() {
...@@ -545,6 +414,11 @@ public class ConcretePolygon extends Polygon { ...@@ -545,6 +414,11 @@ public class ConcretePolygon extends Polygon {
return area; return area;
} }
@Override
public Color getRenderColor() {
return parent.getRenderColor();
}
} }
...@@ -18,9 +18,6 @@ ...@@ -18,9 +18,6 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -31,7 +28,7 @@ import java.util.List; ...@@ -31,7 +28,7 @@ import java.util.List;
* *
* @author Matthias Betz * @author Matthias Betz
*/ */
public class Edge implements Serializable, Copyable { public class Edge implements Serializable {
@Serial @Serial
private static final long serialVersionUID = -504694863498128296L; private static final long serialVersionUID = -504694863498128296L;
...@@ -186,33 +183,7 @@ public class Edge implements Serializable, Copyable { ...@@ -186,33 +183,7 @@ public class Edge implements Serializable, Copyable {
} }
return null; return null;
} }
}
@Override
public void collectInstances(CopyHandler handler) {
handler.addInstance(from);
handler.addInstance(to);
handler.addInstance(adjacentPolygons);
handler.addInstance(adjacentRings);
}
@Override
public Copyable createCopyInstance() {
return new Edge();
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
Edge originalEdge = (Edge) original;
from = handler.getCopyInstance(originalEdge.from);
to = handler.getCopyInstance(originalEdge.to);
numberOfHalfEdges = originalEdge.numberOfHalfEdges;
numberOfOppositeHalfEdges = originalEdge.numberOfOppositeHalfEdges;
for (Polygon originalPoly : originalEdge.adjacentPolygons) {
adjacentPolygons.add(handler.getCopyInstance(originalPoly));
}
for (LinearRing originalRing : originalEdge.adjacentRings) {
adjacentRings.add(handler.getCopyInstance(originalRing));
}
}
}
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
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.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils; import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler; import javafx.scene.paint.Color;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
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.core.AbstractCityObject; import org.citygml4j.core.model.core.AbstractCityObject;
...@@ -47,7 +44,7 @@ public class GenericCityObject extends CityObject { ...@@ -47,7 +44,7 @@ public class GenericCityObject extends CityObject {
} }
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) { if (geom instanceof ImplicitGeometryHolder) {
continue; continue;
...@@ -60,23 +57,21 @@ public class GenericCityObject extends CityObject { ...@@ -60,23 +57,21 @@ public class GenericCityObject extends CityObject {
setSolidAccordingToLod(geom, solid); setSolidAccordingToLod(geom, solid);
} }
} }
for (BoundarySurface bs : boundarySurfaceList) { removeEmptyBoundarySurfaces();
reCreateBoundarySurface(factory, config, bs);
}
} }
private void reCreateBoundarySurface(GeometryFactory factory, ParserConfiguration config, BoundarySurface bs) { private void removeEmptyBoundarySurfaces() {
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.getGeometries().isEmpty()) { if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : cgmlGos.getBoundaries()) { for (AbstractSpaceBoundaryProperty bsp : cgmlGos.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) { if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from generic object", bs.getGmlId()); logger.warn("Found empty boundary surface: {}, removing from feature", bs.getGmlId());
cgmlGos.getBoundaries().remove(bsp); cgmlGos.getBoundaries().remove(bsp);
break; break;
} }
} }
return;
} }
bs.reCreateGeometries(factory, config); }
} }
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) { private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
...@@ -119,86 +114,9 @@ public class GenericCityObject extends CityObject { ...@@ -119,86 +114,9 @@ public class GenericCityObject extends CityObject {
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to buildings"); throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to buildings");
} }
} }
@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;
}
@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);
GenericCityObject originalGos = (GenericCityObject) original;
for (BoundarySurface originalBs : originalGos.boundarySurfaceList) {
boundarySurfaceList.add(handler.getCopyInstance(originalBs));
}
cgmlGos = originalGos.cgmlGos;
}
@Override @Override
public AbstractCityObject getGmlObject() { public AbstractCityObject getGmlObject() {
return null; return cgmlGos;
} }
@Override @Override
...@@ -210,16 +128,23 @@ public class GenericCityObject extends CityObject { ...@@ -210,16 +128,23 @@ public class GenericCityObject extends CityObject {
return boundarySurfaceList; return boundarySurfaceList;
} }
@Override
public Color getRenderColor() {
return Color.DARKGOLDENROD;
}
@Override @Override
public void unsetGmlGeometries() { public void unsetGmlGeometries() {
cgmlGos.setLod1Solid(null); cgmlGos.setLod1Solid(null);
cgmlGos.setLod2Solid(null); cgmlGos.setLod2Solid(null);
cgmlGos.setLod3Solid(null); cgmlGos.setLod3Solid(null);
cgmlGos.setLod0MultiSurface(null);
cgmlGos.setLod2MultiSurface(null); cgmlGos.setLod2MultiSurface(null);
cgmlGos.setLod3MultiSurface(null); cgmlGos.setLod3MultiSurface(null);
for (BoundarySurface bs : boundarySurfaceList) { cgmlGos.getDeprecatedProperties().setLod1Geometry(null);
bs.unsetGmlGeometries(); cgmlGos.getDeprecatedProperties().setLod2Geometry(null);
} cgmlGos.getDeprecatedProperties().setLod3Geometry(null);
cgmlGos.getDeprecatedProperties().setLod4Geometry(null);
} }
@Override @Override
...@@ -236,9 +161,4 @@ public class GenericCityObject extends CityObject { ...@@ -236,9 +161,4 @@ public class GenericCityObject extends CityObject {
bs.setParent(this); bs.setParent(this);
} }
@Override
public Copyable createCopyInstance() {
return new GenericCityObject();
}
} }
...@@ -19,19 +19,16 @@ ...@@ -19,19 +19,16 @@
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
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.CheckId;
import de.hft.stuttgart.citydoctor2.math.Triangle3d; import de.hft.stuttgart.citydoctor2.math.Triangle3d;
import de.hft.stuttgart.citydoctor2.math.Vector3d; import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon; import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon;
import de.hft.stuttgart.citydoctor2.utils.BoundingBoxCalculator; import de.hft.stuttgart.citydoctor2.utils.BoundingBoxCalculator;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import de.hft.stuttgart.citydoctor2.utils.SerializablePair; import de.hft.stuttgart.citydoctor2.utils.SerializablePair;
import javafx.scene.paint.Color;
import java.io.Serial; import java.io.Serial;
import java.util.*; import java.util.*;
import java.util.Map.Entry;
/** /**
* Representation of a geometry containing the polygons and edges * Representation of a geometry containing the polygons and edges
...@@ -207,49 +204,6 @@ public class Geometry extends GmlElement { ...@@ -207,49 +204,6 @@ public class Geometry extends GmlElement {
+ a[0] * b[1] * c[2]; + a[0] * b[1] * c[2];
} }
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (Polygon p : polygons) {
if (p.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public void clearAllContainedCheckResults() {
super.clearCheckResults();
for (Polygon p : polygons) {
p.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (Polygon p : polygons) {
p.collectContainedErrors(errors);
}
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (Polygon p : polygons) {
if (p.containsAnyError()) {
return true;
}
}
return false;
}
@Override @Override
public void accept(Check c) { public void accept(Check c) {
...@@ -378,13 +332,8 @@ public class Geometry extends GmlElement { ...@@ -378,13 +332,8 @@ public class Geometry extends GmlElement {
return false; return false;
} }
@Override
public void prepareForChecking() {
updateEdgesAndVertices();
}
@Override public void clearMetaData() {
public void clearMetaInformation() {
if (vertices != null) { if (vertices != null) {
for (Vertex v : vertices) { for (Vertex v : vertices) {
v.clearAdjacentRings(); v.clearAdjacentRings();
...@@ -395,57 +344,7 @@ public class Geometry extends GmlElement { ...@@ -395,57 +344,7 @@ public class Geometry extends GmlElement {
edgeMap = null; edgeMap = null;
} }
@Override public Color getRenderColor() {
public void collectInstances(CopyHandler handler) { return parent.getRenderColor();
handler.addInstance(parent);
handler.addInstance(polygons);
handler.addInstance(edges);
handler.addInstance(vertices);
if (edgeMap != null) {
for (Entry<SerializablePair<Vertex, Vertex>, Edge> e : edgeMap.entrySet()) {
handler.addInstance(e.getKey().getValue0());
handler.addInstance(e.getKey().getValue1());
handler.addInstance(e.getValue());
}
}
}
@Override
public Copyable createCopyInstance() {
return new Geometry(type, lod);
} }
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
Geometry originalGeometry = (Geometry) original;
for (Polygon originalPoly : originalGeometry.polygons) {
polygons.add(handler.getCopyInstance(originalPoly));
}
if (originalGeometry.edges != null) {
edges = new ArrayList<>(originalGeometry.edges.size());
for (Edge originalEdge : originalGeometry.edges) {
edges.add(handler.getCopyInstance(originalEdge));
}
}
if (originalGeometry.edgeMap != null) {
edgeMap = new HashMap<>(originalGeometry.edgeMap.size());
for (Entry<SerializablePair<Vertex, Vertex>, Edge> originalEntry : originalGeometry.edgeMap.entrySet()) {
Vertex copyV0 = handler.getCopyInstance(originalEntry.getKey().getValue0());
Vertex copyV1 = handler.getCopyInstance(originalEntry.getKey().getValue1());
SerializablePair<Vertex, Vertex> pair = new SerializablePair<>(copyV0, copyV1);
Edge copyEdge = handler.getCopyInstance(originalEntry.getValue());
edgeMap.put(pair, copyEdge);
}
}
if (originalGeometry.vertices != null) {
vertices = new ArrayList<>(originalGeometry.vertices.size());
for (Vertex originalVertex : originalGeometry.vertices) {
vertices.add(handler.getCopyInstance(originalVertex));
}
}
parent = handler.getCopyInstance(originalGeometry.parent);
}
} }
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Checkable; import de.hft.stuttgart.citydoctor2.check.Checkable;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial; import java.io.Serial;
...@@ -29,7 +27,7 @@ import java.io.Serial; ...@@ -29,7 +27,7 @@ import java.io.Serial;
* *
* @author Matthias Betz * @author Matthias Betz
*/ */
public abstract class GmlElement extends Checkable implements Copyable { public abstract class GmlElement extends Checkable {
@Serial @Serial
private static final long serialVersionUID = -3242505393303017359L; private static final long serialVersionUID = -3242505393303017359L;
...@@ -52,11 +50,5 @@ public abstract class GmlElement extends Checkable implements Copyable { ...@@ -52,11 +50,5 @@ public abstract class GmlElement extends Checkable implements Copyable {
return gmlId != null && !gmlId.isGenerated(); return gmlId != null && !gmlId.isGenerated();
} }
@Override
public void fillValues(Copyable original, CopyHandler handler) {
GmlElement originalElement = (GmlElement) original;
// generate gml id before copying
gmlId = originalElement.getGmlId();
}
} }
...@@ -62,32 +62,6 @@ public class ImplicitGeometryHolder extends Geometry { ...@@ -62,32 +62,6 @@ public class ImplicitGeometryHolder extends Geometry {
prototypeGeometry.accept(c); prototypeGeometry.accept(c);
} }
@Override
public boolean containsError(CheckId checkIdentifier) {
return prototypeGeometry.containsError(checkIdentifier);
}
@Override
public void clearAllContainedCheckResults() {
prototypeGeometry.clearAllContainedCheckResults();
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
prototypeGeometry.clearAllContainedCheckResults();
}
@Override
public boolean containsAnyError() {
return prototypeGeometry.containsAnyError();
}
@Override
public void prepareForChecking() {
this.updateEdgesAndVertices();
prototypeGeometry.prepareForChecking();
}
@Override @Override
public boolean isValidated() { public boolean isValidated() {
return prototypeGeometry.isValidated(); return prototypeGeometry.isValidated();
......
...@@ -19,15 +19,16 @@ ...@@ -19,15 +19,16 @@
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
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.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils; import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler; import javafx.scene.paint.Color;
import de.hft.stuttgart.citydoctor2.utils.Copyable; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.bridge.BridgeInstallation; import org.citygml4j.core.model.bridge.BridgeInstallation;
import org.citygml4j.core.model.construction.AbstractInstallation; import org.citygml4j.core.model.construction.AbstractInstallation;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty; import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.model.tunnel.TunnelInstallation;
import org.citygml4j.core.util.geometry.GeometryFactory; import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.GeometryProperty; import org.xmlobjects.gml.model.geometry.GeometryProperty;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface; import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
...@@ -44,13 +45,15 @@ public class Installation extends CityObject { ...@@ -44,13 +45,15 @@ public class Installation extends CityObject {
@Serial @Serial
private static final long serialVersionUID = 1576237433322680191L; private static final long serialVersionUID = 1576237433322680191L;
private static final Logger logger = LogManager.getLogger(Installation.class);
private List<BoundarySurface> boundarySurfaces = new ArrayList<>(4); private List<BoundarySurface> boundarySurfaces = new ArrayList<>(4);
private AbstractInstallation gmlBi; private AbstractInstallation gmlBi;
private CityObject parent; private CityObject parent;
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom.getType() == GeometryType.MULTI_SURFACE) { if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config); MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
...@@ -66,8 +69,20 @@ public class Installation extends CityObject { ...@@ -66,8 +69,20 @@ public class Installation extends CityObject {
throw new IllegalStateException("BuildingInstallation not have Solid geometries"); throw new IllegalStateException("BuildingInstallation not have Solid geometries");
} }
} }
removeEmptyBoundarySurfaces();
}
private void removeEmptyBoundarySurfaces() {
for (BoundarySurface bs : boundarySurfaces) { for (BoundarySurface bs : boundarySurfaces) {
bs.reCreateGeometries(factory, config); if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : gmlBi.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from feature", bs.getGmlId());
gmlBi.getBoundaries().remove(bsp);
break;
}
}
}
} }
} }
...@@ -125,50 +140,6 @@ public class Installation extends CityObject { ...@@ -125,50 +140,6 @@ public class Installation extends CityObject {
} }
} }
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (BoundarySurface bs : boundarySurfaces) {
bs.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (BoundarySurface bs : boundarySurfaces) {
bs.collectContainedErrors(errors);
}
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (BoundarySurface bs : boundarySurfaces) {
if (bs.containsAnyError()) {
return true;
}
}
return false;
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (BoundarySurface bs : boundarySurfaces) {
if (bs.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
public void setParent(CityObject parent) { public void setParent(CityObject parent) {
this.parent = parent; this.parent = parent;
} }
...@@ -177,21 +148,36 @@ public class Installation extends CityObject { ...@@ -177,21 +148,36 @@ public class Installation extends CityObject {
return parent; return parent;
} }
@Override
public Color getRenderColor() {
return parent.getRenderColor().darker();
}
public void addBoundarySurface(BoundarySurface bs) { public void addBoundarySurface(BoundarySurface bs) {
boundarySurfaces.add(bs); boundarySurfaces.add(bs);
bs.setParent(this); bs.setParent(this);
} }
@Override
public void unsetGmlGeometries() { public void unsetGmlGeometries() {
if (gmlBi instanceof org.citygml4j.core.model.building.BuildingInstallation localBi) { gmlBi.setLod0MultiSurface(null);
localBi.getDeprecatedProperties().setLod2Geometry(null); gmlBi.setLod2MultiSurface(null);
localBi.getDeprecatedProperties().setLod3Geometry(null); gmlBi.setLod3MultiSurface(null);
localBi.getDeprecatedProperties().setLod4Geometry(null); gmlBi.setLod1Solid(null);
} else if (gmlBi instanceof BridgeInstallation localBi) { gmlBi.setLod2Solid(null);
removeGeometriesFromBridgeInstallation(localBi); gmlBi.setLod3Solid(null);
} if (gmlBi instanceof org.citygml4j.core.model.building.BuildingInstallation buildingInstallation) {
for (BoundarySurface bs : boundarySurfaces) { buildingInstallation.getDeprecatedProperties().setLod2Geometry(null);
bs.unsetGmlGeometries(); buildingInstallation.getDeprecatedProperties().setLod3Geometry(null);
buildingInstallation.getDeprecatedProperties().setLod4Geometry(null);
} else if (gmlBi instanceof BridgeInstallation bridgeInstallation) {
bridgeInstallation.getDeprecatedProperties().setLod2Geometry(null);
bridgeInstallation.getDeprecatedProperties().setLod3Geometry(null);
bridgeInstallation.getDeprecatedProperties().setLod4Geometry(null);
} else if (gmlBi instanceof TunnelInstallation tunnelInstallation) {
tunnelInstallation.getDeprecatedProperties().setLod2Geometry(null);
tunnelInstallation.getDeprecatedProperties().setLod3Geometry(null);
tunnelInstallation.getDeprecatedProperties().setLod4Geometry(null);
} }
} }
...@@ -200,11 +186,6 @@ public class Installation extends CityObject { ...@@ -200,11 +186,6 @@ public class Installation extends CityObject {
return getParent().getTopLevelCityObject(); return getParent().getTopLevelCityObject();
} }
private void removeGeometriesFromBridgeInstallation(BridgeInstallation localBi) {
localBi.getDeprecatedProperties().setLod2Geometry(null);
localBi.getDeprecatedProperties().setLod3Geometry(null);
localBi.getDeprecatedProperties().setLod4Geometry(null);
}
public void setGmlObject(AbstractInstallation gmlBi) { public void setGmlObject(AbstractInstallation gmlBi) {
this.gmlBi = gmlBi; this.gmlBi = gmlBi;
...@@ -242,46 +223,4 @@ public class Installation extends CityObject { ...@@ -242,46 +223,4 @@ public class Installation extends CityObject {
} }
return boundarySurfaces; return boundarySurfaces;
} }
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (BoundarySurface bs : boundarySurfaces) {
bs.clearMetaInformation();
}
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (BoundarySurface bs : boundarySurfaces) {
bs.prepareForChecking();
}
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
Installation originalBi = (Installation) original;
for (BoundarySurface originalBs : originalBi.boundarySurfaces) {
boundarySurfaces.add(handler.getCopyInstance(originalBs));
}
gmlBi = originalBi.gmlBi;
parent = handler.getCopyInstance(parent);
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
for (BoundarySurface bs : boundarySurfaces) {
handler.addInstance(bs);
}
handler.addInstance(parent);
}
@Override
public Copyable createCopyInstance() {
return new Installation();
}
} }
...@@ -21,7 +21,7 @@ package de.hft.stuttgart.citydoctor2.datastructure; ...@@ -21,7 +21,7 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check; import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils; import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.Copyable; import javafx.scene.paint.Color;
import org.citygml4j.core.model.core.AbstractCityObject; import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.model.landuse.LandUse; import org.citygml4j.core.model.landuse.LandUse;
import org.citygml4j.core.util.geometry.GeometryFactory; import org.citygml4j.core.util.geometry.GeometryFactory;
...@@ -47,7 +47,7 @@ public class LandObject extends CityObject { ...@@ -47,7 +47,7 @@ public class LandObject extends CityObject {
} }
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom.getType() == GeometryType.MULTI_SURFACE) { if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config); MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
...@@ -63,6 +63,11 @@ public class LandObject extends CityObject { ...@@ -63,6 +63,11 @@ public class LandObject extends CityObject {
return FeatureType.LAND; return FeatureType.LAND;
} }
@Override
public Color getRenderColor() {
return Color.TAN;
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) { private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) { switch (geom.getLod()) {
case LOD0: case LOD0:
...@@ -119,9 +124,4 @@ public class LandObject extends CityObject { ...@@ -119,9 +124,4 @@ public class LandObject extends CityObject {
return "LandObject [id=" + getGmlId() + "]"; return "LandObject [id=" + getGmlId() + "]";
} }
@Override
public Copyable createCopyInstance() {
return new LandObject(lu);
}
} }
...@@ -20,8 +20,6 @@ package de.hft.stuttgart.citydoctor2.datastructure; ...@@ -20,8 +20,6 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check; import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.math.*; import de.hft.stuttgart.citydoctor2.math.*;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial; import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -235,11 +233,6 @@ public class LinearRing extends GmlElement { ...@@ -235,11 +233,6 @@ public class LinearRing extends GmlElement {
} }
} }
@Override
public void clearAllContainedCheckResults() {
super.clearCheckResults();
}
public void setParent(Polygon polygon) { public void setParent(Polygon polygon) {
parent = polygon; parent = polygon;
} }
...@@ -313,37 +306,8 @@ public class LinearRing extends GmlElement { ...@@ -313,37 +306,8 @@ public class LinearRing extends GmlElement {
vertices.addAll(extRing); vertices.addAll(extRing);
} }
@Override public void prepareLowMemoryUsageMode() {
public void prepareForChecking() { parent.prepareLowMemoryUsageMode();
parent.getParent().prepareForChecking();
}
@Override
public void clearMetaInformation() {
parent.getParent().clearMetaInformation();
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
LinearRing originalRing = (LinearRing) original;
type = originalRing.type;
parent = handler.getCopyInstance(originalRing.parent);
for (Vertex v : originalRing.vertices) {
vertices.add(handler.getCopyInstance(v));
}
} }
@Override
public void collectInstances(CopyHandler handler) {
for (Vertex v : vertices) {
handler.addInstance(v);
}
handler.addInstance(parent);
}
@Override
public Copyable createCopyInstance() {
return new LinearRing(type);
}
} }
...@@ -19,13 +19,11 @@ ...@@ -19,13 +19,11 @@
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
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.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.math.Vector3d; import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon; import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler; import javafx.scene.paint.Color;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial; import java.io.Serial;
import java.util.List; import java.util.List;
...@@ -77,8 +75,8 @@ public class LinkedPolygon extends Polygon { ...@@ -77,8 +75,8 @@ public class LinkedPolygon extends Polygon {
} }
@Override @Override
public boolean hasAnyError() { public boolean hasAnyErrorWithoutDependencies() {
return poly.hasAnyError(); return poly.hasAnyErrorWithoutDependencies();
} }
@Override @Override
...@@ -117,16 +115,6 @@ public class LinkedPolygon extends Polygon { ...@@ -117,16 +115,6 @@ public class LinkedPolygon extends Polygon {
poly.addCheckResult(cr); poly.addCheckResult(cr);
} }
@Override
public void collectContainedErrors(List<CheckError> errors) {
poly.collectContainedErrors(errors);
}
@Override
public boolean containsAnyError() {
return poly.containsAnyError();
}
@Override @Override
public boolean containsError(CheckId checkIdentifier) { public boolean containsError(CheckId checkIdentifier) {
return poly.containsError(checkIdentifier); return poly.containsError(checkIdentifier);
...@@ -247,24 +235,14 @@ public class LinkedPolygon extends Polygon { ...@@ -247,24 +235,14 @@ public class LinkedPolygon extends Polygon {
poly.anonymize(); poly.anonymize();
} }
@Override
public void clearAllContainedCheckResults() {
poly.clearAllContainedCheckResults();
}
@Override @Override
public ConcretePolygon getOriginal() { public ConcretePolygon getOriginal() {
return poly; return poly;
} }
@Override @Override
public void prepareForChecking() { public void prepareLowMemoryUsageMode() {
poly.prepareForChecking(); poly.prepareLowMemoryUsageMode();
}
@Override
public void clearMetaInformation() {
poly.clearMetaInformation();
} }
@Override @Override
...@@ -272,24 +250,6 @@ public class LinkedPolygon extends Polygon { ...@@ -272,24 +250,6 @@ public class LinkedPolygon extends Polygon {
return false; return false;
} }
@Override
public void collectInstances(CopyHandler handler) {
handler.addInstance(parent);
handler.addInstance(poly);
}
@Override
public Copyable createCopyInstance() {
return new LinkedPolygon();
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
LinkedPolygon linkedOriginal = (LinkedPolygon) original;
parent = handler.getCopyInstance(linkedOriginal.parent);
poly = handler.getCopyInstance(linkedOriginal.poly);
}
@Override @Override
public void remove() { public void remove() {
poly.remove(); poly.remove();
...@@ -300,4 +260,9 @@ public class LinkedPolygon extends Polygon { ...@@ -300,4 +260,9 @@ public class LinkedPolygon extends Polygon {
return poly.getArea(); return poly.getArea();
} }
@Override
public Color getRenderColor() {
return poly.getRenderColor();
}
} }
...@@ -21,8 +21,7 @@ package de.hft.stuttgart.citydoctor2.datastructure; ...@@ -21,8 +21,7 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check; import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils; import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler; import javafx.scene.paint.Color;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.construction.AbstractFillingSurface; import org.citygml4j.core.model.construction.AbstractFillingSurface;
import org.citygml4j.core.model.core.AbstractCityObject; import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.util.geometry.GeometryFactory; import org.citygml4j.core.util.geometry.GeometryFactory;
...@@ -61,7 +60,7 @@ public class Opening extends CityObject { ...@@ -61,7 +60,7 @@ public class Opening extends CityObject {
this.ao = ao; this.ao = ao;
} }
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
if (ao.getId() != null) { if (ao.getId() != null) {
ao.setId(getGmlId().getGmlString()); ao.setId(getGmlId().getGmlString());
} }
...@@ -122,11 +121,6 @@ public class Opening extends CityObject { ...@@ -122,11 +121,6 @@ public class Opening extends CityObject {
} }
} }
@Override
public void clearAllContainedCheckResults() {
super.clearCheckResults();
}
public void unsetGmlGeometries() { public void unsetGmlGeometries() {
ao.setLod0MultiSurface(null); ao.setLod0MultiSurface(null);
ao.setLod1MultiSurface(null); ao.setLod1MultiSurface(null);
...@@ -160,24 +154,12 @@ public class Opening extends CityObject { ...@@ -160,24 +154,12 @@ public class Opening extends CityObject {
} }
@Override @Override
public Copyable createCopyInstance() { public Color getRenderColor() {
return new Opening(type); return switch (type) {
} case DOOR -> Color.ORANGE;
case WINDOW -> Color.TEAL;
@Override default -> Color.BLACK;
public void collectInstances(CopyHandler handler) { };
super.collectInstances(handler);
handler.addInstance(partOf);
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
Opening originalOpening = (Opening) original;
partOf = handler.getCopyInstance(originalOpening.partOf);
type = originalOpening.type;
featureType = originalOpening.featureType;
ao = originalOpening.ao;
} }
} }
...@@ -20,6 +20,7 @@ package de.hft.stuttgart.citydoctor2.datastructure; ...@@ -20,6 +20,7 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.math.Vector3d; import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon; import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon;
import javafx.scene.paint.Color;
import java.io.Serial; import java.io.Serial;
import java.util.List; import java.util.List;
...@@ -80,8 +81,12 @@ public abstract class Polygon extends GmlElement { ...@@ -80,8 +81,12 @@ public abstract class Polygon extends GmlElement {
public abstract ConcretePolygon getOriginal(); public abstract ConcretePolygon getOriginal();
public abstract void prepareLowMemoryUsageMode();
public abstract void remove(); public abstract void remove();
public abstract double getArea(); public abstract double getArea();
public abstract Color getRenderColor();
} }
\ No newline at end of file
...@@ -19,11 +19,8 @@ ...@@ -19,11 +19,8 @@
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
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.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler; import javafx.scene.paint.Color;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.relief.ReliefFeature; import org.citygml4j.core.model.relief.ReliefFeature;
import org.citygml4j.core.util.geometry.GeometryFactory; import org.citygml4j.core.util.geometry.GeometryFactory;
...@@ -56,83 +53,7 @@ public class ReliefObject extends CityObject { ...@@ -56,83 +53,7 @@ public class ReliefObject extends CityObject {
} }
@Override @Override
public void collectInstances(CopyHandler handler) { public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
handler.addInstance(components);
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
ReliefObject originalRelief = (ReliefObject) original;
for (TinObject tin : originalRelief.components) {
components.add(handler.getCopyInstance(tin));
}
}
@Override
public Copyable createCopyInstance() {
return new ReliefObject(feature);
}
@Override
public void prepareForChecking() {
for (TinObject component : components) {
component.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
for (TinObject component : components) {
component.clearMetaInformation();
}
}
@Override
public void clearAllContainedCheckResults() {
for (TinObject component : components) {
component.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (TinObject tin : components) {
tin.collectContainedErrors(errors);
}
}
@Override
public boolean containsAnyError() {
boolean containsError = super.containsAnyError();
if (containsError) {
return true;
}
for (TinObject tin : components) {
if (tin.containsAnyError()) {
return true;
}
}
return false;
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (TinObject tin : components) {
if (tin.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
// no geometries // no geometries
} }
...@@ -156,6 +77,15 @@ public class ReliefObject extends CityObject { ...@@ -156,6 +77,15 @@ public class ReliefObject extends CityObject {
return FeatureType.LAND; return FeatureType.LAND;
} }
@Override
public Color getRenderColor() {
return Color.TAN;
}
public void addComponent(TinObject component) {
components.add(component);
}
public List<TinObject> getComponents() { public List<TinObject> getComponents() {
return components; return components;
} }
......
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
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.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.util.geometry.GeometryFactory; import org.citygml4j.core.util.geometry.GeometryFactory;
import java.io.Serial; import java.io.Serial;
...@@ -19,25 +15,10 @@ public class Storey extends AbstractBuildingSubdivision { ...@@ -19,25 +15,10 @@ public class Storey extends AbstractBuildingSubdivision {
private final List<BuildingUnit> buildingUnits = new ArrayList<>(); 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 @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config); super.reCreateGeometries(factory, config);
for (BuildingUnit buildingUnit : buildingUnits) {
buildingUnit.reCreateGeometries(factory, config);
}
} }
@Override @Override
...@@ -48,84 +29,6 @@ public class Storey extends AbstractBuildingSubdivision { ...@@ -48,84 +29,6 @@ public class Storey extends AbstractBuildingSubdivision {
} }
} }
@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;
}
public List<BuildingUnit> getBuildingUnits() { public List<BuildingUnit> getBuildingUnits() {
return buildingUnits; return buildingUnits;
} }
......
...@@ -21,9 +21,11 @@ package de.hft.stuttgart.citydoctor2.datastructure; ...@@ -21,9 +21,11 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check; import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils; import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import javafx.scene.paint.Color;
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.relief.TINRelief; import org.citygml4j.core.model.relief.TINRelief;
import org.citygml4j.core.model.relief.TinProperty;
import org.citygml4j.core.util.geometry.GeometryFactory; import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.primitives.AbstractRingProperty; import org.xmlobjects.gml.model.geometry.primitives.AbstractRingProperty;
import org.xmlobjects.gml.model.geometry.primitives.Triangle; import org.xmlobjects.gml.model.geometry.primitives.Triangle;
...@@ -55,13 +57,9 @@ public class TinObject extends CityObject { ...@@ -55,13 +57,9 @@ public class TinObject extends CityObject {
} }
} }
@Override
public TinObject createCopyInstance() {
return new TinObject(gmlRelief);
}
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
if (getGeometries().isEmpty()) { if (getGeometries().isEmpty()) {
return; return;
} }
...@@ -79,6 +77,8 @@ public class TinObject extends CityObject { ...@@ -79,6 +77,8 @@ public class TinObject extends CityObject {
t.setExterior(new AbstractRingProperty(CityGmlUtils.createGmlRing(factory, config, ring))); t.setExterior(new AbstractRingProperty(CityGmlUtils.createGmlRing(factory, config, ring)));
triangles.add(t); triangles.add(t);
} }
this.gmlRelief.setTin(new TinProperty(surface));
gmlRelief.setLod(geom.getLod().ordinal());
} }
@Override @Override
...@@ -101,4 +101,9 @@ public class TinObject extends CityObject { ...@@ -101,4 +101,9 @@ public class TinObject extends CityObject {
return FeatureType.LAND; return FeatureType.LAND;
} }
@Override
public Color getRenderColor() {
return Color.TAN;
}
} }
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
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.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.deprecated.transportation.TransportationComplex; import org.citygml4j.core.model.deprecated.transportation.TransportationComplex;
import org.citygml4j.core.model.transportation.Railway; import org.citygml4j.core.model.transportation.Railway;
import org.citygml4j.core.model.transportation.Road; import org.citygml4j.core.model.transportation.Road;
import org.citygml4j.core.model.transportation.Square; import org.citygml4j.core.model.transportation.Square;
import org.citygml4j.core.model.transportation.Track; import org.citygml4j.core.model.transportation.Track;
import org.citygml4j.core.model.transportation.Waterway; import org.citygml4j.core.model.transportation.Waterway;
import org.citygml4j.core.util.geometry.GeometryFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -65,10 +59,12 @@ public class TopLevelTransportFeature extends TransportationSpace { ...@@ -65,10 +59,12 @@ public class TopLevelTransportFeature extends TransportationSpace {
public void addSection(TransportSection section) { public void addSection(TransportSection section) {
sections.add(section); sections.add(section);
section.setParent(this);
} }
public void addIntersection(TransportSection section) { public void addIntersection(TransportSection section) {
intersections.add(section); intersections.add(section);
section.setParent(this);
} }
public List<TransportSection> getSections() { public List<TransportSection> getSections() {
...@@ -79,78 +75,6 @@ public class TopLevelTransportFeature extends TransportationSpace { ...@@ -79,78 +75,6 @@ public class TopLevelTransportFeature extends TransportationSpace {
return intersections; return intersections;
} }
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config);
for (TransportSection section : sections) {
section.reCreateGeometries(factory, config);
}
for (TransportSection section : intersections) {
section.reCreateGeometries(factory, config);
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (TransportSection section : sections) {
if (section.containsError(checkIdentifier)) {
return true;
}
}
for (TransportSection section : intersections) {
if (section.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (TransportSection section : sections) {
section.clearAllContainedCheckResults();
}
for (TransportSection section : intersections) {
section.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (TransportSection section : sections) {
section.collectContainedErrors(errors);
}
for (TransportSection section : intersections) {
section.collectContainedErrors(errors);
}
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (TransportSection section : sections) {
if (section.containsAnyError()) {
return true;
}
}
for (TransportSection section : intersections) {
if (section.containsAnyError()) {
return true;
}
}
return false;
}
@Override @Override
public void accept(Check c) { public void accept(Check c) {
super.accept(c); super.accept(c);
...@@ -165,78 +89,9 @@ public class TopLevelTransportFeature extends TransportationSpace { ...@@ -165,78 +89,9 @@ public class TopLevelTransportFeature extends TransportationSpace {
} }
} }
@Override
public void unsetGmlGeometries() {
super.unsetGmlGeometries();
for (TransportSection section : sections) {
section.unsetGmlGeometries();
}
for (TransportSection section : intersections) {
section.unsetGmlGeometries();
}
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
@Override @Override
public String toString() { public String toString() {
return "TopLevelTransportFeature [id=" + getGmlId() + "]"; return "TopLevelTransportFeature [id=" + getGmlId() + "]";
} }
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (TransportSection section : sections) {
section.prepareForChecking();
}
for (TransportSection section : intersections) {
section.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (TransportSection section : sections) {
section.clearMetaInformation();
}
for (TransportSection section : intersections) {
section.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
for (TransportSection section : sections) {
section.collectInstances(handler);
}
for (TransportSection section : intersections) {
section.collectInstances(handler);
}
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
TransportationObject originalTo = (TransportationObject) original;
for (TransportSection section : sections) {
section.fillValues(originalTo, handler);
}
for (TransportSection section : intersections) {
section.fillValues(originalTo, handler);
}
}
@Override
public Copyable createCopyInstance() {
return new TopLevelTransportFeature(type);
}
} }
...@@ -11,6 +11,9 @@ import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty; ...@@ -11,6 +11,9 @@ import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
public class TrafficAreaObject extends TransportationObject { public class TrafficAreaObject extends TransportationObject {
private TrafficSpaceObject parent;
public enum TrafficAreaType { public enum TrafficAreaType {
TRAFFIC_AREA, AUXILIARY_TRAFFIC_AREA TRAFFIC_AREA, AUXILIARY_TRAFFIC_AREA
} }
...@@ -24,7 +27,7 @@ public class TrafficAreaObject extends TransportationObject { ...@@ -24,7 +27,7 @@ public class TrafficAreaObject extends TransportationObject {
} }
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) { if (geom instanceof ImplicitGeometryHolder) {
continue; continue;
...@@ -40,6 +43,7 @@ public class TrafficAreaObject extends TransportationObject { ...@@ -40,6 +43,7 @@ public class TrafficAreaObject extends TransportationObject {
AuxiliaryTrafficArea ata = (AuxiliaryTrafficArea) super.getGmlObject(); AuxiliaryTrafficArea ata = (AuxiliaryTrafficArea) super.getGmlObject();
setMultiSurfaceAccordingToLod(ata, ms, geom.getLod()); setMultiSurfaceAccordingToLod(ata, ms, geom.getLod());
break; break;
} }
} else { } else {
throw new IllegalStateException("Geometry in TransportationObject cannot be of type " + geom.getType() throw new IllegalStateException("Geometry in TransportationObject cannot be of type " + geom.getType()
...@@ -99,6 +103,8 @@ public class TrafficAreaObject extends TransportationObject { ...@@ -99,6 +103,8 @@ public class TrafficAreaObject extends TransportationObject {
switch (type) { switch (type) {
case TRAFFIC_AREA: case TRAFFIC_AREA:
TrafficArea ta = (TrafficArea) super.getGmlObject(); TrafficArea ta = (TrafficArea) super.getGmlObject();
ta.setLod0MultiSurface(null);
ta.setLod1MultiSurface(null);
ta.setLod2MultiSurface(null); ta.setLod2MultiSurface(null);
ta.setLod3MultiSurface(null); ta.setLod3MultiSurface(null);
ta.getDeprecatedProperties().setLod4MultiSurface(null); ta.getDeprecatedProperties().setLod4MultiSurface(null);
...@@ -116,7 +122,15 @@ public class TrafficAreaObject extends TransportationObject { ...@@ -116,7 +122,15 @@ public class TrafficAreaObject extends TransportationObject {
@Override @Override
public CityObject getTopLevelCityObject() { public CityObject getTopLevelCityObject() {
return this; return parent.getTopLevelCityObject();
}
public void setParent(TrafficSpaceObject parent) {
this.parent = parent;
}
public TrafficSpaceObject getParent() {
return parent;
} }
@Override @Override
......
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
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.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils; 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.AbstractSpace; import org.citygml4j.core.model.core.AbstractSpace;
import org.citygml4j.core.util.geometry.GeometryFactory; import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface; import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty; 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.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -19,6 +17,8 @@ public class TrafficSpaceObject extends TransportationObject { ...@@ -19,6 +17,8 @@ public class TrafficSpaceObject extends TransportationObject {
private final List<TrafficAreaObject> trafficAreas = new ArrayList<>(); private final List<TrafficAreaObject> trafficAreas = new ArrayList<>();
private TransportationSpace parent;
public enum TrafficSpaceType { public enum TrafficSpaceType {
TRAFFIC_SPACE, AUXILIARY_TRAFFIC_SPACE TRAFFIC_SPACE, AUXILIARY_TRAFFIC_SPACE
} }
...@@ -37,20 +37,26 @@ public class TrafficSpaceObject extends TransportationObject { ...@@ -37,20 +37,26 @@ public class TrafficSpaceObject extends TransportationObject {
public void addTrafficArea(TrafficAreaObject trafficAreaObject) { public void addTrafficArea(TrafficAreaObject trafficAreaObject) {
trafficAreas.add(trafficAreaObject); trafficAreas.add(trafficAreaObject);
trafficAreaObject.setParent(this);
} }
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) { if (geom instanceof ImplicitGeometryHolder) {
continue; continue;
} }
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
AbstractSpace ats = (AbstractSpace) super.getGmlObject(); AbstractSpace ats = (AbstractSpace) super.getGmlObject();
if (geom.getType() == GeometryType.MULTI_SURFACE || geom.getType() == GeometryType.COMPOSITE_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(ats, ms, geom.getLod()); setMultiSurfaceAccordingToLod(ats, ms, geom.getLod());
} else if (geom.getType() == GeometryType.SOLID) {
Solid solid = CityGmlUtils.createSolid(geom, factory, config);
setSolidAccordingtoLod(ats, solid, geom.getLod());
} else {
throw new IllegalArgumentException("Unsupported geometry type: " + geom.getType());
} }
for (TrafficAreaObject tao : trafficAreas) {
tao.reCreateGeometries(factory, config);
} }
} }
...@@ -66,52 +72,26 @@ public class TrafficSpaceObject extends TransportationObject { ...@@ -66,52 +72,26 @@ public class TrafficSpaceObject extends TransportationObject {
ats.setLod3MultiSurface(new MultiSurfaceProperty(ms)); ats.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break; break;
default: default:
throw new IllegalStateException("cannot set geometry with LOD for AuxiliaryTrafficSpace: " + lod); throw new IllegalStateException(String.format("Cannot set MultiSurface with LOD %s for " +
} "[GML]AbstractSpace in TrafficSpaceObject ", lod));
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (TrafficAreaObject tao : trafficAreas) {
if (tao.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (TrafficAreaObject tao : trafficAreas) {
tao.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (TrafficAreaObject tao : trafficAreas) {
tao.collectContainedErrors(errors);
} }
} }
@Override private void setSolidAccordingtoLod(AbstractSpace ats, Solid solid, Lod lod) {
public boolean containsAnyError() { switch (lod) {
boolean hasError = super.containsAnyError(); case LOD1:
if (hasError) { ats.setLod1Solid(new SolidProperty(solid));
return true; break;
} case LOD2:
for (TrafficAreaObject tao : trafficAreas) { ats.setLod2Solid(new SolidProperty(solid));
if (tao.containsAnyError()) { break;
return true; case LOD3:
} ats.setLod3Solid(new SolidProperty(solid));
break;
default:
throw new IllegalStateException(String.format("Cannot set MultiSurface with LOD %s for " +
"[GML]AbstractSpace in TrafficSpaceObject ", lod));
} }
return false;
} }
@Override @Override
...@@ -131,60 +111,28 @@ public class TrafficSpaceObject extends TransportationObject { ...@@ -131,60 +111,28 @@ public class TrafficSpaceObject extends TransportationObject {
ats.setLod0MultiSurface(null); ats.setLod0MultiSurface(null);
ats.setLod2MultiSurface(null); ats.setLod2MultiSurface(null);
ats.setLod3MultiSurface(null); ats.setLod3MultiSurface(null);
for (TrafficAreaObject tao : trafficAreas) { ats.setLod1Solid(null);
tao.unsetGmlGeometries(); ats.setLod2Solid(null);
} ats.setLod3Solid(null);
} }
@Override @Override
public CityObject getTopLevelCityObject() { public CityObject getTopLevelCityObject() {
return this; return parent.getTopLevelCityObject();
} }
@Override public void setParent(TransportationSpace parent) {
public String toString() { this.parent = parent;
return "TransportationSpaceObject [id=" + getGmlId() + "]";
} }
@Override public TransportationSpace getParent() {
public void prepareForChecking() { return parent;
super.prepareForChecking();
for (TrafficAreaObject tao : trafficAreas) {
tao.prepareForChecking();
}
} }
@Override @Override
public void clearMetaInformation() { public String toString() {
super.clearMetaInformation(); return "TransportationSpaceObject [id=" + getGmlId() + "]";
for (TrafficAreaObject tao : trafficAreas) {
tao.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
for (TrafficAreaObject tao : trafficAreas) {
handler.addInstance(tao);
}
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
TrafficSpaceObject originalTao = (TrafficSpaceObject) original;
for (TrafficAreaObject tao : originalTao.trafficAreas) {
trafficAreas.add(handler.getCopyInstance(tao));
}
super.setGmlObject(originalTao.getGmlObject());
}
@Override
public Copyable createCopyInstance() {
return new TrafficSpaceObject(null);
} }
} }
...@@ -2,6 +2,8 @@ package de.hft.stuttgart.citydoctor2.datastructure; ...@@ -2,6 +2,8 @@ package de.hft.stuttgart.citydoctor2.datastructure;
public class TransportSection extends TransportationSpace { public class TransportSection extends TransportationSpace {
private TopLevelTransportFeature parent;
public enum SectionType { public enum SectionType {
SECTION, INTERSECTION SECTION, INTERSECTION
} }
...@@ -13,5 +15,17 @@ public class TransportSection extends TransportationSpace { ...@@ -13,5 +15,17 @@ public class TransportSection extends TransportationSpace {
} }
} }
public void setParent(TopLevelTransportFeature parent) {
this.parent = parent;
}
public TopLevelTransportFeature getParent() {
return parent;
}
@Override
public CityObject getTopLevelCityObject() {
return parent.getTopLevelCityObject();
}
} }
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