Commit 1745865f authored by Riegel's avatar Riegel
Browse files

Code cleaning Ref #69

parent 5a6f4b46
...@@ -30,6 +30,8 @@ import de.hft.stuttgart.citydoctor2.check.HealingMethod; ...@@ -30,6 +30,8 @@ import de.hft.stuttgart.citydoctor2.check.HealingMethod;
import de.hft.stuttgart.citydoctor2.check.ModificationListener; import de.hft.stuttgart.citydoctor2.check.ModificationListener;
import de.hft.stuttgart.citydoctor2.datastructure.GmlElement; import de.hft.stuttgart.citydoctor2.datastructure.GmlElement;
import java.io.Serial;
/** /**
* This error is created when an unexpected exception is thrown by the code. * This error is created when an unexpected exception is thrown by the code.
* *
...@@ -38,11 +40,12 @@ import de.hft.stuttgart.citydoctor2.datastructure.GmlElement; ...@@ -38,11 +40,12 @@ import de.hft.stuttgart.citydoctor2.datastructure.GmlElement;
*/ */
public class UnknownCheckError implements CheckError { public class UnknownCheckError implements CheckError {
@Serial
private static final long serialVersionUID = -6554097632341055596L; private static final long serialVersionUID = -6554097632341055596L;
private Checkable c; private final Checkable c;
private Exception e; private final Exception e;
private CheckId checkId; private final CheckId checkId;
public UnknownCheckError(Checkable c, Exception e, Check check) { public UnknownCheckError(Checkable c, Exception e, Check check) {
this.c = c; this.c = c;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -47,12 +48,13 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable; ...@@ -47,12 +48,13 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
*/ */
public abstract class AbstractBuilding extends CityObject { public abstract class AbstractBuilding extends CityObject {
@Serial
private static final long serialVersionUID = -2196414503088741206L; private static final long serialVersionUID = -2196414503088741206L;
private static final Logger logger = LogManager.getLogger(AbstractBuilding.class); private static final Logger logger = LogManager.getLogger(AbstractBuilding.class);
private List<Installation> buildingInstallations = new ArrayList<>(2); private final List<Installation> buildingInstallations = new ArrayList<>(2);
private List<BoundarySurface> boundarySurfaceList = new ArrayList<>(); private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
private org.citygml4j.core.model.building.AbstractBuilding ab; private org.citygml4j.core.model.building.AbstractBuilding ab;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -42,12 +43,13 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable; ...@@ -42,12 +43,13 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
*/ */
public class BoundarySurface extends CityObject { public class BoundarySurface extends CityObject {
@Serial
private static final long serialVersionUID = 8793865135393496408L; private static final long serialVersionUID = 8793865135393496408L;
private SurfaceFeatureType featureType; private SurfaceFeatureType featureType;
private BoundarySurfaceType type; private BoundarySurfaceType type;
private List<Opening> openings = new ArrayList<>(2); private final List<Opening> openings = new ArrayList<>(2);
private CityObject parent; private CityObject parent;
private AbstractThematicSurface gmlObject; private AbstractThematicSurface gmlObject;
......
...@@ -32,7 +32,7 @@ import de.hft.stuttgart.citydoctor2.utils.BoundingBoxCalculator; ...@@ -32,7 +32,7 @@ import de.hft.stuttgart.citydoctor2.utils.BoundingBoxCalculator;
*/ */
public class BoundingBox { public class BoundingBox {
private Vector3d[] bbox; private final Vector3d[] bbox;
/** /**
* Creates an axis aligned bounding box containing all points of all polygons * Creates an axis aligned bounding box containing all points of all polygons
...@@ -142,11 +142,7 @@ public class BoundingBox { ...@@ -142,11 +142,7 @@ public class BoundingBox {
public double getLongestSide() { public double getLongestSide() {
double width = getWidth(); double width = getWidth();
double depth = getDepth(); double depth = getDepth();
if (width > depth) { return Math.max(width, depth);
return width;
} else {
return depth;
}
} }
/** /**
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -47,10 +48,11 @@ public class BridgeConstructiveElement extends CityObject { ...@@ -47,10 +48,11 @@ public class BridgeConstructiveElement extends CityObject {
private static final String CANNOT_ADD = "Cannot add "; private static final String CANNOT_ADD = "Cannot add ";
@Serial
private static final long serialVersionUID = 7353233899458901155L; private static final long serialVersionUID = 7353233899458901155L;
private org.citygml4j.core.model.bridge.BridgeConstructiveElement gmlBridgeElement; private final org.citygml4j.core.model.bridge.BridgeConstructiveElement gmlBridgeElement;
private List<BoundarySurface> boundarySurfaceList = new ArrayList<>(); private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
public BridgeConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement gmlObject) { public BridgeConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement gmlObject) {
......
/*- /*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
* *
* This file is part of CityDoctor2. * This file is part of CityDoctor2.
* *
* CityDoctor2 is free software: you can redistribute it and/or modify * CityDoctor2 is free software: you can redistribute it and/or modify
...@@ -18,9 +18,13 @@ ...@@ -18,9 +18,13 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.util.ArrayList; import de.hft.stuttgart.citydoctor2.check.Check;
import java.util.List; 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.bridge.AbstractBridge; import org.citygml4j.core.model.bridge.AbstractBridge;
import org.citygml4j.core.model.bridge.BridgeInstallation; import org.citygml4j.core.model.bridge.BridgeInstallation;
import org.citygml4j.core.model.bridge.BridgeInstallationProperty; import org.citygml4j.core.model.bridge.BridgeInstallationProperty;
...@@ -31,466 +35,425 @@ import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty; ...@@ -31,466 +35,425 @@ import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.primitives.Solid; import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty; import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import de.hft.stuttgart.citydoctor2.check.Check; import java.io.Serial;
import de.hft.stuttgart.citydoctor2.check.CheckError; import java.util.ArrayList;
import de.hft.stuttgart.citydoctor2.check.CheckId; import java.util.List;
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;
/** /**
* Bridge representation object of CityGML bridge objects * Bridge representation object of CityGML bridge objects
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public class BridgeObject extends CityObject { public class BridgeObject extends CityObject {
private static final long serialVersionUID = 6301112640328373842L; @Serial
private static final long serialVersionUID = 6301112640328373842L;
public enum BridgeType { private final List<BridgeObject> parts = new ArrayList<>(2);
BRIDGE, BRIDGE_PART private final List<BridgeConstructiveElement> elements = new ArrayList<>(2);
} private final List<BoundarySurface> boundarySurfaces = new ArrayList<>(2);
private final List<Installation> bridgeInstallations = new ArrayList<>(2);
private AbstractBridge ab; private AbstractBridge ab;
private BridgeType type; private BridgeType type;
public BridgeObject(BridgeType type, AbstractBridge ab) {
private List<BridgeObject> parts = null; this.ab = ab;
this.type = type;
private List<BridgeConstructiveElement> elements = null; }
private List<BoundarySurface> boundarySurfaces = new ArrayList<>(2);
private List<Installation> bridgeInstallations = new ArrayList<>(2); @Override
public FeatureType getFeatureType() {
public BridgeObject(BridgeType type, AbstractBridge ab) { return FeatureType.BRIDGE;
this.ab = ab; }
this.type = type;
} public List<BridgeConstructiveElement> getConstructiveElements() {
return elements;
@Override }
public FeatureType getFeatureType() {
return FeatureType.BRIDGE; public List<Installation> getBridgeInstallations() {
} return bridgeInstallations;
}
public List<BridgeConstructiveElement> getConstructiveElements() {
if (elements == null) { @Override
elements = new ArrayList<>(2); public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
} for (Geometry geom : getGeometries()) {
return elements; if (geom.getType() == GeometryType.MULTI_SURFACE) {
} MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms);
public List<Installation> getBridgeInstallations() { } else {
return bridgeInstallations; Solid solid = CityGmlUtils.createSolid(geom, factory, config);
} setSolidAccordingToLod(geom, solid);
}
@Override }
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { for (BoundarySurface bs : boundarySurfaces) {
for (Geometry geom : getGeometries()) { bs.reCreateGeometries(factory, config);
if (geom.getType() == GeometryType.MULTI_SURFACE) { }
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config); for (Installation bi : bridgeInstallations) {
setMultiSurfaceAccordingToLod(geom, ms); bi.reCreateGeometries(factory, config);
} else { }
Solid solid = CityGmlUtils.createSolid(geom, factory, config); for (BridgeObject part : parts) {
setSolidAccordingToLod(geom, solid); part.reCreateGeometries(factory, config);
} }
} for (BridgeConstructiveElement ele : elements) {
for (BoundarySurface bs : boundarySurfaces) { ele.reCreateGeometries(factory, config);
bs.reCreateGeometries(factory, config); }
}
for (Installation bi : bridgeInstallations) { }
bi.reCreateGeometries(factory, config);
} private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
if (parts != null) { switch (geom.getLod()) {
for (BridgeObject part : parts) { case LOD1:
part.reCreateGeometries(factory, config); ab.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
} break;
} case LOD2:
if (elements != null) { ab.setLod2MultiSurface(new MultiSurfaceProperty(ms));
for (BridgeConstructiveElement ele : elements) { break;
ele.reCreateGeometries(factory, config); case LOD3:
} ab.setLod3MultiSurface(new MultiSurfaceProperty(ms));
} break;
} case LOD4:
ab.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) { break;
switch (geom.getLod()) { default:
case LOD1: throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to bridges");
ab.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms)); }
break; }
case LOD2:
ab.setLod2MultiSurface(new MultiSurfaceProperty(ms)); private void setSolidAccordingToLod(Geometry geom, Solid solid) {
break; switch (geom.getLod()) {
case LOD3: case LOD1:
ab.setLod3MultiSurface(new MultiSurfaceProperty(ms)); ab.setLod1Solid(new SolidProperty(solid));
break; break;
case LOD4: case LOD2:
ab.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms)); ab.setLod2Solid(new SolidProperty(solid));
break; break;
default: case LOD3:
throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to bridges"); ab.setLod3Solid(new SolidProperty(solid));
} break;
} case LOD4:
ab.getDeprecatedProperties().setLod4Solid(new SolidProperty(solid));
private void setSolidAccordingToLod(Geometry geom, Solid solid) { break;
switch (geom.getLod()) { default:
case LOD1: throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to bridges");
ab.setLod1Solid(new SolidProperty(solid)); }
break; }
case LOD2: public void addBridgeInstallation(Installation coBi) {
ab.setLod2Solid(new SolidProperty(solid)); bridgeInstallations.add(coBi);
break; coBi.setParent(this);
case LOD3: }
ab.setLod3Solid(new SolidProperty(solid));
break; @Override
case LOD4: public void clearAllContainedCheckResults() {
ab.getDeprecatedProperties().setLod4Solid(new SolidProperty(solid)); super.clearAllContainedCheckResults();
break; for (BoundarySurface bs : boundarySurfaces) {
default: bs.clearAllContainedCheckResults();
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to bridges"); }
} for (Installation bi : bridgeInstallations) {
} bi.clearAllContainedCheckResults();
}
public void addBridgeInstallation(Installation coBi) { for (BridgeObject part : parts) {
bridgeInstallations.add(coBi); part.clearAllContainedCheckResults();
coBi.setParent(this); }
} for (BridgeConstructiveElement ele : elements) {
ele.clearAllContainedCheckResults();
@Override }
public void clearAllContainedCheckResults() { }
super.clearAllContainedCheckResults();
for (BoundarySurface bs : boundarySurfaces) { @Override
bs.clearAllContainedCheckResults(); public void collectContainedErrors(List<CheckError> errors) {
} super.collectContainedErrors(errors);
for (Installation bi : bridgeInstallations) { for (BoundarySurface bs : boundarySurfaces) {
bi.clearAllContainedCheckResults(); bs.collectContainedErrors(errors);
} }
if (parts != null) { for (Installation bi : bridgeInstallations) {
for (BridgeObject part : parts) { bi.collectContainedErrors(errors);
part.clearAllContainedCheckResults(); }
} for (BridgeObject part : parts) {
} part.collectContainedErrors(errors);
if (elements != null) { }
for (BridgeConstructiveElement ele : elements) { for (BridgeConstructiveElement ele : elements) {
ele.clearAllContainedCheckResults(); ele.collectContainedErrors(errors);
} }
}
} }
@Override @Override
public void collectContainedErrors(List<CheckError> errors) { public boolean containsAnyError() {
super.collectContainedErrors(errors); boolean hasError = super.containsAnyError();
for (BoundarySurface bs : boundarySurfaces) { if (hasError) {
bs.collectContainedErrors(errors); return true;
} }
for (Installation bi : bridgeInstallations) { for (Installation bi : bridgeInstallations) {
bi.collectContainedErrors(errors); if (bi.containsAnyError()) {
} return true;
if (parts != null) { }
for (BridgeObject part : parts) { }
part.collectContainedErrors(errors); for (BoundarySurface bs : boundarySurfaces) {
} if (bs.containsAnyError()) {
} return true;
if (elements != null) { }
for (BridgeConstructiveElement ele : elements) { }
ele.collectContainedErrors(errors); if (doPartsContainAnyError()) {
} return true;
} }
} for (BridgeConstructiveElement ele : elements) {
if (ele.containsAnyError()) {
@Override return true;
public boolean containsAnyError() { }
boolean hasError = super.containsAnyError(); }
if (hasError) { return false;
return true; }
}
for (Installation bi : bridgeInstallations) { private boolean doPartsContainAnyError() {
if (bi.containsAnyError()) {
return true; for (BridgeObject part : parts) {
} if (part.containsAnyError()) {
} return true;
for (BoundarySurface bs : boundarySurfaces) { }
if (bs.containsAnyError()) { }
return true; return false;
} }
}
if (doPartsContainAnyError()) { @Override
return true; public boolean containsError(CheckId checkIdentifier) {
} boolean hasError = super.containsError(checkIdentifier);
if (elements != null) { if (hasError) {
for (BridgeConstructiveElement ele : elements) { return true;
if (ele.containsAnyError()) { }
return true; for (Installation bi : bridgeInstallations) {
} if (bi.containsError(checkIdentifier)) {
} return true;
} }
return false; }
} for (BoundarySurface bs : boundarySurfaces) {
if (bs.containsError(checkIdentifier)) {
private boolean doPartsContainAnyError() { return true;
if (parts != null) { }
for (BridgeObject part : parts) { }
if (part.containsAnyError()) { if (doPartsContainError(checkIdentifier)) {
return true; return true;
} }
} for (BridgeConstructiveElement ele : elements) {
} if (ele.containsError(checkIdentifier)) {
return false; return true;
} }
}
@Override return false;
public boolean containsError(CheckId checkIdentifier) { }
boolean hasError = super.containsError(checkIdentifier);
if (hasError) { private boolean doPartsContainError(CheckId checkIdentifier) {
return true;
} for (BridgeObject part : parts) {
for (Installation bi : bridgeInstallations) { if (part.containsError(checkIdentifier)) {
if (bi.containsError(checkIdentifier)) { return true;
return true; }
} }
} return false;
for (BoundarySurface bs : boundarySurfaces) { }
if (bs.containsError(checkIdentifier)) {
return true; @Override
} public void accept(Check c) {
} super.accept(c);
if (doPartsContainError(checkIdentifier)) { if (c.canExecute(this)) {
return true; c.check(this);
} }
if (elements != null) { for (BoundarySurface bs : boundarySurfaces) {
for (BridgeConstructiveElement ele : elements) { bs.accept(c);
if (ele.containsError(checkIdentifier)) { }
return true; for (Installation bi : bridgeInstallations) {
} bi.accept(c);
} }
} for (BridgeObject part : parts) {
return false; part.accept(c);
} }
for (BridgeConstructiveElement ele : elements) {
private boolean doPartsContainError(CheckId checkIdentifier) { ele.accept(c);
if (parts != null) { }
for (BridgeObject part : parts) {
if (part.containsError(checkIdentifier)) { }
return true;
} /**
} * Getter method for type
} *
return false; * @return the type
} */
public BridgeType getType() {
@Override return type;
public void accept(Check c) { }
super.accept(c);
if (c.canExecute(this)) { /**
c.check(this); * Setter Method for type
} *
for (BoundarySurface bs : boundarySurfaces) { * @param type the type to set
bs.accept(c); */
} public void setType(BridgeType type) {
for (Installation bi : bridgeInstallations) { this.type = type;
bi.accept(c); }
}
if (parts != null) { public void addBoundarySurface(BoundarySurface bs) {
for (BridgeObject part : parts) { boundarySurfaces.add(bs);
part.accept(c); bs.setParent(this);
} }
}
if (elements != null) { @Override
for (BridgeConstructiveElement ele : elements) { public AbstractBridge getGmlObject() {
ele.accept(c); return ab;
} }
}
} public void setGmlObject(AbstractBridge aBridge) {
ab = aBridge;
/** }
* Getter method for type
* @Override
* @return the type public void unsetGmlGeometries() {
*/ ab.setLod1Solid(null);
public BridgeType getType() { ab.setLod2Solid(null);
return type; ab.setLod3Solid(null);
} ab.setLod2MultiSurface(null);
ab.setLod3MultiSurface(null);
/** ab.getDeprecatedProperties().setLod1MultiSurface(null);
* Setter Method for type ab.getDeprecatedProperties().setLod4MultiSurface(null);
* ab.getDeprecatedProperties().setLod4Solid(null);
* @param type the type to set for (BoundarySurface bs : boundarySurfaces) {
*/ bs.unsetGmlGeometries();
public void setType(BridgeType type) { }
this.type = type; for (Installation bi : bridgeInstallations) {
} bi.unsetGmlGeometries();
}
public void addBoundarySurface(BoundarySurface bs) { for (BridgeObject part : parts) {
boundarySurfaces.add(bs); part.unsetGmlGeometries();
bs.setParent(this); }
} for (BridgeConstructiveElement ele : elements) {
ele.unsetGmlGeometries();
@Override }
public AbstractBridge getGmlObject() {
return ab; }
}
@Override
@Override public String toString() {
public void unsetGmlGeometries() { return "BridgeObject [type=" + type + ", id=" + getGmlId() + "]";
ab.setLod1Solid(null); }
ab.setLod2Solid(null);
ab.setLod3Solid(null); @Override
ab.setLod2MultiSurface(null); public void prepareForChecking() {
ab.setLod3MultiSurface(null); super.prepareForChecking();
ab.getDeprecatedProperties().setLod1MultiSurface(null);
ab.getDeprecatedProperties().setLod4MultiSurface(null); for (BridgeConstructiveElement e : elements) {
ab.getDeprecatedProperties().setLod4Solid(null); e.prepareForChecking();
for (BoundarySurface bs : boundarySurfaces) { }
bs.unsetGmlGeometries(); for (BridgeObject part : parts) {
} part.prepareForChecking();
for (Installation bi : bridgeInstallations) { }
bi.unsetGmlGeometries(); for (BoundarySurface bs : boundarySurfaces) {
} bs.prepareForChecking();
if (parts != null) { }
for (BridgeObject part : parts) { for (Installation bi : bridgeInstallations) {
part.unsetGmlGeometries(); bi.prepareForChecking();
} }
} }
if (elements != null) {
for (BridgeConstructiveElement ele : elements) { @Override
ele.unsetGmlGeometries(); public void clearMetaInformation() {
} super.clearMetaInformation();
} for (BoundarySurface bs : boundarySurfaces) {
} bs.clearMetaInformation();
}
public void setGmlObject(AbstractBridge aBridge) { for (Installation bi : bridgeInstallations) {
ab = aBridge; bi.clearMetaInformation();
} }
@Override for (BridgeObject part : parts) {
public String toString() { part.clearMetaInformation();
return "BridgeObject [type=" + type + ", id=" + getGmlId() + "]"; }
}
@Override for (BridgeConstructiveElement ele : elements) {
public void prepareForChecking() { ele.clearMetaInformation();
super.prepareForChecking(); }
if (elements != null) {
for (BridgeConstructiveElement e : elements) { }
e.prepareForChecking();
} @Override
} public void collectInstances(CopyHandler handler) {
if (parts != null) { super.collectInstances(handler);
for (BridgeObject part : parts) { for (BoundarySurface bs : boundarySurfaces) {
part.prepareForChecking(); handler.addInstance(bs);
} }
} for (Installation bi : bridgeInstallations) {
for (BoundarySurface bs : boundarySurfaces) { handler.addInstance(bi);
bs.prepareForChecking(); }
}
for (Installation bi : bridgeInstallations) { for (BridgeObject part : parts) {
bi.prepareForChecking(); handler.addInstance(part);
} }
}
@Override for (BridgeConstructiveElement ele : elements) {
public void clearMetaInformation() { handler.addInstance(ele);
super.clearMetaInformation(); }
for (BoundarySurface bs : boundarySurfaces) {
bs.clearMetaInformation(); }
}
for (Installation bi : bridgeInstallations) { public void anonymize() {
bi.clearMetaInformation(); for (Geometry geom : getGeometries()) {
} geom.anonymize();
if (parts != null) { }
for (BridgeObject part : parts) { org.citygml4j.core.model.bridge.Bridge gmlB = new org.citygml4j.core.model.bridge.Bridge();
part.clearMetaInformation(); gmlB.setId(GmlId.generateId().getGmlString());
} for (Installation bi : getBridgeInstallations()) {
} bi.anonymize();
if (elements != null) { gmlB.getBridgeInstallations().add(new BridgeInstallationProperty((BridgeInstallation) bi.getGmlObject()));
for (BridgeConstructiveElement ele : elements) { }
ele.clearMetaInformation(); for (BoundarySurface bs : getBoundarySurfaces()) {
} bs.anonymize();
} gmlB.addBoundary(new AbstractSpaceBoundaryProperty(bs.getGmlObject()));
} }
this.ab = gmlB;
@Override }
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler); @Override
for (BoundarySurface bs : boundarySurfaces) { public void fillValues(Copyable original, CopyHandler handler) {
handler.addInstance(bs); super.fillValues(original, handler);
} BridgeObject originalBo = (BridgeObject) original;
for (Installation bi : bridgeInstallations) { for (BoundarySurface originalBs : originalBo.boundarySurfaces) {
handler.addInstance(bi); boundarySurfaces.add(handler.getCopyInstance(originalBs));
} }
if (parts != null) { for (Installation originalBi : originalBo.bridgeInstallations) {
for (BridgeObject part : parts) { bridgeInstallations.add(handler.getCopyInstance(originalBi));
handler.addInstance(part); }
}
} for (BridgeObject part : originalBo.parts) {
if (elements != null) { getParts().add(handler.getCopyInstance(part));
for (BridgeConstructiveElement ele : elements) { }
handler.addInstance(ele);
}
} for (BridgeConstructiveElement ele : originalBo.elements) {
} getConstructiveElements().add(handler.getCopyInstance(ele));
}
public void anonymize() {
for (Geometry geom : getGeometries()) { }
geom.anonymize();
} public List<BoundarySurface> getBoundarySurfaces() {
org.citygml4j.core.model.bridge.Bridge gmlB = new org.citygml4j.core.model.bridge.Bridge(); return boundarySurfaces;
gmlB.setId(GmlId.generateId().getGmlString()); }
for (Installation bi : getBridgeInstallations()) {
bi.anonymize(); public void addConstructiveElement(BridgeConstructiveElement element) {
gmlB.getBridgeInstallations().add(new BridgeInstallationProperty((BridgeInstallation) bi.getGmlObject())); getConstructiveElements().add(element);
} }
for (BoundarySurface bs : getBoundarySurfaces()) {
bs.anonymize(); @Override
gmlB.addBoundary(new AbstractSpaceBoundaryProperty(bs.getGmlObject())); public Copyable createCopyInstance() {
} return new BridgeObject(type, ab);
this.ab = gmlB; }
}
public List<BridgeObject> getParts() {
return parts;
@Override }
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler); public void addBridgePart(BridgeObject bPart) {
BridgeObject originalBo = (BridgeObject) original; getParts().add(bPart);
for (BoundarySurface originalBs : originalBo.boundarySurfaces) { }
boundarySurfaces.add(handler.getCopyInstance(originalBs));
} public enum BridgeType {
for (Installation originalBi : originalBo.bridgeInstallations) { BRIDGE, BRIDGE_PART
bridgeInstallations.add(handler.getCopyInstance(originalBi)); }
}
if (originalBo.parts != null) {
for (BridgeObject part : originalBo.parts) {
getParts().add(handler.getCopyInstance(part));
}
}
if (originalBo.elements != null) {
for (BridgeConstructiveElement ele : originalBo.elements) {
getConstructiveElements().add(handler.getCopyInstance(ele));
}
}
}
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaces;
}
public void addConstructiveElement(BridgeConstructiveElement element) {
getConstructiveElements().add(element);
}
@Override
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) {
getParts().add(bPart);
}
} }
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -35,9 +36,10 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable; ...@@ -35,9 +36,10 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
public class Building extends AbstractBuilding { public class Building extends AbstractBuilding {
@Serial
private static final long serialVersionUID = 588480113268630052L; private static final long serialVersionUID = 588480113268630052L;
private List<BuildingPart> buildingParts = new ArrayList<>(2); private final List<BuildingPart> buildingParts = new ArrayList<>(2);
public List<BuildingPart> getBuildingParts() { public List<BuildingPart> getBuildingParts() {
return buildingParts; return buildingParts;
......
...@@ -21,8 +21,11 @@ package de.hft.stuttgart.citydoctor2.datastructure; ...@@ -21,8 +21,11 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler; import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable; import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
public class BuildingPart extends AbstractBuilding { public class BuildingPart extends AbstractBuilding {
@Serial
private static final long serialVersionUID = 8200322261958679163L; private static final long serialVersionUID = 8200322261958679163L;
private Building parent; private Building parent;
......
...@@ -53,17 +53,17 @@ import de.hft.stuttgart.quality.model.types.ValidationPlan; ...@@ -53,17 +53,17 @@ import de.hft.stuttgart.quality.model.types.ValidationPlan;
public class CityDoctorModel { public class CityDoctorModel {
private static final String COULD_NOT_FIND_FEATURE = "Could not find feature: "; private static final String COULD_NOT_FIND_FEATURE = "Could not find feature: ";
private List<Building> buildings; private final List<Building> buildings;
private List<Vegetation> vegetation; private final List<Vegetation> vegetation;
private List<BridgeObject> bridges; private final List<BridgeObject> bridges;
private List<CityObject> land; private final List<CityObject> land;
private List<TransportationObject> roads; private final List<TransportationObject> roads;
private List<WaterObject> water; private final List<WaterObject> water;
private CityModel cModel; private CityModel cModel;
private ParserConfiguration config; private final ParserConfiguration config;
private String fileName; private final String fileName;
private File file; private final File file;
private List<CheckError> globalErrors; private final List<CheckError> globalErrors;
private boolean isValidated = false; private boolean isValidated = false;
private ValidationPlan plan; private ValidationPlan plan;
private CityGMLVersion cityGMLVersion; private CityGMLVersion cityGMLVersion;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
...@@ -43,9 +44,10 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable; ...@@ -43,9 +44,10 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
*/ */
public abstract class CityObject extends GmlElement { public abstract class CityObject extends GmlElement {
@Serial
private static final long serialVersionUID = 651712070755024188L; private static final long serialVersionUID = 651712070755024188L;
private List<Geometry> geometryList = new ArrayList<>(); private final List<Geometry> geometryList = new ArrayList<>();
/** /**
* Recreates the CityGML4j geometry in this object. The CityGML4j geometry is * Recreates the CityGML4j geometry in this object. The CityGML4j geometry is
...@@ -83,23 +85,11 @@ public abstract class CityObject extends GmlElement { ...@@ -83,23 +85,11 @@ public abstract class CityObject extends GmlElement {
} }
public void removeGeometry(Lod lod) { public void removeGeometry(Lod lod) {
Iterator<Geometry> it = geometryList.iterator(); geometryList.removeIf(geom -> geom.getLod() == lod);
while (it.hasNext()) {
Geometry next = it.next();
if (next.getLod() == lod) {
it.remove();
}
}
} }
public void removeGeometry(Lod lod, GeometryType type) { public void removeGeometry(Lod lod, GeometryType type) {
Iterator<Geometry> it = geometryList.iterator(); geometryList.removeIf(geom -> geom.getLod() == lod && geom.getType() == type);
while (it.hasNext()) {
Geometry next = it.next();
if (next.getLod() == lod && next.getType() == type) {
it.remove();
}
}
} }
public Geometry getHighestLodGeometry() { public Geometry getHighestLodGeometry() {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
...@@ -41,6 +42,7 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable; ...@@ -41,6 +42,7 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
*/ */
public class ConcretePolygon extends Polygon { public class ConcretePolygon extends Polygon {
@Serial
private static final long serialVersionUID = -2208347892270418372L; private static final long serialVersionUID = -2208347892270418372L;
private LinearRing exterior; private LinearRing exterior;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -33,10 +34,11 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable; ...@@ -33,10 +34,11 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
*/ */
public class Edge implements Serializable, Copyable { public class Edge implements Serializable, Copyable {
@Serial
private static final long serialVersionUID = -504694863498128296L; private static final long serialVersionUID = -504694863498128296L;
private List<Polygon> adjacentPolygons = new ArrayList<>(2); private final List<Polygon> adjacentPolygons = new ArrayList<>(2);
private List<LinearRing> adjacentRings = new ArrayList<>(2); private final List<LinearRing> adjacentRings = new ArrayList<>(2);
private Vertex from; private Vertex from;
private Vertex to; private Vertex to;
...@@ -78,16 +80,8 @@ public class Edge implements Serializable, Copyable { ...@@ -78,16 +80,8 @@ public class Edge implements Serializable, Copyable {
} }
private boolean isPointOfEdge(Vertex v0, Vertex edgePoint) { private boolean isPointOfEdge(Vertex v0, Vertex edgePoint) {
if (v0.equals(edgePoint)) { return v0.equals(edgePoint);
return true; }
}
// for (Vertex v : v0.getNeighbors()) {
// if (v.equals(edgePoint)) {
// return true;
// }
// }
return false;
}
public boolean formedByIgnoreDirection(Vertex v1, Vertex v2) { public boolean formedByIgnoreDirection(Vertex v1, Vertex v2) {
return (v1 == from && v2 == to) || (v1 == to && v2 == from); return (v1 == from && v2 == to) || (v1 == to && v2 == from);
...@@ -146,14 +140,9 @@ public class Edge implements Serializable, Copyable { ...@@ -146,14 +140,9 @@ public class Edge implements Serializable, Copyable {
return false; return false;
} }
if (to == null) { if (to == null) {
if (other.to != null) { return other.to == null;
return false; } else return to.equals(other.to);
} }
} else if (!to.equals(other.to)) {
return false;
}
return true;
}
public void addAdjacentPolygon(Polygon p) { public void addAdjacentPolygon(Polygon p) {
adjacentPolygons.add(p); adjacentPolygons.add(p);
......
...@@ -27,6 +27,6 @@ package de.hft.stuttgart.citydoctor2.datastructure; ...@@ -27,6 +27,6 @@ package de.hft.stuttgart.citydoctor2.datastructure;
public enum FeatureType { public enum FeatureType {
BUILDING, TRANSPORTATION, VEGETATION, BRIDGE, LAND, WATER, BOUNDARY_SURFACE, INSTALLATION, OPENING, BUILDING, TRANSPORTATION, VEGETATION, BRIDGE, LAND, WATER, BOUNDARY_SURFACE, INSTALLATION, OPENING,
BUILDING_PART, BRIDGE_CONSTRUCTION_ELEMENT, BRIDGE_INSTALLATION; BUILDING_PART, BRIDGE_CONSTRUCTION_ELEMENT, BRIDGE_INSTALLATION
} }
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
...@@ -48,16 +49,17 @@ public class Geometry extends GmlElement { ...@@ -48,16 +49,17 @@ public class Geometry extends GmlElement {
private static final String FAILED_REMOVING_POLYGON = "Removing polygon %s but polygon is not in geometry"; private static final String FAILED_REMOVING_POLYGON = "Removing polygon %s but polygon is not in geometry";
@Serial
private static final long serialVersionUID = 2539031030917731575L; private static final long serialVersionUID = 2539031030917731575L;
private static Random r = new Random(); private static final Random r = new Random();
private GeometryType type; private GeometryType type;
private Lod lod; private final Lod lod;
private CityObject parent; private CityObject parent;
private List<Polygon> polygons = new ArrayList<>(2); private final List<Polygon> polygons = new ArrayList<>(2);
private List<Edge> edges; private List<Edge> edges;
private Map<SerializablePair<Vertex, Vertex>, Edge> edgeMap; private Map<SerializablePair<Vertex, Vertex>, Edge> edgeMap;
private List<Vertex> vertices; private List<Vertex> vertices;
...@@ -153,7 +155,7 @@ public class Geometry extends GmlElement { ...@@ -153,7 +155,7 @@ public class Geometry extends GmlElement {
} }
// only go to size -1 as ring should be closed // only go to size -1 as ring should be closed
for (int i = 0; i < ring.getVertices().size() - 1; i++) { for (int i = 0; i < ring.getVertices().size() - 1; i++) {
Vertex v0 = ring.getVertices().get(i + 0); Vertex v0 = ring.getVertices().get(i);
Vertex v1 = ring.getVertices().get(i + 1); Vertex v1 = ring.getVertices().get(i + 1);
Edge tempEdge = new Edge(v0, v1); Edge tempEdge = new Edge(v0, v1);
Edge e = duplicacyMap.get(tempEdge); Edge e = duplicacyMap.get(tempEdge);
......
...@@ -22,6 +22,8 @@ import de.hft.stuttgart.citydoctor2.check.Checkable; ...@@ -22,6 +22,8 @@ import de.hft.stuttgart.citydoctor2.check.Checkable;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler; import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable; import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
/** /**
* A general GML element that has a gml id * A general GML element that has a gml id
* *
...@@ -30,6 +32,7 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable; ...@@ -30,6 +32,7 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
*/ */
public abstract class GmlElement extends Checkable implements Copyable { public abstract class GmlElement extends Checkable implements Copyable {
@Serial
private static final long serialVersionUID = -3242505393303017359L; private static final long serialVersionUID = -3242505393303017359L;
private GmlId gmlId; private GmlId gmlId;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
...@@ -30,14 +31,15 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -30,14 +31,15 @@ import java.util.concurrent.atomic.AtomicInteger;
*/ */
public class GmlId implements Serializable { public class GmlId implements Serializable {
@Serial
private static final long serialVersionUID = 4273817255150972966L; private static final long serialVersionUID = 4273817255150972966L;
/* prefixes for generation */ /* prefixes for generation */
private static final String GENERAL_GEN = "CityDoctor_%d_%d"; private static final String GENERAL_GEN = "CityDoctor_%d_%d";
private static final AtomicInteger ID_COUNTER = new AtomicInteger(); private static final AtomicInteger ID_COUNTER = new AtomicInteger();
private String gmlString; private final String gmlString;
private boolean generated; private final boolean generated;
public GmlId(String gmlId) { public GmlId(String gmlId) {
this(gmlId, false); this(gmlId, false);
...@@ -85,14 +87,9 @@ public class GmlId implements Serializable { ...@@ -85,14 +87,9 @@ public class GmlId implements Serializable {
return false; return false;
} }
if (gmlString == null) { if (gmlString == null) {
if (other.gmlString != null) { return other.gmlString == null;
return false; } else return gmlString.equals(other.gmlString);
} }
} else if (!gmlString.equals(other.gmlString)) {
return false;
}
return true;
}
/** /**
* Determines if the GML-ID was generated by CityDoctor or not. * Determines if the GML-ID was generated by CityDoctor or not.
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -41,6 +42,7 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable; ...@@ -41,6 +42,7 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
public class Installation extends CityObject { public class Installation extends CityObject {
@Serial
private static final long serialVersionUID = 1576237433322680191L; private static final long serialVersionUID = 1576237433322680191L;
private List<BoundarySurface> boundarySurfaces = new ArrayList<>(4); private List<BoundarySurface> boundarySurfaces = new ArrayList<>(4);
......
...@@ -29,6 +29,8 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; ...@@ -29,6 +29,8 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils; import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.Copyable; import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
/** /**
* Represents a land use CityGML object. * Represents a land use CityGML object.
* *
...@@ -37,6 +39,7 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable; ...@@ -37,6 +39,7 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
*/ */
public class LandObject extends CityObject { public class LandObject extends CityObject {
@Serial
private static final long serialVersionUID = 1887455662411087326L; private static final long serialVersionUID = 1887455662411087326L;
private LandUse lu; private LandUse lu;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -38,12 +39,13 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable; ...@@ -38,12 +39,13 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
*/ */
public class LinearRing extends GmlElement { public class LinearRing extends GmlElement {
@Serial
private static final long serialVersionUID = -2488180830514940722L; private static final long serialVersionUID = -2488180830514940722L;
private LinearRingType type; private LinearRingType type;
private Polygon parent; private Polygon parent;
private List<Vertex> vertices = new ArrayList<>(); private final List<Vertex> vertices = new ArrayList<>();
public enum LinearRingType { public enum LinearRingType {
EXTERIOR, INTERIOR EXTERIOR, INTERIOR
...@@ -130,7 +132,7 @@ public class LinearRing extends GmlElement { ...@@ -130,7 +132,7 @@ public class LinearRing extends GmlElement {
public Vector3d calculateNormal() { public Vector3d calculateNormal() {
double[] coords = new double[3]; double[] coords = new double[3];
for (int i = 0; i < vertices.size() - 1; i++) { for (int i = 0; i < vertices.size() - 1; i++) {
Vertex current = vertices.get(i + 0); Vertex current = vertices.get(i);
Vertex next = vertices.get(i + 1); Vertex next = vertices.get(i + 1);
coords[0] += (current.getZ() + next.getZ()) * (current.getY() - next.getY()); coords[0] += (current.getZ() + next.getZ()) * (current.getY() - next.getY());
coords[1] += (current.getX() + next.getX()) * (current.getZ() - next.getZ()); coords[1] += (current.getX() + next.getX()) * (current.getZ() - next.getZ());
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -39,6 +40,7 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable; ...@@ -39,6 +40,7 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
*/ */
public class LinkedPolygon extends Polygon { public class LinkedPolygon extends Polygon {
@Serial
private static final long serialVersionUID = -4897578390280277931L; private static final long serialVersionUID = -4897578390280277931L;
private Geometry parent; private Geometry parent;
......
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