Commit 97a65114 authored by Riegel's avatar Riegel
Browse files

Merge branch 'dev' into 'master'

Version 3.15.0

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