Commit 845dd0a6 authored by Matthias Betz's avatar Matthias Betz
Browse files

Merge remote-tracking branch 'remotes/origin/dev' into 111-update-dependencies

parents 8a94994e ffe66fd4
Pipeline #11079 passed with stage
in 1 minute and 24 seconds
......@@ -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;
......@@ -77,6 +65,17 @@ public abstract class TransportationObject extends CityObject {
return ato;
}
@Override
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;
......@@ -92,17 +91,9 @@ public abstract class TransportationObject extends CityObject {
return "TransportationObject [id=" + getGmlId() + "]";
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
TransportationObject originalTo = (TransportationObject) original;
ato = originalTo.ato;
}
@Override
public Copyable createCopyInstance() {
return null;
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.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.core.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;
......@@ -35,37 +33,42 @@ public abstract class TransportationSpace extends TransportationObject {
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 reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
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);
if (super.getGmlObject() instanceof AbstractTransportationSpace ats) {
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 {
AbstractSpace as = (AbstractSpace) super.getGmlObject();
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());
}
} else {
throw new IllegalStateException("Geometry in TransportationObject cannot be of type " + geom.getType()
+ ". Only MultiSurface allowed");
}
}
for (TrafficSpaceObject spaces : trafficSpaces) {
spaces.reCreateGeometries(factory, config);
}
for (TrafficSpaceObject spaces : auxTrafficSpaces) {
spaces.reCreateGeometries(factory, config);
}
}
private void setMultiSurfaceAccordingToLod(AbstractTransportationSpace ats, MultiSurface ms, Lod lod) {
......@@ -75,8 +78,8 @@ public abstract class TransportationSpace extends TransportationObject {
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("cannot set geometry with LOD for AuxiliaryTrafficSpace: " + lod);
default -> throw new IllegalStateException(String.format("Cannot set MultiSurface with LOD %s for " +
"[GML]AbstractTransportationSpace in TransportationSpace ", lod));
}
}
......@@ -92,69 +95,29 @@ public abstract class TransportationSpace extends TransportationObject {
as.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for AuxiliaryTrafficSpace: " + lod);
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
throw new IllegalStateException(String.format("Cannot set MultiSurface with LOD %s for [GML]AbstractSpace in TransportationSpace ", lod));
}
for (TrafficSpaceObject to : trafficSpaces) {
if (to.containsError(checkIdentifier)) {
return true;
}
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
if (to.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (TrafficSpaceObject to : trafficSpaces) {
to.clearAllContainedCheckResults();
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (TrafficSpaceObject to : trafficSpaces) {
to.collectContainedErrors(errors);
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.collectContainedErrors(errors);
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));
}
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (TrafficSpaceObject to : trafficSpaces) {
if (to.containsAnyError()) {
return true;
}
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
if (to.containsAnyError()) {
return true;
}
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));
}
return false;
}
@Override
......@@ -178,12 +141,9 @@ public abstract class TransportationSpace extends TransportationObject {
ats.setLod0MultiSurface(null);
ats.setLod2MultiSurface(null);
ats.setLod3MultiSurface(null);
for (TrafficSpaceObject to : trafficSpaces) {
to.unsetGmlGeometries();
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.unsetGmlGeometries();
}
ats.setLod1Solid(null);
ats.setLod2Solid(null);
ats.setLod3Solid(null);
}
@Override
......@@ -197,50 +157,4 @@ public abstract class TransportationSpace extends TransportationObject {
return "TransportationSpace [id=" + getGmlId() + "]";
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (TrafficSpaceObject to : trafficSpaces) {
to.prepareForChecking();
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (TrafficSpaceObject to : trafficSpaces) {
to.clearMetaInformation();
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
for (TrafficSpaceObject to : trafficSpaces) {
to.collectInstances(handler);
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.collectInstances(handler);
}
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
TransportationObject originalTo = (TransportationObject) original;
for (TrafficSpaceObject to : trafficSpaces) {
to.fillValues(originalTo, handler);
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.fillValues(originalTo, handler);
}
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.model.tunnel.TunnelInstallation;
import org.citygml4j.core.model.tunnel.TunnelInstallationProperty;
import org.citygml4j.core.util.geometry.GeometryFactory;
import java.io.Serial;
import java.util.ArrayList;
......@@ -26,13 +20,6 @@ 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);
}
}
@Override
public CityObject getTopLevelCityObject() {
......@@ -50,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);
}
......@@ -120,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.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;
......@@ -46,12 +43,12 @@ public class TunnelConstructiveElement extends CityObject {
}
@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
......@@ -72,8 +69,20 @@ 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;
}
}
}
}
}
......@@ -88,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()) {
......@@ -191,9 +156,7 @@ public class TunnelConstructiveElement extends CityObject {
gmlTunnelElement.setLod1Solid(null);
gmlTunnelElement.setLod2Solid(null);
gmlTunnelElement.setLod3Solid(null);
for (BoundarySurface bs : boundarySurfaceList) {
bs.unsetGmlGeometries();
}
}
@Override
......@@ -215,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,26 +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 CityObject getTopLevelCityObject() {
return getParent().getTopLevelCityObject();
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(parent);
return parent.getTopLevelCityObject();
}
@Override
public Copyable createCopyInstance() {
return new TunnelHollow();
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
public class TunnelPart extends AbstractTunnel {
......@@ -37,24 +34,6 @@ public class TunnelPart extends AbstractTunnel {
return "TunnelPart [id=" + getGmlId() + "]";
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
TunnelPart originalPart = (TunnelPart) original;
parent = handler.getCopyInstance(originalPart.parent);
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(parent);
}
@Override
public Copyable createCopyInstance() {
return new TunnelPart();
}
private TunnelPart() {
}
}
......@@ -21,7 +21,7 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import javafx.scene.paint.Color;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.model.vegetation.AbstractVegetationObject;
import org.citygml4j.core.model.vegetation.PlantCover;
......@@ -64,7 +64,7 @@ public class Vegetation extends CityObject {
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
......@@ -94,16 +94,13 @@ public class Vegetation extends CityObject {
private void setSolidAccordingToLod(PlantCover pc, Solid solid, Lod lod) {
switch (lod) {
case LOD1:
pc.getDeprecatedProperties().setLod1MultiSolid(new MultiSolidProperty(new MultiSolid(Collections.singletonList(new SolidProperty(solid)))));
pc.setLod1Solid(new SolidProperty(solid));
break;
case LOD2:
pc.getDeprecatedProperties().setLod2MultiSolid(new MultiSolidProperty(new MultiSolid(Collections.singletonList(new SolidProperty(solid)))));
pc.setLod2Solid(new SolidProperty(solid));
break;
case LOD3:
pc.getDeprecatedProperties().setLod3MultiSolid(new MultiSolidProperty(new MultiSolid(Collections.singletonList(new SolidProperty(solid)))));
break;
case LOD4:
pc.getDeprecatedProperties().setLod4MultiSolid(new MultiSolidProperty(new MultiSolid(Collections.singletonList(new SolidProperty(solid)))));
pc.setLod3Solid(new SolidProperty(solid));
break;
default:
throw new IllegalStateException("Cannot set Solid with lod to PlantCover:" + lod);
......@@ -113,13 +110,13 @@ public class Vegetation extends CityObject {
private void setSolidAccordingToLod(SolitaryVegetationObject svo, Solid solid, Lod lod) {
switch (lod) {
case LOD1:
svo.getDeprecatedProperties().setLod1Geometry(new SolidProperty(solid));
svo.setLod1Solid(new SolidProperty(solid));
break;
case LOD2:
svo.getDeprecatedProperties().setLod2Geometry(new SolidProperty(solid));
svo.setLod2Solid(new SolidProperty(solid));
break;
case LOD3:
svo.getDeprecatedProperties().setLod3Geometry(new SolidProperty(solid));
svo.setLod3Solid(new SolidProperty(solid));
break;
case LOD4:
svo.getDeprecatedProperties().setLod4Geometry(new SolidProperty(solid));
......@@ -131,6 +128,9 @@ public class Vegetation extends CityObject {
private void setMultiSurfaceAccordingToLod(PlantCover pc, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
pc.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD1:
pc.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
break;
......@@ -151,14 +151,17 @@ public class Vegetation extends CityObject {
private void setMultiSurfaceAccordingToLod(SolitaryVegetationObject svo, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
svo.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD1:
svo.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD2:
svo.getDeprecatedProperties().setLod2Geometry(new MultiSurfaceProperty(ms));
svo.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
svo.getDeprecatedProperties().setLod3Geometry(new MultiSurfaceProperty(ms));
svo.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
svo.getDeprecatedProperties().setLod4Geometry(new MultiSurfaceProperty(ms));
......@@ -181,8 +184,19 @@ public class Vegetation extends CityObject {
return citygmlVegetation;
}
@Override
public Color getRenderColor() {
return Color.LIGHTGREEN;
}
@Override
public void unsetGmlGeometries() {
citygmlVegetation.setLod0MultiSurface(null);
citygmlVegetation.setLod2MultiSurface(null);
citygmlVegetation.setLod3MultiSurface(null);
citygmlVegetation.setLod1Solid(null);
citygmlVegetation.setLod2Solid(null);
citygmlVegetation.setLod3Solid(null);
if (type == VegetationType.SOLITARY_VEGETATION_OBJECT) {
SolitaryVegetationObject svo = (SolitaryVegetationObject) citygmlVegetation;
svo.getDeprecatedProperties().setLod1Geometry(null);
......@@ -192,9 +206,11 @@ public class Vegetation extends CityObject {
} else {
PlantCover pc = (PlantCover) citygmlVegetation;
pc.getDeprecatedProperties().setLod1MultiSurface(null);
pc.setLod2MultiSurface(null);
pc.setLod3MultiSurface(null);
pc.getDeprecatedProperties().setLod4MultiSurface(null);
pc.getDeprecatedProperties().setLod1MultiSolid(null);
pc.getDeprecatedProperties().setLod2MultiSolid(null);
pc.getDeprecatedProperties().setLod3MultiSolid(null);
pc.getDeprecatedProperties().setLod4MultiSolid(null);
}
}
......@@ -216,8 +232,4 @@ public class Vegetation extends CityObject {
return "Vegetation [id=" + getGmlId() + "]";
}
@Override
public Copyable createCopyInstance() {
return new Vegetation(type);
}
}
......@@ -19,8 +19,6 @@
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import de.hft.stuttgart.citydoctor2.utils.SerializablePair;
import java.io.Serial;
......@@ -34,7 +32,7 @@ import java.util.Set;
*
* @author Matthias Betz
*/
public class Vertex extends Vector3d implements Copyable {
public class Vertex extends Vector3d {
@Serial
private static final long serialVersionUID = -5525361920397934892L;
......@@ -138,34 +136,4 @@ public class Vertex extends Vector3d implements Copyable {
adjacentRings = new ArrayList<>(2);
}
@Override
public void collectInstances(CopyHandler handler) {
for (SerializablePair<Geometry, HashSet<LinearRing>> pair : adjacentRings) {
handler.addInstance(pair.getValue0());
for (LinearRing lr : pair.getValue1()) {
handler.addInstance(lr);
}
}
}
@Override
public Copyable createCopyInstance() {
return new Vertex(this);
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
Vertex originalVertex = (Vertex) original;
// vertex point data already filled
for (SerializablePair<Geometry, HashSet<LinearRing>> pair : originalVertex.adjacentRings) {
Geometry geomCopy = handler.getCopyInstance(pair.getValue0());
HashSet<LinearRing> set = new HashSet<>();
for (LinearRing originalRing : pair.getValue1()) {
set.add(handler.getCopyInstance(originalRing));
}
SerializablePair<Geometry, HashSet<LinearRing>> copyPair = new SerializablePair<>(geomCopy, set);
adjacentRings.add(copyPair);
}
}
}
......@@ -21,13 +21,17 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import javafx.scene.paint.Color;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.model.waterbody.WaterBody;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import java.io.Serial;
import java.util.ArrayList;
......@@ -43,26 +47,78 @@ public class WaterObject extends CityObject {
@Serial
private static final long serialVersionUID = -3821060595086337424L;
@Serial
private static final Logger logger = LogManager.getLogger(WaterObject.class);
private WaterBody gmlWater;
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
public void rebuildGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom.getType() == GeometryType.MULTI_SURFACE) {
if (geom.getType() == GeometryType.MULTI_SURFACE || geom.getType() == GeometryType.COMPOSITE_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
if (geom.getLod() == Lod.LOD0) {
gmlWater.setLod0MultiSurface(new MultiSurfaceProperty(ms));
} else if (geom.getLod() == Lod.LOD1) {
gmlWater.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
} else {
throw new IllegalStateException(
"Cannot add MultiSurface geometry with lod to WaterBody:" + geom.getLod());
}
setMultiSurfaceAccordingToLod(gmlWater, ms, geom.getLod());
} else if (geom.getType() == GeometryType.SOLID) {
Solid solid = CityGmlUtils.createSolid(geom, factory, config);
setSolidAccordingToLod(gmlWater, solid, geom.getLod());
} else {
throw new IllegalStateException("Cannot add Solid geometry to WaterBody");
}
}
removeEmptyBoundarySurfaces();
}
private void setMultiSurfaceAccordingToLod(WaterBody wb, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
wb.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD1:
wb.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
wb.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
wb.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("Cannot set MultiSurface with lod to WaterBody:" + lod);
}
}
private void setSolidAccordingToLod(WaterBody wb, Solid solid, Lod lod) {
switch (lod) {
case LOD1:
wb.setLod1Solid(new SolidProperty(solid));
break;
case LOD2:
wb.setLod2Solid(new SolidProperty(solid));
break;
case LOD3:
wb.setLod3Solid(new SolidProperty(solid));
break;
case LOD4:
wb.getDeprecatedProperties().setLod4Solid(new SolidProperty(solid));
break;
default:
throw new IllegalStateException("Cannot set MultiSurface with lod to SolitaryVegetationObject:" + lod);
}
}
private void removeEmptyBoundarySurfaces() {
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : gmlWater.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from feature", bs.getGmlId());
gmlWater.getBoundaries().remove(bsp);
break;
}
}
}
}
}
/**
......@@ -100,10 +156,21 @@ public class WaterObject extends CityObject {
return gmlWater;
}
@Override
public Color getRenderColor() {
return Color.LIGHTSKYBLUE;
}
@Override
public void unsetGmlGeometries() {
gmlWater.setLod0MultiSurface(null);
gmlWater.getDeprecatedProperties().setLod1MultiSurface(null);
gmlWater.setLod2MultiSurface(null);
gmlWater.setLod3MultiSurface(null);
gmlWater.setLod1Solid(null);
gmlWater.setLod2Solid(null);
gmlWater.setLod3Solid(null);
gmlWater.getDeprecatedProperties().setLod4Solid(null);
}
@Override
......@@ -120,56 +187,4 @@ public class WaterObject extends CityObject {
return "WaterObject [id=" + getGmlId() + "]";
}
@Override
public WaterObject createCopyInstance() {
return new WaterObject();
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
WaterObject wo = (WaterObject) original;
WaterObject originalWaterObject = (WaterObject) original;
for (BoundarySurface originalBs : originalWaterObject.boundarySurfaceList) {
boundarySurfaceList.add(handler.getCopyInstance(originalBs));
}
gmlWater = wo.gmlWater;
}
@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 collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(boundarySurfaceList);
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearMetaInformation();
}
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (BoundarySurface bs : boundarySurfaceList) {
bs.prepareForChecking();
}
}
}
......@@ -46,6 +46,12 @@ import org.citygml4j.core.model.construction.AbstractConstruction;
import org.citygml4j.core.model.core.*;
import org.citygml4j.core.model.deprecated.transportation.TransportationComplex;
import org.citygml4j.core.model.landuse.LandUse;
import org.citygml4j.core.model.relief.AbstractReliefComponentProperty;
import org.citygml4j.core.model.relief.BreaklineRelief;
import org.citygml4j.core.model.relief.MassPointRelief;
import org.citygml4j.core.model.relief.RasterRelief;
import org.citygml4j.core.model.relief.ReliefFeature;
import org.citygml4j.core.model.relief.TINRelief;
import org.citygml4j.core.model.transportation.*;
import org.citygml4j.core.model.tunnel.Tunnel;
import org.citygml4j.core.model.tunnel.*;
......@@ -118,9 +124,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
CityFurniture cf = new CityFurniture();
cf.setGmlObject(gmlCityFurniture);
mapAbstractOccupiedSpace(gmlCityFurniture, cf);
resolveAndClearReferences();
cf.unsetGmlGeometries();
updateEdgesAndVertices(cf);
finishCityObjectConstruction(cf);
model.addCityFurniture(cf);
}
......@@ -141,9 +145,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
mapAbstractOccupiedSpace(gos, gco);
resolveAndClearReferences();
gco.unsetGmlGeometries();
updateEdgesAndVertices(gco);
finishCityObjectConstruction(gco);
model.addGenericCityObject(gco);
}
......@@ -158,6 +160,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
BuildingPart part = new BuildingPart(cdBuilding);
readAbstractBuilding(bpProp.getObject(), part);
}
finishCityObjectConstruction(cdBuilding);
model.addBuilding(cdBuilding);
}
......@@ -181,9 +184,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
wo.addBoundarySurface(bs);
}
resolveAndClearReferences();
wo.unsetGmlGeometries();
updateEdgesAndVertices(wo);
finishCityObjectConstruction(wo);
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
updateEdgesAndVertices(bs);
}
......@@ -200,6 +201,67 @@ public class Citygml3FeatureMapper extends ObjectWalker {
model.addLand(lo);
}
public void visit(ReliefFeature relief) {
ReliefObject ro = new ReliefObject(relief);
mapAbstractSpaceBoundary(relief, ro);
mapReliefFeature(relief, ro);
finishCityObjectConstruction(ro);
model.addRelief(ro);
}
public void mapReliefFeature(ReliefFeature relief, ReliefObject reliefObject) {
if (relief.isSetReliefComponents()) {
for (AbstractReliefComponentProperty arcProp : relief.getReliefComponents()) {
if (arcProp.isSetObject()) {
ObjectWalker ow = new ObjectWalker() {
@Override
public void visit(TINRelief rel) {
mapTINRelief(rel, reliefObject);
}
@Override
public void visit(MassPointRelief rel) {
//Method stub for implementation if requested
}
@Override
public void visit(BreaklineRelief rel) {
//Method stub for implementation if requested
}
@Override
public void visit(RasterRelief rel) {
//Method stub for implementation if requested
}
};
arcProp.getObject().accept(ow);
}
}
}
}
public void mapTINRelief(TINRelief relief, ReliefObject reliefObject) {
TinObject to = new TinObject(relief);
Lod reliefLod = switch (relief.getLod()) {
case 1 -> Lod.LOD1;
case 2 -> Lod.LOD2;
case 3 -> Lod.LOD3;
case 4 -> null;
default -> throw new IllegalStateException("TINRelief has unexpected LOD value: " + relief.getLod());
};
if (reliefLod == null) {
logger.warn("IllegalState: TINRelief {} has LOD value 4!", relief.getId());
return;
}
reliefObject.addComponent(to);
Citygml3GeometryMapper tinMapper = new Citygml3GeometryMapper(config, vertexMap);
relief.getTin().getObject().accept(tinMapper);
Geometry geom = new Geometry(GeometryType.MULTI_SURFACE, reliefLod);
tinMapper.getPolygons().forEach(geom::addPolygon);
to.addGeometry(geom);
}
@Override
public void visit(PlantCover plantCover) {
Vegetation veg = new Vegetation(VegetationType.PLANT_COVER);
......@@ -281,8 +343,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
mapAbstractBridge(gmlBridgePart, bPart);
bo.addBridgePart(bPart);
}
resolveAndClearReferences();
updateEdgesAndVertices(bo);
finishCityObjectConstruction(bo);
for (BridgeObject part : bo.getParts()) {
updateEdgesAndVertices(part);
}
......@@ -337,8 +398,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
for (BoundarySurface bs : bo.getBoundarySurfaces()) {
updateEdgesAndVertices(bs);
}
bo.unsetGmlGeometries();
}
private Installation mapBridgeInstallation(BridgeInstallation gmlBi) {
......@@ -351,7 +410,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, bi);
GeometryProperty<?> lod4Prop = gmlBi.getDeprecatedProperties().getLod4Geometry();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi);
bi.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) {
......@@ -392,8 +450,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
tu.addTunnelPart(tPart);
}
readAbstractTunnel(tunnel, tu);
resolveAndClearReferences();
updateEdgesAndVertices(tu);
finishCityObjectConstruction(tu);
for (TunnelPart part : tu.getTunnelParts()) {
updateEdgesAndVertices(part);
}
......@@ -424,11 +481,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
}
cdTunnel.unsetGmlGeometries();
resolveAndClearReferences();
updateEdgesAndVertices(cdTunnel);
}
private void parseTunnelBoundarySurfaces(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel) {
......@@ -503,7 +555,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, ti);
GeometryProperty<?> lod4Prop = gmlTi.getDeprecatedProperties().getLod4Geometry();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, ti);
ti.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTi.getBoundaries()) {
......@@ -575,7 +627,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
TunnelFurniture tf = new TunnelFurniture();
tf.setGmlObject(gmlTf);
mapAbstractOccupiedSpace(gmlTf, tf);
tf.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTf.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
......@@ -599,7 +651,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
org.citygml4j.core.model.tunnel.TunnelConstructiveElement gmlTe) {
TunnelConstructiveElement te = new TunnelConstructiveElement(gmlTe);
mapAbstractOccupiedSpace(gmlTe, te);
te.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTe.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
......@@ -739,7 +790,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
private void finishCityObjectConstruction(CityObject co) {
co.unsetGmlGeometries();
parseId(co.getGmlObject(), co);
co.clearGmlGeometries();
resolveAndClearReferences();
updateEdgesAndVertices(co);
}
......@@ -757,7 +809,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
if (atsp.isSetObject()) {
TrafficSpaceObject atso = new TrafficSpaceObject(TrafficSpaceObject.TrafficSpaceType.AUXILIARY_TRAFFIC_SPACE);
mapAuxiliaryTrafficSpace(atsp.getObject(), atso);
trsp.addTrafficSpace(atso);
trsp.addAuxTrafficSpace(atso);
}
}
}
......@@ -974,7 +1026,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
AbstractBuilding cdBuilding) {
mapAbstractOccupiedSpace(gmlAb, cdBuilding);
cdBuilding.setGmlObject(gmlAb);
// parse deprecated geometries
parseAndAddMultiSurface(gmlAb.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, cdBuilding);
parseAndAddMultiSurface(gmlAb.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, cdBuilding);
......@@ -1009,9 +1060,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
updatePartOfSurface(cdBuilding, surfaceMapper);
cdBuilding.unsetGmlGeometries();
resolveAndClearReferences();
updateEdgesAndVertices(cdBuilding);
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
updateEdgesAndVertices(bs);
for (Opening o : bs.getOpenings()) {
......@@ -1114,7 +1162,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
BuildingRoomFurniture bf = new BuildingRoomFurniture();
bf.setGmlObject(gmlAF);
mapAbstractOccupiedSpace(gmlAF, bf);
bf.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlAF.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
......@@ -1139,7 +1186,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
de.hft.stuttgart.citydoctor2.datastructure.Storey storey = new de.hft.stuttgart.citydoctor2.datastructure.Storey();
storey.setGmlObject(gmlStorey);
mapAbstractSpace(gmlStorey, storey);
storey.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlStorey.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
......@@ -1163,7 +1209,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit bu = new de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit();
bu.setGmlObject(gmlBU);
mapAbstractSpace(gmlBU, bu);
bu.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBU.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
......@@ -1204,7 +1249,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, bi);
GeometryProperty<?> lod4Prop = gmlBi.getDeprecatedProperties().getLod4Geometry();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi);
bi.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) {
......
......@@ -35,6 +35,7 @@ import org.xmlobjects.gml.visitor.GeometryWalker;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
......@@ -76,6 +77,11 @@ public class Citygml3GeometryMapper extends GeometryWalker {
public void visit(PolygonPatch patch) {
parsePolygonPatch(patch, patchCollection);
}
@Override
public void visit(Triangle tri) {
parsePolygon(null, tri.getExterior(), Collections.emptyList());
}
};
surface.getPatches().getObjects().forEach(abstractSurfacePatch -> abstractSurfacePatch.accept(patchCollector));
}
......
package de.hft.stuttgart.citydoctor2.utils;
/**
* This Throwable signals that a requested CheckError was found.
*/
public class CheckErrorFound extends Throwable {
public CheckErrorFound() {
super("CheckError was found", null, true, false);
}
}
......@@ -27,6 +27,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class Copy {
......@@ -36,7 +37,7 @@ public class Copy {
}
@SuppressWarnings("unchecked")
public static <T extends Copyable> T copy(T original) {
public static <T extends Serializable> T copy(T original) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
ObjectOutputStream oos = new ObjectOutputStream(out);
......
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2.utils;
import java.util.Collection;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
public class CopyHandler {
private final Set<Copyable> toBeDoneInstances = new HashSet<>();
private final Map<Copyable, Copyable> finishedInstances = new IdentityHashMap<>();
@SuppressWarnings("unchecked")
public <T extends Copyable> T copy(T original) {
toBeDoneInstances.add(original);
while (!toBeDoneInstances.isEmpty()) {
handleNextInstance();
}
for (Entry<Copyable, Copyable> e : finishedInstances.entrySet()) {
e.getValue().fillValues(e.getKey(), this);
}
return (T) finishedInstances.get(original);
}
@SuppressWarnings("unchecked")
public <T extends Copyable> T getCopyInstance(T original) {
if (original == null) {
// null gets copied to null
return null;
}
return (T) finishedInstances.get(original);
}
public void addInstance(Copyable copyable) {
if (copyable == null) {
// don't care for null instances
return;
}
if (finishedInstances.containsKey(copyable)) {
// already processed
return;
}
toBeDoneInstances.add(copyable);
}
private void handleNextInstance() {
Iterator<Copyable> iterator = toBeDoneInstances.iterator();
Copyable next = iterator.next();
iterator.remove();
finishedInstances.put(next, next.createCopyInstance());
next.collectInstances(this);
}
public void addInstance(Collection<? extends Copyable> collection) {
if (collection == null) {
return;
}
for (Copyable c : collection) {
addInstance(c);
}
}
}
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2.utils;
public interface Copyable {
public void collectInstances(CopyHandler handler);
public Copyable createCopyInstance();
public void fillValues(Copyable original, CopyHandler handler);
}
package de.hft.stuttgart.citydoctor2.utils;
public class ThrowUtils {
private ThrowUtils() {
}
@SuppressWarnings("unchecked")
private static <T extends Throwable> void uncheckThrowable(Throwable t) throws T {
throw (T) t;
}
/**
* Throws a Throwable as an unchecked generic Throwable
*/
public static void sneakyThrow(Throwable t) {
uncheckThrowable(t);
}
}
package de.hft.stuttgart.citydoctor2.utils.visitors;
import de.hft.stuttgart.citydoctor2.check.AbstractCheck;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.Checkable;
import java.util.List;
/**
* This Visitor collects all CheckErrors in the datastructure of a checkable.
*/
public class CheckableErrorCollector extends AbstractCheck {
List<CheckError> errors;
/**
* Collects all CheckErrors into a list
*
* @param errors the list
*/
public CheckableErrorCollector(List<CheckError> errors) {
this.errors = errors;
}
@Override
public void check(Checkable checkable) {
checkable.collectErrors(errors);
}
}
package de.hft.stuttgart.citydoctor2.utils.visitors;
import de.hft.stuttgart.citydoctor2.check.AbstractCheck;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import java.util.HashSet;
import java.util.Set;
/**
* This Visitor collects all sub-CityObjects that are in the datastructure of a CityObject (including itself) in a Set.
*/
public class CityObjectCollector extends AbstractCheck {
private final Set<CityObject> objects = new HashSet<>();
/**
* Returns the collected CityObjects.
*
* @return A set of CityObjects
*/
public Set<CityObject> getCityObjects() {
return objects;
}
@Override
public void check(CityObject co) {
objects.add(co);
}
}
package de.hft.stuttgart.citydoctor2.utils.visitors;
import de.hft.stuttgart.citydoctor2.check.AbstractCheck;
import de.hft.stuttgart.citydoctor2.check.Checkable;
/**
* This Visitor removes the check results from a CityObject and the objects in its datastructure.
*/
public class ClearCheckResultsVisitor extends AbstractCheck {
@Override
public void check(Checkable checkable) {
checkable.clearCheckResults();
}
}
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