Commit 297334ab authored by Matthias Betz's avatar Matthias Betz
Browse files

Add design spec for OpenGL 3D view



Replaces the JavaFX SubScene/MeshView rendering with an OpenGL viewport
(openglfx-jogl, GL 3.3 core), single global VBO, GPU color-picking, and
baked fake shading. Windows/Linux targets; JavaFX 3D path removed.

Co-Authored-By: default avatarClaude Opus 4.8 <noreply@anthropic.com>
parents 5c2847ef bd40b396
......@@ -18,10 +18,8 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckableVisitor;
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.util.ArrayList;
......@@ -228,18 +226,13 @@ public class LinearRing extends GmlElement {
}
@Override
public void accept(Check c) {
public void accept(CheckableVisitor c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearCheckResults();
}
public void setParent(Polygon polygon) {
parent = polygon;
}
......@@ -313,37 +306,8 @@ public class LinearRing extends GmlElement {
vertices.addAll(extRing);
}
@Override
public void prepareForChecking() {
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));
}
public void prepareLowMemoryUsageMode() {
parent.prepareLowMemoryUsageMode();
}
@Override
public void collectInstances(CopyHandler handler) {
for (Vertex v : vertices) {
handler.addInstance(v);
}
handler.addInstance(parent);
}
@Override
public Copyable createCopyInstance() {
return new LinearRing(type);
}
}
......@@ -22,10 +22,12 @@ 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.CheckResult;
import de.hft.stuttgart.citydoctor2.check.Checkable;
import de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor;
import de.hft.stuttgart.citydoctor2.check.CheckableVisitor;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import javafx.scene.paint.Color;
import java.io.Serial;
import java.util.List;
......@@ -45,9 +47,6 @@ public class LinkedPolygon extends Polygon {
private Geometry parent;
private ConcretePolygon poly;
private LinkedPolygon() {
}
/**
* @param poly polygon this is linked to
* @param parent the parent of the linked polygon
......@@ -66,6 +65,52 @@ public class LinkedPolygon extends Polygon {
}
}
@Override
public boolean hasExistingGmlId() {
return poly.hasExistingGmlId();
}
@Override
public void setValidated(boolean validated) {
// Linked polys themselves are not checked
}
@Override
public boolean isValidated() {
return poly.isValidated();
}
//TODO: Think how to handle this, as it violates class contract if ignored
@Override
public void prepareForChecking() {
// Linked polys themselves are not checked
}
@Override
public void clearMetaInformation() {
// Linked polys themselves are not checked
}
@Override
public boolean hasError(CheckId checkIdentifier) {
return poly.hasError(checkIdentifier);
}
@Override
public boolean hasAnyError() {
return poly.hasAnyError();
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
poly.collectContainedErrors(errors);
}
@Override
public void collectErrors(List<CheckError> errors) {
poly.collectErrors(errors);
}
@Override
public CheckResult getCheckResult(Check c) {
return poly.getCheckResult(c);
......@@ -77,8 +122,8 @@ public class LinkedPolygon extends Polygon {
}
@Override
public boolean hasAnyError() {
return poly.hasAnyError();
public boolean hasAnyErrorWithoutDependencies() {
return poly.hasAnyErrorWithoutDependencies();
}
@Override
......@@ -107,9 +152,13 @@ public class LinkedPolygon extends Polygon {
}
@Override
public void accept(Check c) {
// linked polygons are not checked
setValidated(true);
public void accept(CheckableVisitor c) {
// LinkedPolygon should ignore Checks, as their referenced ConcretePolygon must be within the same TopLevelFeature.
// Checks always start iterating from a TopLevelFeature and thus will visit the referenced ConcretePolygon.
if (!c.isValidator()){
// Utility Visitors get passed to the ConcretePolygon, as they can start iterating from a sub-CityObject.
poly.accept(c);
}
}
@Override
......@@ -117,16 +166,6 @@ public class LinkedPolygon extends Polygon {
poly.addCheckResult(cr);
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
poly.collectContainedErrors(errors);
}
@Override
public boolean containsAnyError() {
return poly.containsAnyError();
}
@Override
public boolean containsError(CheckId checkIdentifier) {
return poly.containsError(checkIdentifier);
......@@ -247,24 +286,14 @@ public class LinkedPolygon extends Polygon {
poly.anonymize();
}
@Override
public void clearAllContainedCheckResults() {
poly.clearAllContainedCheckResults();
}
@Override
public ConcretePolygon getOriginal() {
return poly;
}
@Override
public void prepareForChecking() {
poly.prepareForChecking();
}
@Override
public void clearMetaInformation() {
poly.clearMetaInformation();
public void prepareLowMemoryUsageMode() {
poly.prepareLowMemoryUsageMode();
}
@Override
......@@ -272,24 +301,6 @@ public class LinkedPolygon extends Polygon {
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
public void remove() {
poly.remove();
......@@ -300,4 +311,9 @@ public class LinkedPolygon extends Polygon {
return poly.getArea();
}
@Override
public Color getRenderColor() {
return poly.getRenderColor();
}
}
......@@ -18,11 +18,10 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckableVisitor;
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 javafx.scene.paint.Color;
import org.citygml4j.core.model.construction.AbstractFillingSurface;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.util.geometry.GeometryFactory;
......@@ -45,23 +44,17 @@ public class Opening extends CityObject {
private BoundarySurface partOf;
private OpeningType type;
private SurfaceFeatureType featureType;
private AbstractFillingSurface ao;
private Opening(OpeningType type) {
this.type = type;
}
public Opening(OpeningType type, SurfaceFeatureType featureType, BoundarySurface partOf,
public Opening(OpeningType type, BoundarySurface partOf,
AbstractFillingSurface ao) {
this.featureType = featureType;
this.partOf = partOf;
this.type = type;
this.ao = ao;
}
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
if (ao.getId() != null) {
ao.setId(getGmlId().getGmlString());
}
......@@ -97,11 +90,6 @@ public class Opening extends CityObject {
}
}
public SurfaceFeatureType getSurfaceFeatureType() {
return featureType;
}
public BoundarySurface getPartOf() {
return partOf;
}
......@@ -115,18 +103,13 @@ public class Opening extends CityObject {
}
@Override
public void accept(Check c) {
public void accept(CheckableVisitor c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearCheckResults();
}
public void unsetGmlGeometries() {
ao.setLod0MultiSurface(null);
ao.setLod1MultiSurface(null);
......@@ -135,6 +118,11 @@ public class Opening extends CityObject {
ao.getDeprecatedProperties().setLod4MultiSurface(null);
}
@Override
public CityObject getTopLevelCityObject() {
return partOf.getTopLevelCityObject();
}
@Override
public String toString() {
return "Opening [type=" + type + ", id=" + getGmlId() + "]";
......@@ -155,24 +143,12 @@ public class Opening extends CityObject {
}
@Override
public Copyable createCopyInstance() {
return new Opening(type);
}
@Override
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;
public Color getRenderColor() {
return switch (type) {
case DOOR -> Color.ORANGE;
case WINDOW -> Color.TEAL;
default -> Color.BLACK;
};
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.CheckableVisitor;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.construction.OtherConstruction;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class OtherConstructionObject extends CityObject{
@Serial
private static final long serialVersionUID = -3885206364978761701L;
private static final Logger logger = LogManager.getLogger(OtherConstructionObject.class);
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
private OtherConstruction gmlObject;
@Override
public void accept(CheckableVisitor c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.accept(c);
}
}
public void setGmlObject(OtherConstruction gmlObject) {
this.gmlObject = gmlObject;
}
@Override
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms);
} else {
Solid solid = CityGmlUtils.createSolid(geom, factory, config);
setSolidAccordingToLod(geom, solid);
}
}
removeEmptyBoundarySurfaces();
}
private void removeEmptyBoundarySurfaces() {
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : gmlObject.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from feature", bs.getGmlId());
gmlObject.getBoundaries().remove(bsp);
break;
}
}
}
}
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) {
case LOD0:
gmlObject.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
gmlObject.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
gmlObject.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to other construction object");
}
}
private void setSolidAccordingToLod(Geometry geom, Solid solid) {
switch (geom.getLod()) {
case LOD1:
gmlObject.setLod1Solid(new SolidProperty(solid));
break;
case LOD2:
gmlObject.setLod2Solid(new SolidProperty(solid));
break;
case LOD3:
gmlObject.setLod3Solid(new SolidProperty(solid));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to other construction object");
}
}
@Override
public OtherConstruction getGmlObject() {
return gmlObject;
}
@Override
public void unsetGmlGeometries() {
gmlObject.setLod0MultiSurface(null);
gmlObject.setLod2MultiSurface(null);
gmlObject.setLod3MultiSurface(null);
gmlObject.setLod1Solid(null);
gmlObject.setLod2Solid(null);
gmlObject.setLod3Solid(null);
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
@Override
public FeatureType getFeatureType() {
return FeatureType.OTHER_CITY_OBJECT;
}
public void addBoundarySurface(BoundarySurface bs) {
boundarySurfaceList.add(bs);
bs.setParent(this);
}
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaceList;
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public final class PatchCollection implements Serializable {
@Serial
private static final long serialVersionUID = -1748657379840997228L;
private List<ConcretePolygon> patchMembers = new ArrayList<>();
public void addPatchMember(ConcretePolygon patchMember) {
patchMembers.add(patchMember);
patchMember.setPartOfPatch(this);
}
public List<ConcretePolygon> getPatchMembers() {
return new ArrayList<>(patchMembers);
}
}
......@@ -20,6 +20,7 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon;
import javafx.scene.paint.Color;
import java.io.Serial;
import java.util.List;
......@@ -80,8 +81,12 @@ public abstract class Polygon extends GmlElement {
public abstract ConcretePolygon getOriginal();
public abstract void prepareLowMemoryUsageMode();
public abstract void remove();
public abstract double getArea();
public abstract Color getRenderColor();
}
\ No newline at end of file
......@@ -14,20 +14,30 @@ public class RelativeGeometry extends Geometry {
@Serial
private static final long serialVersionUID = -686112245455298977L;
private static Map<Geometry, RelativeGeometry> relativeGeometries = new ConcurrentHashMap<>();
private static final Map<GmlId, RelativeGeometry> relativeGeometries = new ConcurrentHashMap<>();
public static RelativeGeometry of(Geometry geom) {
if (relativeGeometries.containsKey(geom)) {
return relativeGeometries.get(geom);
public static RelativeGeometry of(GmlId gmlId, Geometry geom) {
if (relativeGeometries.containsKey(gmlId)) {
return relativeGeometries.get(gmlId);
}
RelativeGeometry relGeo = new RelativeGeometry(geom.getType(), geom.getLod());
RelativeGeometry relGeo = new RelativeGeometry(geom.getType(), geom.getLod(), geom.getOrientation());
geom.getPolygons().forEach(relGeo::addPolygon);
relGeo.updateEdgesAndVertices();
relativeGeometries.put(geom, relGeo);
relativeGeometries.put(gmlId, relGeo);
return relGeo;
}
private RelativeGeometry(GeometryType type, Lod lod) {
super(type, lod);
public static RelativeGeometry of(GmlId gmlId) {
return relativeGeometries.getOrDefault(gmlId, null);
}
private RelativeGeometry(GeometryType type, Lod lod, Orientation orientation) {
super(type, lod, orientation);
}
public static void resetObjectMap() {
relativeGeometries.clear();
}
}
......@@ -18,12 +18,9 @@
*/
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.check.CheckableVisitor;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import javafx.scene.paint.Color;
import org.citygml4j.core.model.relief.ReliefFeature;
import org.citygml4j.core.util.geometry.GeometryFactory;
......@@ -45,7 +42,7 @@ public class ReliefObject extends CityObject {
}
@Override
public void accept(Check c) {
public void accept(CheckableVisitor c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
......@@ -56,99 +53,37 @@ public class ReliefObject extends CityObject {
}
@Override
public void collectInstances(CopyHandler handler) {
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);
}
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
// no geometries
}
@Override
public boolean containsAnyError() {
boolean containsError = super.containsAnyError();
if (containsError) {
return true;
}
for (TinObject tin : components) {
if (tin.containsAnyError()) {
return true;
}
}
return false;
public ReliefFeature getGmlObject() {
return feature;
}
@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;
public void unsetGmlGeometries() {
// no geometries
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
// no geometries
public CityObject getTopLevelCityObject() {
return this;
}
@Override
public ReliefFeature getGmlObject() {
return feature;
public FeatureType getFeatureType() {
return FeatureType.LAND;
}
@Override
public void unsetGmlGeometries() {
// no geometries
public Color getRenderColor() {
return Color.TAN;
}
@Override
public FeatureType getFeatureType() {
return FeatureType.LAND;
public void addComponent(TinObject component) {
components.add(component);
}
public List<TinObject> getComponents() {
......
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.check.CheckableVisitor;
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;
......@@ -19,110 +15,21 @@ public class Storey extends AbstractBuildingSubdivision {
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) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config);
for (BuildingUnit buildingUnit : buildingUnits) {
buildingUnit.reCreateGeometries(factory, config);
}
}
@Override
public void accept(Check c) {
public void accept(CheckableVisitor 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;
public List<BuildingUnit> getBuildingUnits() {
return buildingUnits;
}
}
......@@ -18,12 +18,14 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckableVisitor;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import javafx.scene.paint.Color;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.relief.TINRelief;
import org.citygml4j.core.model.relief.TinProperty;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.primitives.AbstractRingProperty;
import org.xmlobjects.gml.model.geometry.primitives.Triangle;
......@@ -48,20 +50,16 @@ public class TinObject extends CityObject {
}
@Override
public void accept(Check c) {
public void accept(CheckableVisitor c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
}
@Override
public TinObject createCopyInstance() {
return new TinObject(gmlRelief);
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
if (getGeometries().isEmpty()) {
return;
}
......@@ -79,6 +77,8 @@ public class TinObject extends CityObject {
t.setExterior(new AbstractRingProperty(CityGmlUtils.createGmlRing(factory, config, ring)));
triangles.add(t);
}
this.gmlRelief.setTin(new TinProperty(surface));
gmlRelief.setLod(geom.getLod().ordinal());
}
@Override
......@@ -91,9 +91,19 @@ public class TinObject extends CityObject {
gmlRelief.setTin(null);
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
@Override
public FeatureType getFeatureType() {
return FeatureType.LAND;
}
@Override
public Color getRenderColor() {
return Color.TAN;
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.CheckableVisitor;
import org.citygml4j.core.model.deprecated.transportation.TransportationComplex;
import org.citygml4j.core.model.transportation.Railway;
import org.citygml4j.core.model.transportation.Road;
import org.citygml4j.core.model.transportation.Square;
import org.citygml4j.core.model.transportation.Track;
import org.citygml4j.core.model.transportation.Waterway;
import java.util.ArrayList;
import java.util.List;
public class TopLevelTransportFeature extends TransportationSpace {
private final List<TransportSection> sections = new ArrayList<>();
private final List<TransportSection> intersections = new ArrayList<>();
public static TopLevelTransportFeature from(Track t) {
TopLevelTransportFeature top = new TopLevelTransportFeature(TransportationType.TRACK);
top.setGmlObject(t);
return top;
}
public static TopLevelTransportFeature from(Road r) {
TopLevelTransportFeature top = new TopLevelTransportFeature(TransportationType.ROAD);
top.setGmlObject(r);
return top;
}
public static TopLevelTransportFeature from(Waterway w) {
TopLevelTransportFeature top = new TopLevelTransportFeature(TransportationType.WATERWAY);
top.setGmlObject(w);
return top;
}
public static TopLevelTransportFeature from(Railway r) {
TopLevelTransportFeature top = new TopLevelTransportFeature(TransportationType.RAILWAY);
top.setGmlObject(r);
return top;
}
public static TopLevelTransportFeature from(Square s) {
TopLevelTransportFeature top = new TopLevelTransportFeature(TransportationType.SQUARE);
top.setGmlObject(s);
return top;
}
public static TopLevelTransportFeature from(TransportationComplex tc) {
TopLevelTransportFeature top = new TopLevelTransportFeature(TransportationType.TRANSPORTATION_COMPLEX);
top.setGmlObject(tc);
return top;
}
private TopLevelTransportFeature(TransportationType type) {
super(type);
}
public void addSection(TransportSection section) {
sections.add(section);
section.setParent(this);
}
public void addIntersection(TransportSection section) {
intersections.add(section);
section.setParent(this);
}
public List<TransportSection> getSections() {
return sections;
}
public List<TransportSection> getIntersections() {
return intersections;
}
@Override
public void accept(CheckableVisitor c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (TransportSection section : sections) {
section.accept(c);
}
for (TransportSection section : intersections) {
section.accept(c);
}
}
@Override
public String toString() {
return "TopLevelTransportFeature [id=" + getGmlId() + "]";
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import org.citygml4j.core.model.transportation.AuxiliaryTrafficArea;
import org.citygml4j.core.model.transportation.TrafficArea;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
public class TrafficAreaObject extends TransportationObject {
private TrafficSpaceObject parent;
public enum TrafficAreaType {
TRAFFIC_AREA, AUXILIARY_TRAFFIC_AREA
}
public TrafficAreaObject(TrafficAreaType trafficAreaType) {
if (trafficAreaType == TrafficAreaType.TRAFFIC_AREA) {
setType(TransportationType.TRAFFIC_AREA);
} else {
setType(TransportationType.AUXILLIARY_TRAFFIC_AREA);
}
}
@Override
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
switch (type) {
case TRAFFIC_AREA:
TrafficArea ta = (TrafficArea) super.getGmlObject();
setMultiSurfaceAccordingToLod(ta, ms, geom.getLod());
break;
case AUXILLIARY_TRAFFIC_AREA:
AuxiliaryTrafficArea ata = (AuxiliaryTrafficArea) super.getGmlObject();
setMultiSurfaceAccordingToLod(ata, ms, geom.getLod());
break;
}
} else {
throw new IllegalStateException("Geometry in TransportationObject cannot be of type " + geom.getType()
+ ". Only MultiSurface allowed");
}
}
}
private void setMultiSurfaceAccordingToLod(AuxiliaryTrafficArea ata, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
ata.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD1:
ata.setLod1MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
ata.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
ata.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
ata.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for AuxiliaryTrafficArea: " + lod);
}
}
private void setMultiSurfaceAccordingToLod(TrafficArea ta, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
ta.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD1:
ta.setLod1MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
ta.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
ta.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
ta.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for TrafficArea: " + lod);
}
}
@Override
public void unsetGmlGeometries() {
switch (type) {
case TRAFFIC_AREA:
TrafficArea ta = (TrafficArea) super.getGmlObject();
ta.setLod0MultiSurface(null);
ta.setLod1MultiSurface(null);
ta.setLod2MultiSurface(null);
ta.setLod3MultiSurface(null);
ta.getDeprecatedProperties().setLod4MultiSurface(null);
break;
case AUXILLIARY_TRAFFIC_AREA:
AuxiliaryTrafficArea ata = (AuxiliaryTrafficArea) super.getGmlObject();
ata.setLod0MultiSurface(null);
ata.setLod1MultiSurface(null);
ata.setLod2MultiSurface(null);
ata.setLod3MultiSurface(null);
ata.getDeprecatedProperties().setLod4MultiSurface(null);
break;
}
}
@Override
public CityObject getTopLevelCityObject() {
return parent.getTopLevelCityObject();
}
public void setParent(TrafficSpaceObject parent) {
this.parent = parent;
}
public TrafficSpaceObject getParent() {
return parent;
}
@Override
public String toString() {
return "TrafficArea [id=" + getGmlId() + "]";
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.CheckableVisitor;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import org.citygml4j.core.model.core.AbstractSpace;
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.util.ArrayList;
import java.util.List;
public class TrafficSpaceObject extends TransportationObject {
private final List<TrafficAreaObject> trafficAreas = new ArrayList<>();
private TransportationSpace parent;
public enum TrafficSpaceType {
TRAFFIC_SPACE, AUXILIARY_TRAFFIC_SPACE
}
public TrafficSpaceObject(TrafficSpaceType trafficSpaceType) {
if (trafficSpaceType == TrafficSpaceType.TRAFFIC_SPACE) {
super.setType(TransportationType.TRAFFIC_SPACE);
} else {
super.setType(TransportationType.AUXILLIARY_TRAFFIC_SPACE);
}
}
public List<TrafficAreaObject> getTrafficAreas() {
return trafficAreas;
}
public void addTrafficArea(TrafficAreaObject trafficAreaObject) {
trafficAreas.add(trafficAreaObject);
trafficAreaObject.setParent(this);
}
@Override
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
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());
} 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());
}
}
}
private void setMultiSurfaceAccordingToLod(AbstractSpace ats, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
ats.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
ats.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
ats.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException(String.format("Cannot set MultiSurface with LOD %s for " +
"[GML]AbstractSpace in TrafficSpaceObject ", lod));
}
}
private void setSolidAccordingtoLod(AbstractSpace ats, Solid solid, Lod lod) {
switch (lod) {
case LOD1:
ats.setLod1Solid(new SolidProperty(solid));
break;
case LOD2:
ats.setLod2Solid(new SolidProperty(solid));
break;
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));
}
}
@Override
public void accept(CheckableVisitor c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (TrafficAreaObject tao : trafficAreas) {
tao.accept(c);
}
}
@Override
public void unsetGmlGeometries() {
AbstractSpace ats = (AbstractSpace) super.getGmlObject();
ats.setLod0MultiSurface(null);
ats.setLod2MultiSurface(null);
ats.setLod3MultiSurface(null);
ats.setLod1Solid(null);
ats.setLod2Solid(null);
ats.setLod3Solid(null);
}
@Override
public CityObject getTopLevelCityObject() {
return parent.getTopLevelCityObject();
}
public void setParent(TransportationSpace parent) {
this.parent = parent;
}
public TransportationSpace getParent() {
return parent;
}
@Override
public String toString() {
return "TransportationSpaceObject [id=" + getGmlId() + "]";
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
public class TransportSection extends TransportationSpace {
private TopLevelTransportFeature parent;
public enum SectionType {
SECTION, INTERSECTION
}
public TransportSection(SectionType sectionType) {
super(TransportationType.SECTION);
if (sectionType == SectionType.INTERSECTION) {
super.setType(TransportationType.INTERSECTION);
}
}
public void setParent(TopLevelTransportFeature parent) {
this.parent = parent;
}
public TopLevelTransportFeature getParent() {
return parent;
}
@Override
public CityObject getTopLevelCityObject() {
return parent.getTopLevelCityObject();
}
}
......@@ -18,21 +18,9 @@
*/
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 javafx.scene.paint.Color;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.model.core.AbstractSpace;
import org.citygml4j.core.model.transportation.AbstractTransportationSpace;
import org.citygml4j.core.model.transportation.AuxiliaryTrafficArea;
import org.citygml4j.core.model.transportation.TrafficArea;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import java.io.Serial;
import java.util.ArrayList;
......@@ -43,190 +31,33 @@ import java.util.List;
*
* @author Matthias Betz
*/
public class TransportationObject extends CityObject {
public abstract class TransportationObject extends CityObject {
@Serial
private static final long serialVersionUID = -2698907271726700390L;
public enum TransportationType {
ROAD, TRACK, RAILWAY, TRAFFIC_AREA, AUXILLIARY_TRAFFIC_AREA, TRANSPORTATION_COMPLEX, SQUARE, AUXILLIARY_TRAFFIC_SPACE, TRAFFIC_SPACE
ROAD, TRACK, RAILWAY, TRAFFIC_AREA, AUXILLIARY_TRAFFIC_AREA, TRANSPORTATION_COMPLEX, SQUARE, AUXILLIARY_TRAFFIC_SPACE,
TRAFFIC_SPACE, WATERWAY, SECTION, INTERSECTION
}
private AbstractCityObject ato;
private final List<TransportationObject> composesOf = new ArrayList<>(1);
private final TransportationType type;
protected TransportationType type;
public TransportationObject(TransportationType type) {
this.type = type;
}
@Override
public FeatureType getFeatureType() {
return FeatureType.TRANSPORTATION;
}
@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) {
case ROAD, TRACK, RAILWAY, SQUARE, TRANSPORTATION_COMPLEX:
AbstractTransportationSpace tc = (AbstractTransportationSpace) ato;
setMultiSurfaceAccordingToLod(tc, ms, geom.getLod());
break;
case TRAFFIC_AREA:
TrafficArea ta = (TrafficArea) ato;
setMultiSurfaceAccordingToLod(ta, ms, geom.getLod());
break;
case AUXILLIARY_TRAFFIC_AREA:
AuxiliaryTrafficArea ata = (AuxiliaryTrafficArea) ato;
setMultiSurfaceAccordingToLod(ata, ms, geom.getLod());
break;
case AUXILLIARY_TRAFFIC_SPACE, TRAFFIC_SPACE:
AbstractSpace ats = (AbstractSpace) ato;
setMultiSurfaceAccordingToLod(ats, ms, geom.getLod());
break;
}
} else {
throw new IllegalStateException("Geometry in TransportationObject cannot be of type " + geom.getType()
+ ". Only MultiSurface allowed");
}
}
for (TransportationObject children : composesOf) {
children.reCreateGeometries(factory, config);
}
}
private void setMultiSurfaceAccordingToLod(AbstractSpace ats, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
ats.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
ats.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
ats.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for AuxiliaryTrafficSpace: " + lod);
}
}
private void setMultiSurfaceAccordingToLod(AbstractTransportationSpace tc, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD1:
tc.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
tc.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
tc.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
tc.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for TransportationComplex: " + lod);
}
}
private void setMultiSurfaceAccordingToLod(AuxiliaryTrafficArea ata, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
ata.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD1:
ata.setLod1MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
ata.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
ata.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
ata.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for AuxiliaryTrafficArea: " + lod);
}
}
private void setMultiSurfaceAccordingToLod(TrafficArea ta, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD2:
ta.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
ta.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
ta.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for TrafficArea: " + lod);
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (TransportationObject to : composesOf) {
if (to.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (TransportationObject to : composesOf) {
to.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (TransportationObject to : composesOf) {
to.collectContainedErrors(errors);
}
protected TransportationObject() {
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (TransportationObject to : composesOf) {
if (to.containsAnyError()) {
return true;
}
}
return false;
void setType(TransportationType type) {
this.type = type;
}
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (TransportationObject to : composesOf) {
to.accept(c);
}
public FeatureType getFeatureType() {
return FeatureType.TRANSPORTATION;
}
@Override
......@@ -235,49 +66,21 @@ public class TransportationObject extends CityObject {
}
@Override
public void unsetGmlGeometries() {
switch (type) {
case ROAD, TRACK, RAILWAY, SQUARE, TRANSPORTATION_COMPLEX:
AbstractTransportationSpace tc = (AbstractTransportationSpace) ato;
tc.getDeprecatedProperties().setLod1MultiSurface(null);
tc.setLod2MultiSurface(null);
tc.setLod3MultiSurface(null);
tc.getDeprecatedProperties().setLod4MultiSurface(null);
break;
case TRAFFIC_AREA:
TrafficArea ta = (TrafficArea) ato;
ta.setLod2MultiSurface(null);
ta.setLod3MultiSurface(null);
ta.getDeprecatedProperties().setLod4MultiSurface(null);
break;
case AUXILLIARY_TRAFFIC_AREA:
AuxiliaryTrafficArea ata = (AuxiliaryTrafficArea) ato;
ata.setLod0MultiSurface(null);
ata.setLod1MultiSurface(null);
ata.setLod2MultiSurface(null);
ata.setLod3MultiSurface(null);
ata.getDeprecatedProperties().setLod4MultiSurface(null);
break;
case AUXILLIARY_TRAFFIC_SPACE, TRAFFIC_SPACE:
AbstractSpace ats = (AbstractSpace) ato;
ats.setLod0MultiSurface(null);
ats.setLod2MultiSurface(null);
ats.setLod3MultiSurface(null);
break;
}
public Color getRenderColor() {
return switch (type) {
case TRACK -> Color.BROWN;
case WATERWAY -> Color.NAVY;
case SQUARE -> Color.DARKSLATEGRAY;
case AUXILLIARY_TRAFFIC_AREA, AUXILLIARY_TRAFFIC_SPACE -> Color.LIGHTSLATEGREY;
default -> Color.DIMGRAY;
};
}
public void setGmlObject(AbstractCityObject tc) {
ato = tc;
}
public void addChild(TransportationObject subTrans) {
composesOf.add(subTrans);
}
public List<TransportationObject> getChildren() {
return composesOf;
}
public TransportationType getTransportationType() {
return type;
......@@ -289,42 +92,8 @@ public class TransportationObject extends CityObject {
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (TransportationObject child : composesOf) {
child.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (TransportationObject child : composesOf) {
child.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
for (TransportationObject to : composesOf) {
handler.addInstance(to);
}
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
TransportationObject originalTo = (TransportationObject) original;
for (TransportationObject to : originalTo.composesOf) {
composesOf.add(handler.getCopyInstance(to));
}
ato = originalTo.ato;
}
@Override
public Copyable createCopyInstance() {
return new TransportationObject(type);
public String getDisplayText() {
return String.format("[%s] %s", this.type.name(), this.getGmlId().toString());
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.CheckableVisitor;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import org.citygml4j.core.model.core.AbstractSpace;
import org.citygml4j.core.model.transportation.AbstractTransportationSpace;
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.util.ArrayList;
import java.util.List;
public abstract class TransportationSpace extends TransportationObject {
private final List<TrafficSpaceObject> trafficSpaces = new ArrayList<>();
private final List<TrafficSpaceObject> auxTrafficSpaces = new ArrayList<>();
protected TransportationSpace(TransportationType type) {
super(type);
}
public List<TrafficSpaceObject> getTrafficSpaces() {
return trafficSpaces;
}
public List<TrafficSpaceObject> getAuxTrafficSpaces() {
return auxTrafficSpaces;
}
public void addTrafficSpace(TrafficSpaceObject t) {
trafficSpaces.add(t);
t.setParent(this);
}
public void addAuxTrafficSpace(TrafficSpaceObject t) {
auxTrafficSpaces.add(t);
t.setParent(this);
}
@Override
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (super.getGmlObject() instanceof AbstractTransportationSpace ats) {
if (geom.getType() == GeometryType.MULTI_SURFACE || geom.getType() == GeometryType.COMPOSITE_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
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());
}
} else if (super.getGmlObject() instanceof AbstractSpace as) {
if (geom.getType() == GeometryType.MULTI_SURFACE || geom.getType() == GeometryType.COMPOSITE_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(as, ms, geom.getLod());
} else if (geom.getType() == GeometryType.SOLID) {
Solid solid = CityGmlUtils.createSolid(geom, factory, config);
setSolidAccordingToLod(as, solid, geom.getLod());
} else {
throw new IllegalArgumentException("Unsupported geometry type: " + geom.getType());
}
}
}
}
private void setMultiSurfaceAccordingToLod(AbstractTransportationSpace ats, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0 -> ats.setLod0MultiSurface(new MultiSurfaceProperty(ms));
case LOD1 -> ats.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
case LOD2 -> ats.setLod2MultiSurface(new MultiSurfaceProperty(ms));
case LOD3 -> ats.setLod3MultiSurface(new MultiSurfaceProperty(ms));
case LOD4 -> ats.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
default -> throw new IllegalStateException(String.format("Cannot set MultiSurface with LOD %s for " +
"[GML]AbstractTransportationSpace in TransportationSpace ", lod));
}
}
private void setMultiSurfaceAccordingToLod(AbstractSpace as, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
as.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
as.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
as.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException(String.format("Cannot set MultiSurface with LOD %s for [GML]AbstractSpace in TransportationSpace ", lod));
}
}
private void setSolidAccordingToLod(AbstractTransportationSpace ats, Solid solid, Lod lod) {
switch (lod) {
case LOD1 -> ats.setLod1Solid(new SolidProperty(solid));
case LOD2 -> ats.setLod2Solid(new SolidProperty(solid));
case LOD3 -> ats.setLod3Solid(new SolidProperty(solid));
default -> throw new IllegalStateException(String.format("Cannot set Solid with LOD %s for " +
"[GML]AbstractTransportationSpace in TransportationSpace ", lod));
}
}
private void setSolidAccordingToLod(AbstractSpace ats, Solid solid, Lod lod) {
switch (lod) {
case LOD1 -> ats.setLod1Solid(new SolidProperty(solid));
case LOD2 -> ats.setLod2Solid(new SolidProperty(solid));
case LOD3 -> ats.setLod3Solid(new SolidProperty(solid));
default ->
throw new IllegalStateException(String.format("Cannot set Solid with LOD %s for [GML]AbstractSpace" +
" in TransportationSpace ", lod));
}
}
@Override
public void accept(CheckableVisitor c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (TrafficSpaceObject to : trafficSpaces) {
to.accept(c);
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.accept(c);
}
}
@Override
public void unsetGmlGeometries() {
AbstractSpace ats = (AbstractSpace) super.getGmlObject();
ats.setLod0MultiSurface(null);
ats.setLod2MultiSurface(null);
ats.setLod3MultiSurface(null);
ats.setLod1Solid(null);
ats.setLod2Solid(null);
ats.setLod3Solid(null);
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
@Override
public String toString() {
return "TransportationSpace [id=" + getGmlId() + "]";
}
}
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 de.hft.stuttgart.citydoctor2.check.CheckableVisitor;
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;
......@@ -26,16 +20,14 @@ public class Tunnel extends AbstractTunnel {
return tunnelParts;
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config);
for (TunnelPart tp : tunnelParts) {
tp.reCreateGeometries(factory, config);
}
public CityObject getTopLevelCityObject() {
return this;
}
@Override
public void accept(Check c) {
public void accept(CheckableVisitor c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
......@@ -45,50 +37,6 @@ public class Tunnel extends AbstractTunnel {
}
}
@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);
}
......@@ -115,43 +63,6 @@ public class Tunnel extends AbstractTunnel {
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.check.CheckableVisitor;
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 javafx.scene.paint.Color;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
......@@ -31,19 +28,27 @@ public class TunnelConstructiveElement extends CityObject {
private final org.citygml4j.core.model.tunnel.TunnelConstructiveElement gmlTunnelElement;
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
private AbstractTunnel parent;
public TunnelConstructiveElement(org.citygml4j.core.model.tunnel.TunnelConstructiveElement gmlObject) {
this.gmlTunnelElement = gmlObject;
}
public void setParent(AbstractTunnel parent) {
this.parent = parent;
}
public AbstractTunnel getParent() {
return parent;
}
@Override
public Copyable createCopyInstance() {
return new TunnelConstructiveElement(gmlTunnelElement);
public Color getRenderColor() {
return parent.getRenderColor();
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
// only handles CityGML2 for now
// unknown which CityGML is handled here
// need context information to decide
......@@ -64,13 +69,25 @@ public class TunnelConstructiveElement extends CityObject {
throw new IllegalStateException("Tunnel constructive element cannot have a composite surface geometry");
}
}
removeEmptyBoundarySurfaces();
}
private void removeEmptyBoundarySurfaces() {
for (BoundarySurface bs : boundarySurfaceList) {
reCreateBoundarySurface(factory, config, 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 feature", bs.getGmlId());
gmlTunnelElement.getBoundaries().remove(bsp);
break;
}
}
}
}
}
@Override
public void accept(Check c) {
public void accept(CheckableVisitor c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
......@@ -80,50 +97,6 @@ public class TunnelConstructiveElement extends CityObject {
}
}
@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()) {
......@@ -183,9 +156,12 @@ public class TunnelConstructiveElement extends CityObject {
gmlTunnelElement.setLod1Solid(null);
gmlTunnelElement.setLod2Solid(null);
gmlTunnelElement.setLod3Solid(null);
for (BoundarySurface bs : boundarySurfaceList) {
bs.unsetGmlGeometries();
}
}
@Override
public CityObject getTopLevelCityObject() {
return getParent().getTopLevelCityObject();
}
@Override
......@@ -202,34 +178,4 @@ public class TunnelConstructiveElement extends CityObject {
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;
......@@ -13,9 +12,4 @@ public class TunnelFurniture extends AbstractFurniture {
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 javafx.scene.paint.Color;
import org.citygml4j.core.model.tunnel.TunnelFurnitureProperty;
import java.io.Serial;
......@@ -36,21 +35,13 @@ public class TunnelHollow extends AbstractRoom {
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
TunnelHollow oHollow = (TunnelHollow) original;
parent = handler.getCopyInstance(oHollow.getParent());
public Color getRenderColor() {
return parent.getRenderColor();
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(parent);
public CityObject getTopLevelCityObject() {
return parent.getTopLevelCityObject();
}
@Override
public Copyable createCopyInstance() {
return new TunnelHollow();
}
}
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