Commit 3f3c1884 authored by Matthias Betz's avatar Matthias Betz
Browse files

change to citygml4j 3.0.0 rc4

change to quality ade 0.1.4
parent 92f3e523
Pipeline #6596 failed with stage
in 17 seconds
......@@ -20,7 +20,6 @@ package de.hft.stuttgart.citydoctor2.check.error;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import de.hft.stuttgart.citydoctor2.check.CheckError;
......@@ -34,9 +33,6 @@ import de.hft.stuttgart.citydoctor2.datastructure.Edge;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GmlElement;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.utils.QualityADEUtils;
import de.hft.stuttgart.quality.model.PolygonWrongOrientation;
import de.hft.stuttgart.quality.model.ValidationError;
/**
* If a polygon is wrongly oriented it results in edges being traversed in the
......@@ -105,14 +101,4 @@ public class PolygonWrongOrientationError implements CheckError {
public GmlElement getFeature() {
return getGeometry();
}
@Override
public Optional<ValidationError> convertToQualityAdeDatastructure() {
PolygonWrongOrientation err = new PolygonWrongOrientation();
err.setGeometryId(g.getGmlId().getGmlString());
for (Edge e : edges) {
err.getEdges().add(QualityADEUtils.convertEdge(e));
}
return Optional.of(err);
}
}
......@@ -18,8 +18,6 @@
*/
package de.hft.stuttgart.citydoctor2.check.error;
import java.util.Optional;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.ErrorId;
import de.hft.stuttgart.citydoctor2.check.ErrorReport;
......@@ -30,10 +28,6 @@ import de.hft.stuttgart.citydoctor2.check.ModificationListener;
import de.hft.stuttgart.citydoctor2.datastructure.GmlElement;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.utils.QualityADEUtils;
import de.hft.stuttgart.quality.model.RingSelfIntersection;
import de.hft.stuttgart.quality.model.ValidationError;
import de.hft.stuttgart.quality.model.jaxb.RingSelfIntType;
/**
* When a point is repeated in a linear ring, but is not consecutive. This
......@@ -104,15 +98,4 @@ public class RingDuplicatePointError implements CheckError {
public GmlElement getFeature() {
return getRing();
}
@Override
public Optional<ValidationError> convertToQualityAdeDatastructure() {
RingSelfIntersection err = new RingSelfIntersection();
err.setType(RingSelfIntType.DUPLICATE_POINT);
err.setVertex1(QualityADEUtils.convertVertex(v1));
err.setVertex2(QualityADEUtils.convertVertex(v2));
err.setLinearRingId(r.getGmlId().getGmlString());
return Optional.of(err);
}
}
......@@ -18,8 +18,6 @@
*/
package de.hft.stuttgart.citydoctor2.check.error;
import java.util.Optional;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.ErrorId;
import de.hft.stuttgart.citydoctor2.check.ErrorReport;
......@@ -31,10 +29,6 @@ import de.hft.stuttgart.citydoctor2.datastructure.Edge;
import de.hft.stuttgart.citydoctor2.datastructure.GmlElement;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.utils.QualityADEUtils;
import de.hft.stuttgart.quality.model.RingSelfIntersection;
import de.hft.stuttgart.quality.model.ValidationError;
import de.hft.stuttgart.quality.model.jaxb.RingSelfIntType;
/**
* When two edges of the same linear ring are intersecting with each other this
......@@ -116,16 +110,4 @@ public class RingEdgeIntersectionError implements CheckError {
public GmlElement getFeature() {
return getRing();
}
@Override
public Optional<ValidationError> convertToQualityAdeDatastructure() {
RingSelfIntersection err = new RingSelfIntersection();
err.setLinearRingId(lr.getGmlId().getGmlString());
err.setEdge1(QualityADEUtils.convertEdge(e1));
err.setEdge2(QualityADEUtils.convertEdge(e2));
err.setVertex1(QualityADEUtils.convertVertex(intersection));
err.setType(RingSelfIntType.EDGE_INTERSECTS_EDGE);
return Optional.of(err);
}
}
......@@ -18,8 +18,6 @@
*/
package de.hft.stuttgart.citydoctor2.check.error;
import java.util.Optional;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.ErrorId;
import de.hft.stuttgart.citydoctor2.check.ErrorReport;
......@@ -29,8 +27,6 @@ import de.hft.stuttgart.citydoctor2.check.HealingMethod;
import de.hft.stuttgart.citydoctor2.check.ModificationListener;
import de.hft.stuttgart.citydoctor2.datastructure.GmlElement;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.quality.model.RingNotClosed;
import de.hft.stuttgart.quality.model.ValidationError;
/**
* If the first and last point of a linear ring are not the same, this error is
......@@ -87,11 +83,4 @@ public class RingNotClosedError implements CheckError {
public GmlElement getFeature() {
return getRing();
}
@Override
public Optional<ValidationError> convertToQualityAdeDatastructure() {
RingNotClosed err = new RingNotClosed();
err.setLinearRingId(ring.getGmlId().getGmlString());
return Optional.of(err);
}
}
......@@ -18,8 +18,6 @@
*/
package de.hft.stuttgart.citydoctor2.check.error;
import java.util.Optional;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.ErrorId;
import de.hft.stuttgart.citydoctor2.check.ErrorReport;
......@@ -29,8 +27,6 @@ import de.hft.stuttgart.citydoctor2.check.HealingMethod;
import de.hft.stuttgart.citydoctor2.check.ModificationListener;
import de.hft.stuttgart.citydoctor2.datastructure.GmlElement;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.quality.model.TooFewPoints;
import de.hft.stuttgart.quality.model.ValidationError;
/**
* If a linear ring has less than 4 distinct points, it is has too few points.
......@@ -86,11 +82,4 @@ public class RingTooFewPointsError implements CheckError {
public GmlElement getFeature() {
return getRing();
}
@Override
public Optional<ValidationError> convertToQualityAdeDatastructure() {
TooFewPoints err = new TooFewPoints();
err.setLinearRingId(lr.getGmlId().getGmlString());
return Optional.of(err);
}
}
......@@ -19,7 +19,6 @@
package de.hft.stuttgart.citydoctor2.check.error;
import java.util.List;
import java.util.Optional;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.ErrorId;
......@@ -31,9 +30,6 @@ import de.hft.stuttgart.citydoctor2.check.ModificationListener;
import de.hft.stuttgart.citydoctor2.datastructure.Edge;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GmlElement;
import de.hft.stuttgart.citydoctor2.utils.QualityADEUtils;
import de.hft.stuttgart.quality.model.SolidNotClosed;
import de.hft.stuttgart.quality.model.ValidationError;
/**
* If a geometry has holes in it, it results in edges being traversed only once.
......@@ -97,14 +93,4 @@ public class SolidNotClosedError implements CheckError {
public GmlElement getFeature() {
return getGeometry();
}
@Override
public Optional<ValidationError> convertToQualityAdeDatastructure() {
SolidNotClosed err = new SolidNotClosed();
err.setGeometryId(g.getGmlId().getGmlString());
for (Edge e : errorEdges) {
err.getEdges().add(QualityADEUtils.convertEdge(e));
}
return Optional.of(err);
}
}
......@@ -19,7 +19,6 @@
package de.hft.stuttgart.citydoctor2.check.error;
import java.util.List;
import java.util.Optional;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.ErrorId;
......@@ -31,8 +30,6 @@ import de.hft.stuttgart.citydoctor2.check.ModificationListener;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GmlElement;
import de.hft.stuttgart.citydoctor2.utils.PolygonIntersection;
import de.hft.stuttgart.quality.model.SolidSelfIntersection;
import de.hft.stuttgart.quality.model.ValidationError;
/**
* When two polygons of the same geometry are intersecting each other.
......@@ -95,14 +92,4 @@ public class SolidSelfIntError implements CheckError {
public GmlElement getFeature() {
return getGeometry();
}
@Override
public Optional<ValidationError> convertToQualityAdeDatastructure() {
SolidSelfIntersection err = new SolidSelfIntersection();
err.setGeometryId(g.getGmlId().getGmlString());
PolygonIntersection polygonIntersection = intersections.get(0);
err.setPolygonId1(polygonIntersection.getP1().getGmlId().getGmlString());
err.setPolygonId2(polygonIntersection.getP2().getGmlId().getGmlString());
return Optional.of(err);
}
}
......@@ -18,8 +18,6 @@
*/
package de.hft.stuttgart.citydoctor2.check.error;
import java.util.Optional;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.ErrorId;
import de.hft.stuttgart.citydoctor2.check.ErrorReport;
......@@ -29,8 +27,6 @@ import de.hft.stuttgart.citydoctor2.check.HealingMethod;
import de.hft.stuttgart.citydoctor2.check.ModificationListener;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GmlElement;
import de.hft.stuttgart.quality.model.TooFewPolygons;
import de.hft.stuttgart.quality.model.ValidationError;
/**
* When a geometry has less than 4 polygons, it cannot form a valid solid.
......@@ -87,11 +83,4 @@ public class TooFewPolygonsError implements CheckError {
public GmlElement getFeature() {
return getGeometry();
}
@Override
public Optional<ValidationError> convertToQualityAdeDatastructure() {
TooFewPolygons err = new TooFewPolygons();
err.setGeometryId(g.getGmlId().getGmlString());
return Optional.of(err);
}
}
......@@ -23,12 +23,12 @@ import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.building.BoundarySurfaceProperty;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurface;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty;
import org.citygml4j.model.gml.geometry.primitives.Solid;
import org.citygml4j.model.gml.geometry.primitives.SolidProperty;
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 de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
......@@ -54,7 +54,7 @@ public abstract class AbstractBuilding extends CityObject {
private List<BuildingInstallation> buildingInstallations = new ArrayList<>(2);
private List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
private org.citygml4j.model.citygml.building.AbstractBuilding ab;
private org.citygml4j.core.model.building.AbstractBuilding ab;
/**
* Getter for all boundary surfaces contained in this building.
......@@ -66,7 +66,7 @@ public abstract class AbstractBuilding extends CityObject {
}
@Override
public org.citygml4j.model.citygml.building.AbstractBuilding getGmlObject() {
public org.citygml4j.core.model.building.AbstractBuilding getGmlObject() {
return ab;
}
......@@ -77,14 +77,15 @@ public abstract class AbstractBuilding extends CityObject {
@Override
public void unsetGmlGeometries() {
ab.unsetLod1MultiSurface();
ab.unsetLod2MultiSurface();
ab.unsetLod3MultiSurface();
ab.unsetLod4MultiSurface();
ab.unsetLod1Solid();
ab.unsetLod2Solid();
ab.unsetLod3Solid();
ab.unsetLod4Solid();
ab.setLod1Solid(null);
ab.setLod2Solid(null);
ab.setLod3Solid(null);
ab.setLod2MultiSurface(null);
ab.setLod3MultiSurface(null);
ab.getDeprecatedProperties().setLod1MultiSurface(null);
ab.getDeprecatedProperties().setLod4MultiSurface(null);
ab.getDeprecatedProperties().setLod4Solid(null);
for (BoundarySurface bs : boundarySurfaceList) {
bs.unsetGmlGeometries();
}
......@@ -94,7 +95,7 @@ public abstract class AbstractBuilding extends CityObject {
}
@Override
public void reCreateGeometries(GMLGeometryFactory factory, ParserConfiguration config) {
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
......@@ -112,12 +113,12 @@ public abstract class AbstractBuilding extends CityObject {
}
}
private void reCreateBoundarySurface(GMLGeometryFactory factory, ParserConfiguration config, BoundarySurface bs) {
private void reCreateBoundarySurface(GeometryFactory factory, ParserConfiguration config, BoundarySurface bs) {
if (bs.getGeometries().isEmpty()) {
for (BoundarySurfaceProperty bsp : ab.getBoundedBySurface()) {
if (bsp.getBoundarySurface() != null && bsp.getBoundarySurface() == bs.getGmlObject()) {
for (AbstractSpaceBoundaryProperty bsp : ab.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from building", bs.getGmlId());
ab.getBoundedBySurface().remove(bsp);
ab.getBoundaries().remove(bsp);
break;
}
}
......@@ -128,8 +129,11 @@ public abstract class AbstractBuilding extends CityObject {
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) {
case LOD0:
ab.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD1:
ab.setLod1MultiSurface(new MultiSurfaceProperty(ms));
ab.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
ab.setLod2MultiSurface(new MultiSurfaceProperty(ms));
......@@ -138,7 +142,7 @@ public abstract class AbstractBuilding extends CityObject {
ab.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
ab.setLod4MultiSurface(new MultiSurfaceProperty(ms));
ab.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to buildings");
......@@ -157,7 +161,7 @@ public abstract class AbstractBuilding extends CityObject {
ab.setLod3Solid(new SolidProperty(solid));
break;
case LOD4:
ab.setLod4Solid(new SolidProperty(solid));
ab.getDeprecatedProperties().setLod4Solid(new SolidProperty(solid));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to buildings");
......@@ -238,7 +242,7 @@ public abstract class AbstractBuilding extends CityObject {
return false;
}
void setCityGmlBuilding(org.citygml4j.model.citygml.building.AbstractBuilding ab) {
void setCityGmlBuilding(org.citygml4j.core.model.building.AbstractBuilding ab) {
this.ab = ab;
}
......@@ -252,7 +256,7 @@ public abstract class AbstractBuilding extends CityObject {
coBi.setParent(this);
}
public void setGmlObject(org.citygml4j.model.citygml.building.AbstractBuilding ab) {
public void setGmlObject(org.citygml4j.core.model.building.AbstractBuilding ab) {
this.ab = ab;
}
......
......@@ -21,10 +21,10 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import java.util.ArrayList;
import java.util.List;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.core.AbstractCityObject;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurface;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty;
import org.citygml4j.core.model.core.AbstractThematicSurface;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
......@@ -50,13 +50,13 @@ public class BoundarySurface extends CityObject {
private List<Opening> openings = new ArrayList<>(2);
private CityObject parent;
private AbstractCityObject gmlObject;
private AbstractThematicSurface gmlObject;
public BoundarySurface(AbstractCityObject aco) {
public BoundarySurface(AbstractThematicSurface aco) {
this(SurfaceFeatureType.BUILDING, BoundarySurfaceType.UNDEFINED, aco);
}
public BoundarySurface(SurfaceFeatureType featureType, BoundarySurfaceType type, AbstractCityObject aco) {
public BoundarySurface(SurfaceFeatureType featureType, BoundarySurfaceType type, AbstractThematicSurface aco) {
this.featureType = featureType;
this.type = type;
gmlObject = aco;
......@@ -70,7 +70,7 @@ public class BoundarySurface extends CityObject {
this.type = type;
}
public void setGmlObject(AbstractCityObject gmlObject) {
public void setGmlObject(AbstractThematicSurface gmlObject) {
this.gmlObject = gmlObject;
}
......@@ -87,8 +87,8 @@ public class BoundarySurface extends CityObject {
}
@Override
public void reCreateGeometries(GMLGeometryFactory factory, ParserConfiguration config) {
if (!gmlObject.isSetId()) {
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
if (gmlObject.getId() == null) {
gmlObject.setId(getGmlId().getGmlString());
}
for (Geometry geom : getGeometries()) {
......@@ -108,69 +108,26 @@ public class BoundarySurface extends CityObject {
private void setGeometryAccordingToLod(Lod lod, MultiSurfaceProperty ms) {
switch (lod) {
case LOD0:
gmlObject.setLod0MultiSurface(ms);
break;
case LOD1:
gmlObject.setLod1MultiSurface(ms);
break;
case LOD2:
setLod2Ms(ms);
gmlObject.setLod2MultiSurface(ms);
break;
case LOD3:
setLod3Ms(ms);
gmlObject.setLod3MultiSurface(ms);
break;
case LOD4:
setLod4Ms(ms);
gmlObject.getDeprecatedProperties().setLod4MultiSurface(ms);
break;
default:
throw new IllegalStateException("Found geometry with LOD other than LOD2,"
+ " LOD3, LOD4, which is illegal for BoundarySurfaces: " + lod);
}
}
private void setLod2Ms(MultiSurfaceProperty ms) {
switch (featureType) {
case BRIDGE:
org.citygml4j.model.citygml.bridge.AbstractBoundarySurface bridgeAbs = (org.citygml4j.model.citygml.bridge.AbstractBoundarySurface) gmlObject;
bridgeAbs.setLod2MultiSurface(ms);
break;
case BUILDING:
org.citygml4j.model.citygml.building.AbstractBoundarySurface buildAbs = (org.citygml4j.model.citygml.building.AbstractBoundarySurface) gmlObject;
buildAbs.setLod2MultiSurface(ms);
break;
case TUNNEL:
org.citygml4j.model.citygml.tunnel.AbstractBoundarySurface tunAbs = (org.citygml4j.model.citygml.tunnel.AbstractBoundarySurface) gmlObject;
tunAbs.setLod2MultiSurface(ms);
}
}
private void setLod3Ms(MultiSurfaceProperty ms) {
switch (featureType) {
case BRIDGE:
org.citygml4j.model.citygml.bridge.AbstractBoundarySurface bridgeAbs = (org.citygml4j.model.citygml.bridge.AbstractBoundarySurface) gmlObject;
bridgeAbs.setLod3MultiSurface(ms);
break;
case BUILDING:
org.citygml4j.model.citygml.building.AbstractBoundarySurface buildAbs = (org.citygml4j.model.citygml.building.AbstractBoundarySurface) gmlObject;
buildAbs.setLod3MultiSurface(ms);
break;
case TUNNEL:
org.citygml4j.model.citygml.tunnel.AbstractBoundarySurface tunAbs = (org.citygml4j.model.citygml.tunnel.AbstractBoundarySurface) gmlObject;
tunAbs.setLod3MultiSurface(ms);
throw new IllegalStateException("Found geometry with LOD other than LOD1-4, which is illegal for BoundarySurfaces: " + lod);
}
}
private void setLod4Ms(MultiSurfaceProperty ms) {
switch (featureType) {
case BRIDGE:
org.citygml4j.model.citygml.bridge.AbstractBoundarySurface bridgeAbs = (org.citygml4j.model.citygml.bridge.AbstractBoundarySurface) gmlObject;
bridgeAbs.setLod4MultiSurface(ms);
break;
case BUILDING:
org.citygml4j.model.citygml.building.AbstractBoundarySurface buildAbs = (org.citygml4j.model.citygml.building.AbstractBoundarySurface) gmlObject;
buildAbs.setLod4MultiSurface(ms);
break;
case TUNNEL:
org.citygml4j.model.citygml.tunnel.AbstractBoundarySurface tunAbs = (org.citygml4j.model.citygml.tunnel.AbstractBoundarySurface) gmlObject;
tunAbs.setLod4MultiSurface(ms);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
......@@ -234,26 +191,14 @@ public class BoundarySurface extends CityObject {
return parent;
}
@Override
public void unsetGmlGeometries() {
switch (featureType) {
case BRIDGE:
org.citygml4j.model.citygml.bridge.AbstractBoundarySurface bridgeAbs = (org.citygml4j.model.citygml.bridge.AbstractBoundarySurface) gmlObject;
bridgeAbs.unsetLod2MultiSurface();
bridgeAbs.unsetLod3MultiSurface();
bridgeAbs.unsetLod4MultiSurface();
break;
case BUILDING:
org.citygml4j.model.citygml.building.AbstractBoundarySurface buildAbs = (org.citygml4j.model.citygml.building.AbstractBoundarySurface) gmlObject;
buildAbs.unsetLod2MultiSurface();
buildAbs.unsetLod3MultiSurface();
buildAbs.unsetLod4MultiSurface();
break;
case TUNNEL:
org.citygml4j.model.citygml.tunnel.AbstractBoundarySurface tunAbs = (org.citygml4j.model.citygml.tunnel.AbstractBoundarySurface) gmlObject;
tunAbs.unsetLod2MultiSurface();
tunAbs.unsetLod3MultiSurface();
tunAbs.unsetLod4MultiSurface();
}
gmlObject.setLod0MultiSurface(null);
gmlObject.setLod1MultiSurface(null);
gmlObject.setLod2MultiSurface(null);
gmlObject.setLod3MultiSurface(null);
gmlObject.getDeprecatedProperties().setLod4MultiSurface(null);
for (Opening o : openings) {
o.unsetGmlGeometries();
}
......@@ -265,21 +210,20 @@ public class BoundarySurface extends CityObject {
}
void anonymize() {
gmlObject.unsetAppearance();
gmlObject.unsetBoundedBy();
gmlObject.unsetCreationDate();
gmlObject.unsetDescription();
gmlObject.unsetExternalReference();
gmlObject.unsetGeneralizesTo();
gmlObject.unsetGenericADEElement();
gmlObject.unsetGenericApplicationPropertyOfCityObject();
gmlObject.unsetGenericAttribute();
gmlObject.setAppearances(null);
gmlObject.setBoundedBy(null);
gmlObject.setCreationDate(null);
gmlObject.setDescription(null);
gmlObject.setExternalReferences(null);
gmlObject.setGeneralizesTo(null);
gmlObject.setADEProperties(null);
gmlObject.setGenericAttributes(null);
setGmlId(GmlId.generateId());
gmlObject.setId(getGmlId().getGmlString());
}
@Override
public AbstractCityObject getGmlObject() {
public AbstractThematicSurface getGmlObject() {
return gmlObject;
}
......
......@@ -21,12 +21,12 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import java.util.ArrayList;
import java.util.List;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.bridge.AbstractBridge;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurface;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty;
import org.citygml4j.model.gml.geometry.primitives.Solid;
import org.citygml4j.model.gml.geometry.primitives.SolidProperty;
import org.citygml4j.core.model.bridge.AbstractBridge;
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 de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
......@@ -52,6 +52,8 @@ public class BridgeObject extends CityObject {
private AbstractBridge ab;
private BridgeType type;
private List<BridgeObject> parts = null;
private List<BoundarySurface> boundarySurfaces = new ArrayList<>();
......@@ -66,7 +68,7 @@ public class BridgeObject extends CityObject {
}
@Override
public void reCreateGeometries(GMLGeometryFactory factory, ParserConfiguration config) {
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
......@@ -84,7 +86,7 @@ public class BridgeObject extends CityObject {
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) {
case LOD1:
ab.setLod1MultiSurface(new MultiSurfaceProperty(ms));
ab.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
ab.setLod2MultiSurface(new MultiSurfaceProperty(ms));
......@@ -93,7 +95,7 @@ public class BridgeObject extends CityObject {
ab.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
ab.setLod4MultiSurface(new MultiSurfaceProperty(ms));
ab.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to bridges");
......@@ -112,7 +114,7 @@ public class BridgeObject extends CityObject {
ab.setLod3Solid(new SolidProperty(solid));
break;
case LOD4:
ab.setLod4Solid(new SolidProperty(solid));
ab.getDeprecatedProperties().setLod4Solid(new SolidProperty(solid));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to bridges");
......@@ -204,14 +206,14 @@ public class BridgeObject extends CityObject {
@Override
public void unsetGmlGeometries() {
ab.unsetLod1MultiSurface();
ab.unsetLod2MultiSurface();
ab.unsetLod3MultiSurface();
ab.unsetLod4MultiSurface();
ab.unsetLod1Solid();
ab.unsetLod2Solid();
ab.unsetLod3Solid();
ab.unsetLod4Solid();
ab.setLod1Solid(null);
ab.setLod2Solid(null);
ab.setLod3Solid(null);
ab.setLod2MultiSurface(null);
ab.setLod3MultiSurface(null);
ab.getDeprecatedProperties().setLod1MultiSurface(null);
ab.getDeprecatedProperties().setLod4MultiSurface(null);
ab.getDeprecatedProperties().setLod4Solid(null);
for (BoundarySurface bs : boundarySurfaces) {
bs.unsetGmlGeometries();
}
......@@ -263,5 +265,19 @@ public class BridgeObject extends CityObject {
public Copyable createCopyInstance() {
return new BridgeObject(type, ab);
}
public List<BridgeObject> getParts() {
if (parts == null) {
parts = new ArrayList<>(2);
}
return parts;
}
public void addBridgePart(BridgeObject bPart) {
if (parts == null) {
parts = new ArrayList<>(2);
}
parts.add(bPart);
}
}
......@@ -21,10 +21,9 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import java.util.ArrayList;
import java.util.List;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.building.AbstractBoundarySurface;
import org.citygml4j.model.citygml.building.BoundarySurfaceProperty;
import org.citygml4j.model.citygml.building.BuildingInstallationProperty;
import org.citygml4j.core.model.building.BuildingInstallationProperty;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.util.geometry.GeometryFactory;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
......@@ -44,7 +43,7 @@ public class Building extends AbstractBuilding {
}
@Override
public void reCreateGeometries(GMLGeometryFactory factory, ParserConfiguration config) {
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config);
for (BuildingPart bp : buildingParts) {
bp.reCreateGeometries(factory, config);
......@@ -119,15 +118,15 @@ public class Building extends AbstractBuilding {
for (Geometry geom : getGeometries()) {
geom.anonymize();
}
org.citygml4j.model.citygml.building.Building gmlB = new org.citygml4j.model.citygml.building.Building();
org.citygml4j.core.model.building.Building gmlB = new org.citygml4j.core.model.building.Building();
gmlB.setId(GmlId.generateId().getGmlString());
for (BuildingInstallation bi : getBuildingInstallations()) {
bi.anonymize();
gmlB.addOuterBuildingInstallation(new BuildingInstallationProperty(bi.getGmlObject()));
gmlB.getBuildingInstallations().add(new BuildingInstallationProperty(bi.getGmlObject()));
}
for (BoundarySurface bs : getBoundarySurfaces()) {
bs.anonymize();
gmlB.addBoundedBySurface(new BoundarySurfaceProperty((AbstractBoundarySurface) bs.getGmlObject()));
gmlB.addBoundary(new AbstractSpaceBoundaryProperty(bs.getGmlObject()));
}
setCityGmlBuilding(gmlB);
}
......
......@@ -21,14 +21,13 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import java.util.ArrayList;
import java.util.List;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.building.AbstractBoundarySurface;
import org.citygml4j.model.citygml.building.BoundarySurfaceProperty;
import org.citygml4j.model.gml.geometry.GeometryProperty;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurface;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty;
import org.citygml4j.model.gml.geometry.complexes.CompositeSurface;
import org.citygml4j.model.gml.geometry.complexes.CompositeSurfaceProperty;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.GeometryProperty;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.complexes.CompositeSurface;
import org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
......@@ -44,11 +43,11 @@ public class BuildingInstallation extends CityObject {
private List<BoundarySurface> boundarySurfaces = new ArrayList<>(4);
private org.citygml4j.model.citygml.building.BuildingInstallation gmlBi;
private org.citygml4j.core.model.building.BuildingInstallation gmlBi;
private AbstractBuilding parent;
public void reCreateGeometries(GMLGeometryFactory factory, ParserConfiguration config) {
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
......@@ -58,7 +57,7 @@ public class BuildingInstallation extends CityObject {
} else if (geom.getType() == GeometryType.COMPOSITE_SURFACE) {
CompositeSurface cs = CityGmlUtils.createCompositeSurface(geom, factory, config);
if (cs != null) {
setGeometryAccordingToLod(geom.getLod(), new CompositeSurfaceProperty(cs));
setGeometryAccordingToLod(geom.getLod(), new SurfaceProperty(cs));
}
} else {
throw new IllegalStateException("BuildingInstallation not have Solid geometries");
......@@ -70,15 +69,16 @@ public class BuildingInstallation extends CityObject {
}
private void setGeometryAccordingToLod(Lod lod, GeometryProperty<?> ms) {
switch (lod) {
case LOD2:
gmlBi.setLod2Geometry(ms);
gmlBi.getDeprecatedProperties().setLod2Geometry(ms);
break;
case LOD3:
gmlBi.setLod3Geometry(ms);
gmlBi.getDeprecatedProperties().setLod3Geometry(ms);
break;
case LOD4:
gmlBi.setLod4Geometry(ms);
gmlBi.getDeprecatedProperties().setLod4Geometry(ms);
break;
default:
throw new IllegalStateException("Found geometry with LOD other than LOD2,"
......@@ -155,15 +155,15 @@ public class BuildingInstallation extends CityObject {
}
public void unsetGmlGeometries() {
gmlBi.unsetLod2Geometry();
gmlBi.unsetLod3Geometry();
gmlBi.unsetLod4Geometry();
gmlBi.getDeprecatedProperties().setLod2Geometry(null);
gmlBi.getDeprecatedProperties().setLod3Geometry(null);
gmlBi.getDeprecatedProperties().setLod4Geometry(null);
for (BoundarySurface bs : boundarySurfaces) {
bs.unsetGmlGeometries();
}
}
public void setGmlObject(org.citygml4j.model.citygml.building.BuildingInstallation gmlBi) {
public void setGmlObject(org.citygml4j.core.model.building.BuildingInstallation gmlBi) {
this.gmlBi = gmlBi;
}
......@@ -174,17 +174,17 @@ public class BuildingInstallation extends CityObject {
void anonymize() {
setGmlId(GmlId.generateId());
gmlBi = new org.citygml4j.model.citygml.building.BuildingInstallation();
gmlBi = new org.citygml4j.core.model.building.BuildingInstallation();
gmlBi.setId(getGmlId().getGmlString());
for (BoundarySurface bs : boundarySurfaces) {
bs.anonymize();
gmlBi.addBoundedBySurface(new BoundarySurfaceProperty((AbstractBoundarySurface) bs.getGmlObject()));
gmlBi.getBoundaries().add(new AbstractSpaceBoundaryProperty(bs.getGmlObject()));
}
}
@Override
public org.citygml4j.model.citygml.building.BuildingInstallation getGmlObject() {
public org.citygml4j.core.model.building.BuildingInstallation getGmlObject() {
return gmlBi;
}
......
......@@ -23,46 +23,25 @@ import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
import org.citygml4j.CityGMLContext;
import org.citygml4j.builder.jaxb.CityGMLBuilder;
import org.citygml4j.builder.jaxb.CityGMLBuilderException;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.ade.ADEException;
import org.citygml4j.model.citygml.ade.binding.ADEContext;
import org.citygml4j.model.citygml.core.CityModel;
import org.citygml4j.model.citygml.core.CityObjectMember;
import org.citygml4j.model.module.citygml.CityGMLVersion;
import org.citygml4j.xml.io.CityGMLOutputFactory;
import org.citygml4j.xml.io.writer.CityGMLWriteException;
import org.citygml4j.xml.io.writer.CityGMLWriter;
import org.citygml4j.core.model.CityGMLVersion;
import org.citygml4j.core.model.core.CityModel;
import de.hft.stuttgart.citydoctor2.check.AbstractCheck;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.ErrorId;
import de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.Localization;
import de.hft.stuttgart.citydoctor2.utils.QualityADEUtils;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.model.Validation;
import de.hft.stuttgart.quality.model.jaxb.ErrorStatistics;
import de.hft.stuttgart.quality.model.jaxb.FeatureStatistics;
import de.hft.stuttgart.quality.model.jaxb.Statistics;
import de.hft.stuttgart.quality.model.jaxb.ValidationPlan;
import de.hft.stuttgart.citydoctor2.writer.CityGMLWriterUtils;
import de.hft.stuttgart.quality.model.types.ValidationPlan;
/**
* The complete CityGML model containing all features that are used in
......@@ -87,6 +66,7 @@ public class CityDoctorModel {
private List<CheckError> globalErrors;
private boolean isValidated = false;
private ValidationPlan plan;
private CityGMLVersion cityGMLVersion;
public CityDoctorModel(ParserConfiguration config, File file) {
if (config == null) {
......@@ -112,6 +92,10 @@ public class CityDoctorModel {
this.plan = plan;
this.isValidated = true;
}
public ValidationPlan getValidationPlan() {
return plan;
}
public void addGlobalError(CheckError err) {
globalErrors.add(err);
......@@ -134,7 +118,7 @@ public class CityDoctorModel {
water.stream()).flatMap(co -> co);
}
public void saveAs(String file) throws CityGMLBuilderException, CityGMLWriteException, ADEException {
public void saveAs(String file) throws CityDoctorWriteException {
if (file.endsWith(".off")) {
exportAsOff(file);
} else {
......@@ -142,43 +126,8 @@ public class CityDoctorModel {
}
}
private void exportAsGML(String file) throws ADEException, CityGMLBuilderException, CityGMLWriteException {
CityGMLContext gmlContext = CityGMLContext.getInstance();
// setup energy ade stuff, so the parser doesn't crash on encountering this
if (!gmlContext.hasADEContexts()) {
for (ADEContext adeContext : ServiceLoader.load(ADEContext.class)) {
gmlContext.registerADEContext(adeContext);
}
}
CityGMLBuilder builder = gmlContext.createCityGMLBuilder();
CityGMLOutputFactory factory = builder.createCityGMLOutputFactory();
try (CityGMLWriter writer = factory.createCityGMLWriter(new File(file))) {
if (isValidated) {
writer.setPrefix("qual", QualityADEModule.NAMESPACE_URI);
writer.setSchemaLocation(QualityADEModule.NAMESPACE_URI,
QualityADEModule.NAMESPACE_URI + "/qualityAde.xsd");
// remove old model if available
QualityADEUtils.removeValidation(cModel);
// create new quality ade validation datastructures
Validation val = createValidation();
// add to city model
cModel.addGenericApplicationPropertyOfCityModel(val);
}
writer.setIndentString(" ");
writer.setPrefixes(CityGMLVersion.DEFAULT);
writer.setSchemaLocations(CityGMLVersion.DEFAULT);
GMLGeometryFactory gmlFactory = new GMLGeometryFactory();
storeCityObjects(buildings, gmlFactory);
storeCityObjects(vegetation, gmlFactory);
storeCityObjects(bridges, gmlFactory);
storeCityObjects(land, gmlFactory);
storeCityObjects(roads, gmlFactory);
storeCityObjects(water, gmlFactory);
writer.write(cModel);
cModel.unsetCityObjectMember();
}
private void exportAsGML(String file) throws CityDoctorWriteException {
CityGMLWriterUtils.writeCityModel(file, this);
}
private void exportAsOff(String file) {
......@@ -258,55 +207,6 @@ public class CityDoctorModel {
return counter;
}
private void storeCityObjects(List<? extends CityObject> cos, GMLGeometryFactory gmlFactory) {
for (CityObject co : cos) {
QualityADEUtils.removeValidationResult(co);
if (isValidated) {
QualityADEUtils.writeQualityAde(co);
}
co.reCreateGeometries(gmlFactory, config);
cModel.addCityObjectMember(new CityObjectMember(co.getGmlObject()));
}
}
private Validation createValidation() {
Validation val = new Validation();
val.setValidationDate(ZonedDateTime.now());
val.setValidationSoftware("CityDoctor " + Localization.getText(Localization.VERSION));
Statistics statistics = new Statistics();
Set<CheckError> errors = collectErrors();
Map<ErrorId, AtomicInteger> errorCount = new HashMap<>();
for (CheckError e : errors) {
errorCount.compute(e.getErrorId(), (k, v) -> {
if (v == null) {
return new AtomicInteger(1);
}
v.incrementAndGet();
return v;
});
}
for (Entry<ErrorId, AtomicInteger> e : errorCount.entrySet()) {
ErrorStatistics stats = new ErrorStatistics();
stats.setAmount(e.getValue().get());
de.hft.stuttgart.quality.model.jaxb.ErrorId adeId = QualityADEUtils.mapErrorIdToAdeId(e.getKey());
if (adeId == null) {
// error that is not part of the ade standard
continue;
}
stats.setName(adeId);
statistics.getErrorStatistics().add(stats);
}
statistics.setNumErrorBuildings(countValidatedCityObjects(buildings));
statistics.setNumErrorBridgeObjects(countValidatedCityObjects(bridges));
statistics.setNumErrorLandObjects(countValidatedCityObjects(land));
statistics.setNumErrorTransportation(countValidatedCityObjects(roads));
statistics.setNumErrorVegetation(countValidatedCityObjects(vegetation));
statistics.setNumErrorWaterObjects(countValidatedCityObjects(water));
val.setStatistics(statistics);
val.setValidationPlan(plan);
return val;
}
public Set<CheckError> collectErrors() {
List<CheckError> errors = new ArrayList<>();
collectErrorsFromList(errors, buildings);
......@@ -324,20 +224,6 @@ public class CityDoctorModel {
}
}
private FeatureStatistics countValidatedCityObjects(List<? extends CityObject> cos) {
int numChecked = 0;
int numError = 0;
for (CityObject co : cos) {
if (co.isValidated()) {
numChecked++;
if (co.containsAnyError()) {
numError++;
}
}
}
return new FeatureStatistics(numChecked, numError);
}
public String getFileName() {
return fileName;
}
......@@ -471,18 +357,26 @@ public class CityDoctorModel {
}
public void addCityObject(CityObject co) {
if (co instanceof Building) {
buildings.add((Building) co);
} else if (co instanceof BridgeObject) {
bridges.add((BridgeObject) co);
} else if (co instanceof TransportationObject) {
roads.add((TransportationObject) co);
} else if (co instanceof Vegetation) {
vegetation.add((Vegetation) co);
} else if (co instanceof LandObject) {
land.add((LandObject) co);
} else if (co instanceof WaterObject) {
water.add((WaterObject) co);
if (co instanceof Building b) {
buildings.add(b);
} else if (co instanceof BridgeObject bo) {
bridges.add(bo);
} else if (co instanceof TransportationObject to) {
roads.add(to);
} else if (co instanceof Vegetation veg) {
vegetation.add(veg);
} else if (co instanceof LandObject lo) {
land.add(lo);
} else if (co instanceof WaterObject wo) {
water.add(wo);
}
}
public void setParsedCityGMLVersion(CityGMLVersion cityGMLVersion) {
this.cityGMLVersion = cityGMLVersion;
}
public CityGMLVersion getCityGMLVersion() {
return cityGMLVersion;
}
}
......@@ -23,8 +23,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.core.AbstractCityObject;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.util.geometry.GeometryFactory;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
......@@ -58,7 +58,7 @@ public abstract class CityObject extends GmlElement {
* transformed to a different coordinate system. It would need to
* be transformed to the original coordinate system
*/
public abstract void reCreateGeometries(GMLGeometryFactory factory, ParserConfiguration config);
public abstract void reCreateGeometries(GeometryFactory factory, ParserConfiguration config);
/**
* Getter for the CityGML4j data object
......@@ -68,17 +68,9 @@ public abstract class CityObject extends GmlElement {
public abstract AbstractCityObject getGmlObject();
/**
* Remove the CityGML4j geometries from the data structure to save memory
* Remove the CityGML4j geometries from the data structure to save memory.
*/
public abstract void unsetGmlGeometries();
// void copyAttributesInto(CityObject copy, ReferenceStore store) {
// super.copyAttributesInto(copy);
// copy.geometryList = new ArrayList<>();
// for (Geometry geom : geometryList) {
// copy.geometryList.add(geom.copy(store));
// }
// }
public void addGeometry(Geometry geom) {
Objects.requireNonNull(geom);
......@@ -177,28 +169,28 @@ public abstract class CityObject extends GmlElement {
}
return null;
}
@Override
public void prepareForChecking() {
for (Geometry geom : geometryList) {
geom.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
for (Geometry geom : geometryList) {
geom.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
for (Geometry geom : geometryList) {
handler.addInstance(geom);
}
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
......
......@@ -49,6 +49,10 @@ public class ConcretePolygon extends Polygon {
private BuildingInstallation partfOfInstallation;
private Geometry parent;
private LinkedPolygon linkedFromPolygon;
public ConcretePolygon() {
// TODO Auto-generated constructor stub
}
/*
* (non-Javadoc)
......@@ -259,7 +263,7 @@ public class ConcretePolygon extends Polygon {
if (hasError) {
return true;
}
if (exterior.containsError(checkIdentifier)) {
if (exterior != null && exterior.containsError(checkIdentifier)) {
return true;
}
if (innerRings != null) {
......@@ -494,6 +498,11 @@ public class ConcretePolygon extends Polygon {
partOfSurface = handler.getCopyInstance(originalPoly.partOfSurface);
linkedFromPolygon = handler.getCopyInstance(originalPoly.linkedFromPolygon);
}
@Override
public void remove() {
parent.removePolygon(this);
}
......
......@@ -46,6 +46,8 @@ import de.hft.stuttgart.citydoctor2.utils.SerializablePair;
*/
public class Geometry extends GmlElement {
private static final String FAILED_REMOVING_POLYGON = "Removing polygon %s but polygon is not in geometry";
private static final long serialVersionUID = 2539031030917731575L;
private static Random r = new Random();
......@@ -55,7 +57,7 @@ public class Geometry extends GmlElement {
private CityObject parent;
private List<Polygon> polygons = new ArrayList<>();
private List<Polygon> polygons = new ArrayList<>(2);
private List<Edge> edges;
private Map<SerializablePair<Vertex, Vertex>, Edge> edgeMap;
private List<Vertex> vertices;
......@@ -93,14 +95,13 @@ public class Geometry extends GmlElement {
polygons.add(cdPoly);
cdPoly.setParent(this);
// set part of boundary surface or building installation or both
if (parent instanceof BoundarySurface) {
BoundarySurface bs = (BoundarySurface) parent;
if (parent instanceof BoundarySurface bs) {
cdPoly.setPartOfSurface(bs);
if (bs.getParent() instanceof BuildingInstallation) {
cdPoly.setPartOfInstallation((BuildingInstallation) bs.getParent());
if (bs.getParent() instanceof BuildingInstallation bi) {
cdPoly.setPartOfInstallation(bi);
}
} else if (parent instanceof BuildingInstallation) {
cdPoly.setPartOfInstallation((BuildingInstallation) parent);
} else if (parent instanceof BuildingInstallation bi) {
cdPoly.setPartOfInstallation(bi);
}
}
......@@ -323,15 +324,21 @@ public class Geometry extends GmlElement {
}
}
public void removePolygon(Polygon p) {
void removePolygon(Polygon p) {
p.removeRings();
polygons.remove(p);
if (!polygons.remove(p)) {
throw new IllegalStateException(String.format(FAILED_REMOVING_POLYGON, p));
}
if (p.isLink()) {
Polygon original = p.getOriginal();
original.getParent().polygons.remove(original);
if (!original.getParent().polygons.remove(original)) {
throw new IllegalStateException(String.format(FAILED_REMOVING_POLYGON, p));
}
} else if (p.isLinkedTo()) {
Polygon link = p.getLinkedFromPolygon();
link.getParent().polygons.remove(link);
if (!link.getParent().polygons.remove(link)) {
throw new IllegalStateException(String.format(FAILED_REMOVING_POLYGON, p));
}
}
}
......
......@@ -46,6 +46,10 @@ public abstract class GmlElement extends Checkable implements Copyable {
return gmlId;
}
public boolean hasExistingGmlId() {
return gmlId != null && !gmlId.isGenerated();
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
GmlElement originalElement = (GmlElement) original;
......
......@@ -18,11 +18,11 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.core.AbstractCityObject;
import org.citygml4j.model.citygml.landuse.LandUse;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurface;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.model.landuse.LandUse;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
......@@ -46,7 +46,7 @@ public class LandObject extends CityObject {
}
@Override
public void reCreateGeometries(GMLGeometryFactory factory, ParserConfiguration config) {
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
......@@ -77,7 +77,7 @@ public class LandObject extends CityObject {
lu.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
lu.setLod4MultiSurface(new MultiSurfaceProperty(ms));
lu.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break;
}
}
......@@ -97,11 +97,11 @@ public class LandObject extends CityObject {
@Override
public void unsetGmlGeometries() {
lu.unsetLod0MultiSurface();
lu.unsetLod1MultiSurface();
lu.unsetLod2MultiSurface();
lu.unsetLod3MultiSurface();
lu.unsetLod4MultiSurface();
lu.setLod0MultiSurface(null);
lu.setLod1MultiSurface(null);
lu.setLod2MultiSurface(null);
lu.setLod3MultiSurface(null);
lu.getDeprecatedProperties().setLod4MultiSurface(null);
}
public void setGmlObject(LandUse landUse) {
......
......@@ -290,4 +290,9 @@ public class LinkedPolygon extends Polygon {
poly = handler.getCopyInstance(linkedOriginal.poly);
}
@Override
public void remove() {
poly.remove();
}
}
Markdown is supported
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