Commit 02de0a22 authored by Riegel's avatar Riegel
Browse files

Reformat code

parent ad3589e8
Pipeline #10297 passed with stage
in 1 minute and 5 seconds
...@@ -20,7 +20,7 @@ import java.io.Serial; ...@@ -20,7 +20,7 @@ import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public abstract class AbstractBuildingSubdivision extends CityObject{ public abstract class AbstractBuildingSubdivision extends CityObject {
@Serial @Serial
private static final long serialVersionUID = 7033994252340571002L; private static final long serialVersionUID = 7033994252340571002L;
...@@ -77,7 +77,7 @@ public abstract class AbstractBuildingSubdivision extends CityObject{ ...@@ -77,7 +77,7 @@ public abstract class AbstractBuildingSubdivision extends CityObject{
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder){ if (geom instanceof ImplicitGeometryHolder) {
continue; continue;
} }
if (geom.getType() == GeometryType.MULTI_SURFACE) { if (geom.getType() == GeometryType.MULTI_SURFACE) {
...@@ -285,7 +285,6 @@ public abstract class AbstractBuildingSubdivision extends CityObject{ ...@@ -285,7 +285,6 @@ public abstract class AbstractBuildingSubdivision extends CityObject{
} }
public void setGmlObject(org.citygml4j.core.model.building.AbstractBuildingSubdivision abs) { public void setGmlObject(org.citygml4j.core.model.building.AbstractBuildingSubdivision abs) {
this.abs = abs; this.abs = abs;
} }
......
...@@ -20,7 +20,7 @@ import java.util.List; ...@@ -20,7 +20,7 @@ import java.util.List;
/** /**
* Represents all types of furniture used inside Buildings. * Represents all types of furniture used inside Buildings.
*/ */
public abstract class AbstractFurniture extends CityObject{ public abstract class AbstractFurniture extends CityObject {
@Serial @Serial
private static final long serialVersionUID = -9050689238027190674L; private static final long serialVersionUID = -9050689238027190674L;
...@@ -43,7 +43,7 @@ public abstract class AbstractFurniture extends CityObject{ ...@@ -43,7 +43,7 @@ public abstract class AbstractFurniture extends CityObject{
} }
@Override @Override
public void collectContainedErrors(List<CheckError> errors){ public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors); super.collectContainedErrors(errors);
for (BoundarySurface boundarySurface : boundarySurfaceList) { for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.collectContainedErrors(errors); boundarySurface.collectContainedErrors(errors);
...@@ -51,7 +51,7 @@ public abstract class AbstractFurniture extends CityObject{ ...@@ -51,7 +51,7 @@ public abstract class AbstractFurniture extends CityObject{
} }
@Override @Override
public void clearAllContainedCheckResults(){ public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults(); super.clearAllContainedCheckResults();
for (BoundarySurface boundarySurface : boundarySurfaceList) { for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.clearAllContainedCheckResults(); boundarySurface.clearAllContainedCheckResults();
...@@ -59,13 +59,13 @@ public abstract class AbstractFurniture extends CityObject{ ...@@ -59,13 +59,13 @@ public abstract class AbstractFurniture extends CityObject{
} }
@Override @Override
public boolean containsError(CheckId checkIdentifier){ public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier); boolean hasError = super.containsError(checkIdentifier);
if (hasError){ if (hasError) {
return true; return true;
} }
for (BoundarySurface boundarySurface : boundarySurfaceList) { for (BoundarySurface boundarySurface : boundarySurfaceList) {
if (boundarySurface.containsError(checkIdentifier)){ if (boundarySurface.containsError(checkIdentifier)) {
return true; return true;
} }
} }
...@@ -73,13 +73,13 @@ public abstract class AbstractFurniture extends CityObject{ ...@@ -73,13 +73,13 @@ public abstract class AbstractFurniture extends CityObject{
} }
@Override @Override
public boolean containsAnyError(){ public boolean containsAnyError() {
boolean hasError = super.containsAnyError(); boolean hasError = super.containsAnyError();
if (hasError){ if (hasError) {
return true; return true;
} }
for (BoundarySurface boundarySurface : boundarySurfaceList) { for (BoundarySurface boundarySurface : boundarySurfaceList) {
if (boundarySurface.containsAnyError()){ if (boundarySurface.containsAnyError()) {
return true; return true;
} }
} }
...@@ -87,9 +87,8 @@ public abstract class AbstractFurniture extends CityObject{ ...@@ -87,9 +87,8 @@ public abstract class AbstractFurniture extends CityObject{
} }
@Override @Override
public org.citygml4j.core.model.construction.AbstractFurniture getGmlObject(){ public org.citygml4j.core.model.construction.AbstractFurniture getGmlObject() {
return af; return af;
} }
...@@ -105,7 +104,7 @@ public abstract class AbstractFurniture extends CityObject{ ...@@ -105,7 +104,7 @@ public abstract class AbstractFurniture extends CityObject{
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder){ if (geom instanceof ImplicitGeometryHolder) {
continue; continue;
} }
if (geom.getType() == GeometryType.MULTI_SURFACE) { if (geom.getType() == GeometryType.MULTI_SURFACE) {
...@@ -118,7 +117,7 @@ public abstract class AbstractFurniture extends CityObject{ ...@@ -118,7 +117,7 @@ public abstract class AbstractFurniture extends CityObject{
} }
} }
protected void setGmlObject(org.citygml4j.core.model.construction.AbstractFurniture af){ protected void setGmlObject(org.citygml4j.core.model.construction.AbstractFurniture af) {
this.af = af; this.af = af;
} }
...@@ -171,7 +170,7 @@ public abstract class AbstractFurniture extends CityObject{ ...@@ -171,7 +170,7 @@ public abstract class AbstractFurniture extends CityObject{
@Override @Override
public void prepareForChecking(){ public void prepareForChecking() {
super.prepareForChecking(); super.prepareForChecking();
for (BoundarySurface boundarySurface : boundarySurfaceList) { for (BoundarySurface boundarySurface : boundarySurfaceList) {
boundarySurface.prepareForChecking(); boundarySurface.prepareForChecking();
...@@ -193,7 +192,7 @@ public abstract class AbstractFurniture extends CityObject{ ...@@ -193,7 +192,7 @@ public abstract class AbstractFurniture extends CityObject{
} }
@Override @Override
public void fillValues(Copyable original, CopyHandler handler){ public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler); super.fillValues(original, handler);
AbstractFurniture originalAf = (AbstractFurniture) original; AbstractFurniture originalAf = (AbstractFurniture) original;
af = originalAf.af; af = originalAf.af;
......
...@@ -21,7 +21,7 @@ import java.util.List; ...@@ -21,7 +21,7 @@ import java.util.List;
/** /**
* Abstract base class for rooms inside CityGML 3.0 construction objects. * Abstract base class for rooms inside CityGML 3.0 construction objects.
*/ */
public abstract class AbstractRoom extends CityObject{ public abstract class AbstractRoom extends CityObject {
@Serial @Serial
private static final long serialVersionUID = -1730625513988944329L; private static final long serialVersionUID = -1730625513988944329L;
...@@ -33,9 +33,8 @@ public abstract class AbstractRoom extends CityObject{ ...@@ -33,9 +33,8 @@ public abstract class AbstractRoom extends CityObject{
protected org.citygml4j.core.model.core.AbstractUnoccupiedSpace cgmlRoom; protected org.citygml4j.core.model.core.AbstractUnoccupiedSpace cgmlRoom;
@Override @Override
public void accept(Check c) { public void accept(Check c) {
super.accept(c); super.accept(c);
...@@ -51,7 +50,7 @@ public abstract class AbstractRoom extends CityObject{ ...@@ -51,7 +50,7 @@ public abstract class AbstractRoom extends CityObject{
} }
@Override @Override
public void collectContainedErrors(List<CheckError> errors){ public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors); super.collectContainedErrors(errors);
for (Installation roomInstallation : roomInstallations) { for (Installation roomInstallation : roomInstallations) {
roomInstallation.collectContainedErrors(errors); roomInstallation.collectContainedErrors(errors);
...@@ -62,7 +61,7 @@ public abstract class AbstractRoom extends CityObject{ ...@@ -62,7 +61,7 @@ public abstract class AbstractRoom extends CityObject{
} }
@Override @Override
public void clearAllContainedCheckResults(){ public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults(); super.clearAllContainedCheckResults();
for (Installation roomInstallation : roomInstallations) { for (Installation roomInstallation : roomInstallations) {
roomInstallation.clearAllContainedCheckResults(); roomInstallation.clearAllContainedCheckResults();
...@@ -73,18 +72,18 @@ public abstract class AbstractRoom extends CityObject{ ...@@ -73,18 +72,18 @@ public abstract class AbstractRoom extends CityObject{
} }
@Override @Override
public boolean containsError(CheckId checkIdentifier){ public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier); boolean hasError = super.containsError(checkIdentifier);
if (hasError){ if (hasError) {
return true; return true;
} }
for (Installation roomInstallation : roomInstallations) { for (Installation roomInstallation : roomInstallations) {
if (roomInstallation.containsError(checkIdentifier)){ if (roomInstallation.containsError(checkIdentifier)) {
return true; return true;
} }
} }
for (BoundarySurface boundarySurface : boundarySurfaceList) { for (BoundarySurface boundarySurface : boundarySurfaceList) {
if (boundarySurface.containsError(checkIdentifier)){ if (boundarySurface.containsError(checkIdentifier)) {
return true; return true;
} }
} }
...@@ -92,18 +91,18 @@ public abstract class AbstractRoom extends CityObject{ ...@@ -92,18 +91,18 @@ public abstract class AbstractRoom extends CityObject{
} }
@Override @Override
public boolean containsAnyError(){ public boolean containsAnyError() {
boolean hasError = super.containsAnyError(); boolean hasError = super.containsAnyError();
if (hasError){ if (hasError) {
return true; return true;
} }
for (Installation roomInstallation : roomInstallations) { for (Installation roomInstallation : roomInstallations) {
if (roomInstallation.containsAnyError()){ if (roomInstallation.containsAnyError()) {
return true; return true;
} }
} }
for (BoundarySurface boundarySurface : boundarySurfaceList) { for (BoundarySurface boundarySurface : boundarySurfaceList) {
if (boundarySurface.containsAnyError()){ if (boundarySurface.containsAnyError()) {
return true; return true;
} }
} }
...@@ -113,7 +112,7 @@ public abstract class AbstractRoom extends CityObject{ ...@@ -113,7 +112,7 @@ public abstract class AbstractRoom extends CityObject{
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder){ if (geom instanceof ImplicitGeometryHolder) {
continue; continue;
} }
if (geom.getType() == GeometryType.MULTI_SURFACE) { if (geom.getType() == GeometryType.MULTI_SURFACE) {
...@@ -183,7 +182,7 @@ public abstract class AbstractRoom extends CityObject{ ...@@ -183,7 +182,7 @@ public abstract class AbstractRoom extends CityObject{
} }
@Override @Override
public void prepareForChecking(){ public void prepareForChecking() {
super.prepareForChecking(); super.prepareForChecking();
for (Installation roomInstallation : roomInstallations) { for (Installation roomInstallation : roomInstallations) {
roomInstallation.prepareForChecking(); roomInstallation.prepareForChecking();
...@@ -205,7 +204,6 @@ public abstract class AbstractRoom extends CityObject{ ...@@ -205,7 +204,6 @@ public abstract class AbstractRoom extends CityObject{
} }
@Override @Override
public AbstractCityObject getGmlObject() { public AbstractCityObject getGmlObject() {
return cgmlRoom; return cgmlRoom;
...@@ -232,21 +230,20 @@ public abstract class AbstractRoom extends CityObject{ ...@@ -232,21 +230,20 @@ public abstract class AbstractRoom extends CityObject{
} }
@Override @Override
public FeatureType getFeatureType() { public FeatureType getFeatureType() {
return FeatureType.ROOM; return FeatureType.ROOM;
} }
@Override @Override
public void collectInstances(CopyHandler handler){ public void collectInstances(CopyHandler handler) {
super.collectInstances(handler); super.collectInstances(handler);
handler.addInstance(roomInstallations); handler.addInstance(roomInstallations);
handler.addInstance(boundarySurfaceList); handler.addInstance(boundarySurfaceList);
} }
@Override @Override
public void fillValues(Copyable original, CopyHandler handler){ public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler); super.fillValues(original, handler);
AbstractRoom originalAr = (AbstractRoom) original; AbstractRoom originalAr = (AbstractRoom) original;
for (BoundarySurface originalBs : originalAr.boundarySurfaceList) { for (BoundarySurface originalBs : originalAr.boundarySurfaceList) {
......
...@@ -20,7 +20,7 @@ import java.io.Serial; ...@@ -20,7 +20,7 @@ import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public abstract class AbstractTunnel extends CityObject{ public abstract class AbstractTunnel extends CityObject {
@Serial @Serial
private static final long serialVersionUID = -2196414503088741206L; private static final long serialVersionUID = -2196414503088741206L;
...@@ -84,7 +84,7 @@ public abstract class AbstractTunnel extends CityObject{ ...@@ -84,7 +84,7 @@ public abstract class AbstractTunnel extends CityObject{
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder){ if (geom instanceof ImplicitGeometryHolder) {
continue; continue;
} }
if (geom.getType() == GeometryType.MULTI_SURFACE) { if (geom.getType() == GeometryType.MULTI_SURFACE) {
......
/*- /*-
* 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,15 +18,6 @@ ...@@ -18,15 +18,6 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
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.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError; import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId; import de.hft.stuttgart.citydoctor2.check.CheckId;
...@@ -34,255 +25,262 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; ...@@ -34,255 +25,262 @@ 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.CopyHandler; import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable; import de.hft.stuttgart.citydoctor2.utils.Copyable;
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 java.io.Serial;
import java.util.ArrayList;
import java.util.List;
/** /**
* Representing a boundary surface in CityGML * Representing a boundary surface in CityGML
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public class BoundarySurface extends CityObject { public class BoundarySurface extends CityObject {
@Serial @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 final 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;
public BoundarySurface(AbstractThematicSurface aco) { public BoundarySurface(AbstractThematicSurface aco) {
this(SurfaceFeatureType.BUILDING, BoundarySurfaceType.UNDEFINED, aco); this(SurfaceFeatureType.BUILDING, BoundarySurfaceType.UNDEFINED, aco);
} }
public BoundarySurface(SurfaceFeatureType featureType, BoundarySurfaceType type, AbstractThematicSurface aco) { public BoundarySurface(SurfaceFeatureType featureType, BoundarySurfaceType type, AbstractThematicSurface aco) {
this.featureType = featureType; this.featureType = featureType;
this.type = type; this.type = type;
gmlObject = aco; gmlObject = aco;
} }
public void setFeatureType(SurfaceFeatureType featureType) { public void setFeatureType(SurfaceFeatureType featureType) {
this.featureType = featureType; this.featureType = featureType;
} }
public void setType(BoundarySurfaceType type) { public void setType(BoundarySurfaceType type) {
this.type = type; this.type = type;
} }
public void setGmlObject(AbstractThematicSurface gmlObject) { public void setGmlObject(AbstractThematicSurface gmlObject) {
this.gmlObject = gmlObject; this.gmlObject = gmlObject;
} }
public SurfaceFeatureType getSurfaceFeatureType() { public SurfaceFeatureType getSurfaceFeatureType() {
return featureType; return featureType;
} }
public BoundarySurfaceType getType() { public BoundarySurfaceType getType() {
return type; return type;
} }
public List<Opening> getOpenings() { public List<Opening> getOpenings() {
return openings; return openings;
} }
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
if (gmlObject.getId() == null) { if (gmlObject.getId() == null) {
gmlObject.setId(getGmlId().getGmlString()); gmlObject.setId(getGmlId().getGmlString());
} }
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder){ if (geom instanceof ImplicitGeometryHolder) {
continue; continue;
} }
if (geom.getType() == GeometryType.MULTI_SURFACE) { if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config); MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
if (ms != null) { if (ms != null) {
setGeometryAccordingToLod(geom.getLod(), new MultiSurfaceProperty(ms)); setGeometryAccordingToLod(geom.getLod(), new MultiSurfaceProperty(ms));
} }
} else { } else {
throw new IllegalStateException("BoundarySurfaces can only have MultiSurface geometries"); throw new IllegalStateException("BoundarySurfaces can only have MultiSurface geometries");
} }
} }
for (Opening o : openings) { for (Opening o : openings) {
o.reCreateGeometries(factory, config); o.reCreateGeometries(factory, config);
} }
} }
private void setGeometryAccordingToLod(Lod lod, MultiSurfaceProperty ms) { private void setGeometryAccordingToLod(Lod lod, MultiSurfaceProperty ms) {
switch (lod) { switch (lod) {
case LOD0: case LOD0:
gmlObject.setLod0MultiSurface(ms); gmlObject.setLod0MultiSurface(ms);
break; break;
case LOD1: case LOD1:
gmlObject.setLod1MultiSurface(ms); gmlObject.setLod1MultiSurface(ms);
break; break;
case LOD2: case LOD2:
gmlObject.setLod2MultiSurface(ms); gmlObject.setLod2MultiSurface(ms);
break; break;
case LOD3: case LOD3:
gmlObject.setLod3MultiSurface(ms); gmlObject.setLod3MultiSurface(ms);
break; break;
case LOD4: case LOD4:
gmlObject.getDeprecatedProperties().setLod4MultiSurface(ms); gmlObject.getDeprecatedProperties().setLod4MultiSurface(ms);
break; break;
default: default:
throw new IllegalStateException("Found geometry with LOD other than LOD1-4, which is illegal for BoundarySurfaces: " + lod); throw new IllegalStateException("Found geometry with LOD other than LOD1-4, which is illegal for BoundarySurfaces: " + lod);
} }
} }
@Override @Override
public void clearAllContainedCheckResults() { public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults(); super.clearAllContainedCheckResults();
for (Opening o : openings) { for (Opening o : openings) {
o.clearAllContainedCheckResults(); o.clearAllContainedCheckResults();
} }
} }
@Override @Override
public void collectContainedErrors(List<CheckError> errors) { public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors); super.collectContainedErrors(errors);
for (Opening o : openings) { for (Opening o : openings) {
o.collectContainedErrors(errors); o.collectContainedErrors(errors);
} }
} }
@Override @Override
public boolean containsAnyError() { public boolean containsAnyError() {
boolean hasError = super.containsAnyError(); boolean hasError = super.containsAnyError();
if (hasError) { if (hasError) {
return true; return true;
} }
for (Opening o : openings) { for (Opening o : openings) {
if (o.containsAnyError()) { if (o.containsAnyError()) {
return true; return true;
} }
} }
return false; return false;
} }
@Override @Override
public boolean containsError(CheckId checkIdentifier) { public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier); boolean hasError = super.containsError(checkIdentifier);
if (hasError) { if (hasError) {
return true; return true;
} }
for (Opening o : openings) { for (Opening o : openings) {
if (o.containsError(checkIdentifier)) { if (o.containsError(checkIdentifier)) {
return true; return true;
} }
} }
return false; return false;
} }
@Override @Override
public void accept(Check c) { public void accept(Check c) {
super.accept(c); super.accept(c);
if (c.canExecute(this)) { if (c.canExecute(this)) {
c.check(this); c.check(this);
} }
for (Opening o : openings) { for (Opening o : openings) {
o.accept(c); o.accept(c);
} }
} }
public void setParent(CityObject parent) { public void setParent(CityObject parent) {
this.parent = parent; this.parent = parent;
} }
public CityObject getParent() { public CityObject getParent() {
return parent; return parent;
} }
@Override @Override
public void unsetGmlGeometries() { public void unsetGmlGeometries() {
gmlObject.setLod0MultiSurface(null); gmlObject.setLod0MultiSurface(null);
gmlObject.setLod1MultiSurface(null); gmlObject.setLod1MultiSurface(null);
gmlObject.setLod2MultiSurface(null); gmlObject.setLod2MultiSurface(null);
gmlObject.setLod3MultiSurface(null); gmlObject.setLod3MultiSurface(null);
gmlObject.getDeprecatedProperties().setLod4MultiSurface(null); gmlObject.getDeprecatedProperties().setLod4MultiSurface(null);
for (Opening o : openings) { for (Opening o : openings) {
o.unsetGmlGeometries(); o.unsetGmlGeometries();
} }
} }
@Override @Override
public String toString() { public String toString() {
return "BoundarySurface [type=" + type + ", id=" + getGmlId() + "]"; return "BoundarySurface [type=" + type + ", id=" + getGmlId() + "]";
} }
void anonymize() { void anonymize() {
gmlObject.setAppearances(null); gmlObject.setAppearances(null);
gmlObject.setBoundedBy(null); gmlObject.setBoundedBy(null);
gmlObject.setCreationDate(null); gmlObject.setCreationDate(null);
gmlObject.setDescription(null); gmlObject.setDescription(null);
gmlObject.setExternalReferences(null); gmlObject.setExternalReferences(null);
gmlObject.setGeneralizesTo(null); gmlObject.setGeneralizesTo(null);
gmlObject.setADEProperties(null); gmlObject.setADEProperties(null);
gmlObject.setGenericAttributes(null); gmlObject.setGenericAttributes(null);
setGmlId(GmlId.generateId()); setGmlId(GmlId.generateId());
gmlObject.setId(getGmlId().getGmlString()); gmlObject.setId(getGmlId().getGmlString());
} }
@Override @Override
public AbstractThematicSurface getGmlObject() { public AbstractThematicSurface getGmlObject() {
return gmlObject; return gmlObject;
} }
@Override @Override
public FeatureType getFeatureType() { public FeatureType getFeatureType() {
return FeatureType.BOUNDARY_SURFACE; return FeatureType.BOUNDARY_SURFACE;
} }
public void addOpening(Opening opening) { public void addOpening(Opening opening) {
openings.add(opening); openings.add(opening);
opening.setPartOfSurface(this); opening.setPartOfSurface(this);
} }
@Override @Override
public void prepareForChecking() { public void prepareForChecking() {
super.prepareForChecking(); super.prepareForChecking();
for (Opening o : openings) { for (Opening o : openings) {
o.prepareForChecking(); o.prepareForChecking();
} }
} }
@Override @Override
public void clearMetaInformation() { public void clearMetaInformation() {
super.clearMetaInformation(); super.clearMetaInformation();
for (Opening o : openings) { for (Opening o : openings) {
o.clearMetaInformation(); o.clearMetaInformation();
} }
} }
@Override @Override
public Copyable createCopyInstance() { public Copyable createCopyInstance() {
return new BoundarySurface(gmlObject); return new BoundarySurface(gmlObject);
} }
@Override @Override
public void collectInstances(CopyHandler handler) { public void collectInstances(CopyHandler handler) {
super.collectInstances(handler); super.collectInstances(handler);
for (Opening o : openings) { for (Opening o : openings) {
handler.addInstance(o); handler.addInstance(o);
} }
handler.addInstance(parent); handler.addInstance(parent);
} }
@Override @Override
public void fillValues(Copyable original, CopyHandler handler) { public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler); super.fillValues(original, handler);
BoundarySurface originalBs = (BoundarySurface) original; BoundarySurface originalBs = (BoundarySurface) original;
featureType = originalBs.featureType; featureType = originalBs.featureType;
type = originalBs.type; type = originalBs.type;
for (Opening originalOpening : originalBs.openings) { for (Opening originalOpening : originalBs.openings) {
openings.add(handler.getCopyInstance(originalOpening)); openings.add(handler.getCopyInstance(originalOpening));
} }
parent = handler.getCopyInstance(originalBs.parent); parent = handler.getCopyInstance(originalBs.parent);
gmlObject = originalBs.gmlObject; gmlObject = originalBs.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
...@@ -20,12 +20,11 @@ package de.hft.stuttgart.citydoctor2.datastructure; ...@@ -20,12 +20,11 @@ package de.hft.stuttgart.citydoctor2.datastructure;
/** /**
* Types of boundary surfaces used in city doctor * Types of boundary surfaces used in city doctor
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public enum BoundarySurfaceType { public enum BoundarySurfaceType {
UNDEFINED, ROOF, WALL, GROUND, CLOSURE, OUTER_FLOOR, OUTER_CEILING, CEILING, INTERIOR_WALL, FLOOR UNDEFINED, ROOF, WALL, GROUND, CLOSURE, OUTER_FLOOR, OUTER_CEILING, CEILING, INTERIOR_WALL, FLOOR
} }
/*- /*-
* 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,148 +18,147 @@ ...@@ -18,148 +18,147 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.util.Collection;
import java.util.List;
import de.hft.stuttgart.citydoctor2.math.Vector3d; import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.utils.BoundingBoxCalculator; import de.hft.stuttgart.citydoctor2.utils.BoundingBoxCalculator;
import java.util.Collection;
import java.util.List;
/** /**
* An axis aligned bounding box represented by its two corners * An axis aligned bounding box represented by its two corners
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public class BoundingBox { public class BoundingBox {
private final 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
* *
* @param polygons containing the points from which the box will be created * @param polygons containing the points from which the box will be created
* @return the bounding box around all points * @return the bounding box around all points
*/ */
public static BoundingBox of(Collection<? extends Polygon> polygons) { public static BoundingBox of(Collection<? extends Polygon> polygons) {
return BoundingBoxCalculator.calculateBoundingBox(polygons); return BoundingBoxCalculator.calculateBoundingBox(polygons);
} }
public static BoundingBox ofPoints(List<? extends Vector3d> points) { public static BoundingBox ofPoints(List<? extends Vector3d> points) {
return BoundingBoxCalculator.calculateBoundingBoxFromPoints(points); return BoundingBoxCalculator.calculateBoundingBoxFromPoints(points);
} }
/** /**
* Creates an axis aligned bounding box of the whole model. * Creates an axis aligned bounding box of the whole model.
* *
* @param model the model containing the features with geometries used for the * @param model the model containing the features with geometries used for the
* bounding box * bounding box
* @return the bounding box around all features * @return the bounding box around all features
*/ */
public static BoundingBox of(CityDoctorModel model) { public static BoundingBox of(CityDoctorModel model) {
return BoundingBoxCalculator.calculateBoundingBox(model); return BoundingBoxCalculator.calculateBoundingBox(model);
} }
/** /**
* Creates a new bounding box with two vectors as corner points. * Creates a new bounding box with two vectors as corner points.
* *
* @param box the array of length 2 containing both corners * @param box the array of length 2 containing both corners
* @return the new bounding box * @return the new bounding box
*/ */
public static BoundingBox of(Vector3d[] box) { public static BoundingBox of(Vector3d[] box) {
return new BoundingBox(box); return new BoundingBox(box);
} }
private BoundingBox(Vector3d[] bbox) { private BoundingBox(Vector3d[] bbox) {
if (bbox == null || bbox.length != 2) { if (bbox == null || bbox.length != 2) {
throw new IllegalArgumentException("BoundingBox must be an array of the length 2"); throw new IllegalArgumentException("BoundingBox must be an array of the length 2");
} }
this.bbox = bbox; this.bbox = bbox;
} }
/** /**
* Calculates the volume of the box * Calculates the volume of the box
* *
* @return the volume of the box * @return the volume of the box
*/ */
public double getVolume() { public double getVolume() {
double length = getDepth(); double length = getDepth();
double width = getWidth(); double width = getWidth();
double height = getHeight(); double height = getHeight();
return height * width * length; return height * width * length;
} }
/** /**
* Calculates the center of the bounding box * Calculates the center of the bounding box
* *
* @return the center of the bounding box * @return the center of the bounding box
*/ */
public Vector3d getCenter() { public Vector3d getCenter() {
return bbox[0].plus(bbox[1].minus(bbox[0]).mult(0.5)); return bbox[0].plus(bbox[1].minus(bbox[0]).mult(0.5));
} }
/** /**
* Getter for the corner array * Getter for the corner array
* *
* @return the array containing the corner points * @return the array containing the corner points
*/ */
public Vector3d[] getBox() { public Vector3d[] getBox() {
return bbox; return bbox;
} }
/** /**
* Calculates the width of the bounding box * Calculates the width of the bounding box
* *
* @return the width of the bounding box * @return the width of the bounding box
*/ */
public double getWidth() { public double getWidth() {
return bbox[1].getY() - bbox[0].getY(); return bbox[1].getY() - bbox[0].getY();
} }
/** /**
* Calculates the height of the bounding box * Calculates the height of the bounding box
* *
* @return the height of the bounding box * @return the height of the bounding box
*/ */
public double getHeight() { public double getHeight() {
return bbox[1].getZ() - bbox[0].getZ(); return bbox[1].getZ() - bbox[0].getZ();
} }
/** /**
* Calculates the depth of the bounding box * Calculates the depth of the bounding box
* *
* @return the depth of the bounding box * @return the depth of the bounding box
*/ */
public double getDepth() { public double getDepth() {
return bbox[1].getX() - bbox[0].getX(); return bbox[1].getX() - bbox[0].getX();
} }
/** /**
* Returns the length of the longest side of the bounding box, ignoring the * Returns the length of the longest side of the bounding box, ignoring the
* height. Only X and Y axis are considered * height. Only X and Y axis are considered
* *
* @return the length of the longest side in X or Y direction * @return the length of the longest side in X or Y direction
*/ */
public double getLongestSide() { public double getLongestSide() {
double width = getWidth(); double width = getWidth();
double depth = getDepth(); double depth = getDepth();
return Math.max(width, depth); return Math.max(width, depth);
} }
/** /**
* Calculates the direction vector from the lower corner to the upper corner * Calculates the direction vector from the lower corner to the upper corner
* *
* @return the direction vector from the lower corner to the upper corner * @return the direction vector from the lower corner to the upper corner
*/ */
public Vector3d getDiagonal() { public Vector3d getDiagonal() {
return bbox[1].minus(bbox[0]); return bbox[1].minus(bbox[0]);
} }
/** /**
* Calculates the distance between the corner points * Calculates the distance between the corner points
* *
* @return the distance between the corner points * @return the distance between the corner points
*/ */
public double getDiagonalLength() { public double getDiagonalLength() {
return bbox[1].getDistance(bbox[0]); return bbox[1].getDistance(bbox[0]);
} }
} }
/*- /*-
* Copyright 2022 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2022 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,10 +18,13 @@ ...@@ -18,10 +18,13 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial; import de.hft.stuttgart.citydoctor2.check.Check;
import java.util.ArrayList; import de.hft.stuttgart.citydoctor2.check.CheckError;
import java.util.List; 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.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty; import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
...@@ -34,260 +37,256 @@ import org.xmlobjects.gml.model.geometry.complexes.CompositeSurface; ...@@ -34,260 +37,256 @@ import org.xmlobjects.gml.model.geometry.complexes.CompositeSurface;
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;
public class BridgeConstructiveElement extends CityObject { public class BridgeConstructiveElement extends CityObject {
private static final Logger logger = LogManager.getLogger(BridgeConstructiveElement.class);
private static final String CANNOT_ADD = "Cannot add "; private static final Logger logger = LogManager.getLogger(BridgeConstructiveElement.class);
private static final String CANNOT_ADD = "Cannot add ";
@Serial
private static final long serialVersionUID = 7353233899458901155L;
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) {
this.gmlBridgeElement = gmlObject;
}
@Override
public Copyable createCopyInstance() {
return new BridgeConstructiveElement(gmlBridgeElement);
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
// only handles CityGML2 for now
// unknown which CityGML is handled here
// need context information to decide
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
switch (geom.getType()) {
case SOLID:
Solid solid = CityGmlUtils.createSolid(geom, factory, config);
setSolidAccordingToLod(geom, solid);
break;
case MULTI_SURFACE:
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms);
break;
case COMPOSITE_SURFACE:
CompositeSurface cs = CityGmlUtils.createCompositeSurface(geom, factory, config);
setCompositeSurfaceAccordingToLod(geom, cs);
break;
}
}
for (BoundarySurface bs : boundarySurfaceList) {
reCreateBoundarySurface(factory, config, bs);
}
}
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.accept(c);
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (BoundarySurface bs : boundarySurfaceList) {
bs.collectContainedErrors(errors);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearAllContainedCheckResults();
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.containsAnyError()) {
return true;
}
}
return false;
}
private void reCreateBoundarySurface(GeometryFactory factory, ParserConfiguration config, BoundarySurface bs) {
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : gmlBridgeElement.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from BridgeConstructiveElement", bs.getGmlId());
gmlBridgeElement.getBoundaries().remove(bsp);
break;
}
}
return;
}
bs.reCreateGeometries(factory, config);
}
@Serial private void setCompositeSurfaceAccordingToLod(Geometry geom, CompositeSurface cs) {
private static final long serialVersionUID = 7353233899458901155L; switch (geom.getLod()) {
case LOD1:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new GeometryProperty<>(cs));
break;
case LOD2:
gmlBridgeElement.getDeprecatedProperties().setLod2Geometry(new GeometryProperty<>(cs));
break;
case LOD3:
gmlBridgeElement.getDeprecatedProperties().setLod3Geometry(new GeometryProperty<>(cs));
break;
case LOD4:
gmlBridgeElement.getDeprecatedProperties().setLod4Geometry(new GeometryProperty<>(cs));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " composite surface to buildings");
}
}
private final org.citygml4j.core.model.bridge.BridgeConstructiveElement gmlBridgeElement; private void setSolidAccordingToLod(Geometry geom, Solid solid) {
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>(); switch (geom.getLod()) {
case LOD1:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new SolidProperty(solid));
break;
case LOD2:
gmlBridgeElement.getDeprecatedProperties().setLod2Geometry(new SolidProperty(solid));
break;
case LOD3:
gmlBridgeElement.getDeprecatedProperties().setLod3Geometry(new SolidProperty(solid));
break;
case LOD4:
gmlBridgeElement.getDeprecatedProperties().setLod4Geometry(new SolidProperty(solid));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " solid to buildings");
}
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) {
case LOD0:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD1:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD2:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD3:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD4:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " multi surface to buildings");
}
}
public BridgeConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement gmlObject) { @Override
this.gmlBridgeElement = gmlObject; public org.citygml4j.core.model.bridge.BridgeConstructiveElement getGmlObject() {
} return gmlBridgeElement;
}
@Override @Override
public Copyable createCopyInstance() { public void unsetGmlGeometries() {
return new BridgeConstructiveElement(gmlBridgeElement); gmlBridgeElement.setLod0MultiSurface(null);
} gmlBridgeElement.setLod2MultiSurface(null);
gmlBridgeElement.setLod3MultiSurface(null);
DeprecatedPropertiesOfBridgeConstructiveElement depProps = gmlBridgeElement.getDeprecatedProperties();
depProps.setLod1Geometry(null);
depProps.setLod2Geometry(null);
depProps.setLod3Geometry(null);
depProps.setLod4Geometry(null);
gmlBridgeElement.setLod1Solid(null);
gmlBridgeElement.setLod2Solid(null);
gmlBridgeElement.setLod3Solid(null);
for (BoundarySurface bs : boundarySurfaceList) {
bs.unsetGmlGeometries();
}
}
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public FeatureType getFeatureType() {
// only handles CityGML2 for now return FeatureType.BRIDGE_CONSTRUCTION_ELEMENT;
// unknown which CityGML is handled here }
// need context information to decide
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder){
continue;
}
switch (geom.getType()) {
case SOLID:
Solid solid = CityGmlUtils.createSolid(geom, factory, config);
setSolidAccordingToLod(geom, solid);
break;
case MULTI_SURFACE:
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms);
break;
case COMPOSITE_SURFACE:
CompositeSurface cs = CityGmlUtils.createCompositeSurface(geom, factory, config);
setCompositeSurfaceAccordingToLod(geom, cs);
break;
}
}
for (BoundarySurface bs : boundarySurfaceList) {
reCreateBoundarySurface(factory, config, bs);
}
}
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.accept(c);
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (BoundarySurface bs : boundarySurfaceList) {
bs.collectContainedErrors(errors);
}
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearAllContainedCheckResults();
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (BoundarySurface bs : boundarySurfaceList) {
if (bs.containsAnyError()) {
return true;
}
}
return false;
}
private void reCreateBoundarySurface(GeometryFactory factory, ParserConfiguration config, BoundarySurface bs) {
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : gmlBridgeElement.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
logger.warn("Found empty boundary surface: {}, removing from BridgeConstructiveElement", bs.getGmlId());
gmlBridgeElement.getBoundaries().remove(bsp);
break;
}
}
return;
}
bs.reCreateGeometries(factory, config);
}
private void setCompositeSurfaceAccordingToLod(Geometry geom, CompositeSurface cs) { public void addBoundarySurface(BoundarySurface bs) {
switch (geom.getLod()) { boundarySurfaceList.add(bs);
case LOD1: bs.setParent(this);
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new GeometryProperty<>(cs)); }
break;
case LOD2:
gmlBridgeElement.getDeprecatedProperties().setLod2Geometry(new GeometryProperty<>(cs));
break;
case LOD3:
gmlBridgeElement.getDeprecatedProperties().setLod3Geometry(new GeometryProperty<>(cs));
break;
case LOD4:
gmlBridgeElement.getDeprecatedProperties().setLod4Geometry(new GeometryProperty<>(cs));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " composite surface to buildings");
}
}
private void setSolidAccordingToLod(Geometry geom, Solid solid) { public List<BoundarySurface> getBoundarySurfaces() {
switch (geom.getLod()) { return boundarySurfaceList;
case LOD1: }
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new SolidProperty(solid));
break;
case LOD2:
gmlBridgeElement.getDeprecatedProperties().setLod2Geometry(new SolidProperty(solid));
break;
case LOD3:
gmlBridgeElement.getDeprecatedProperties().setLod3Geometry(new SolidProperty(solid));
break;
case LOD4:
gmlBridgeElement.getDeprecatedProperties().setLod4Geometry(new SolidProperty(solid));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " solid to buildings");
}
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) {
case LOD0:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD1:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD2:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD3:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD4:
gmlBridgeElement.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException(CANNOT_ADD + geom.getLod() + " multi surface to buildings");
}
}
@Override @Override
public org.citygml4j.core.model.bridge.BridgeConstructiveElement getGmlObject() { public void prepareForChecking() {
return gmlBridgeElement; super.prepareForChecking();
} for (BoundarySurface bs : boundarySurfaceList) {
bs.prepareForChecking();
}
}
@Override @Override
public void unsetGmlGeometries() { public void clearMetaInformation() {
gmlBridgeElement.setLod0MultiSurface(null); super.clearMetaInformation();
gmlBridgeElement.setLod2MultiSurface(null); for (BoundarySurface bs : boundarySurfaceList) {
gmlBridgeElement.setLod3MultiSurface(null); bs.clearMetaInformation();
DeprecatedPropertiesOfBridgeConstructiveElement depProps = gmlBridgeElement.getDeprecatedProperties(); }
depProps.setLod1Geometry(null); }
depProps.setLod2Geometry(null);
depProps.setLod3Geometry(null);
depProps.setLod4Geometry(null);
gmlBridgeElement.setLod1Solid(null);
gmlBridgeElement.setLod2Solid(null);
gmlBridgeElement.setLod3Solid(null);
for (BoundarySurface bs : boundarySurfaceList) {
bs.unsetGmlGeometries();
}
}
@Override @Override
public FeatureType getFeatureType() { public void collectInstances(CopyHandler handler) {
return FeatureType.BRIDGE_CONSTRUCTION_ELEMENT; super.collectInstances(handler);
} handler.addInstance(boundarySurfaceList);
}
public void addBoundarySurface(BoundarySurface bs) { @Override
boundarySurfaceList.add(bs); public void fillValues(Copyable original, CopyHandler handler) {
bs.setParent(this); super.fillValues(original, handler);
} BridgeConstructiveElement originalBce = (BridgeConstructiveElement) original;
for (BoundarySurface originalBs : originalBce.boundarySurfaceList) {
public List<BoundarySurface> getBoundarySurfaces() { boundarySurfaceList.add(handler.getCopyInstance(originalBs));
return boundarySurfaceList; }
} }
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (BoundarySurface bs : boundarySurfaceList) {
bs.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(boundarySurfaceList);
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
BridgeConstructiveElement originalBce = (BridgeConstructiveElement) original;
for (BoundarySurface originalBs : originalBce.boundarySurfaceList) {
boundarySurfaceList.add(handler.getCopyInstance(originalBs));
}
}
} }
...@@ -55,6 +55,7 @@ public class BridgeObject extends CityObject { ...@@ -55,6 +55,7 @@ public class BridgeObject extends CityObject {
private final List<BridgeRoom> bridgeRooms = new ArrayList<>(2); private final List<BridgeRoom> bridgeRooms = new ArrayList<>(2);
private AbstractBridge ab; private AbstractBridge ab;
private BridgeType type; private BridgeType type;
public BridgeObject(BridgeType type, AbstractBridge ab) { public BridgeObject(BridgeType type, AbstractBridge ab) {
this.ab = ab; this.ab = ab;
this.type = type; this.type = type;
...@@ -80,7 +81,7 @@ public class BridgeObject extends CityObject { ...@@ -80,7 +81,7 @@ public class BridgeObject extends CityObject {
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder){ if (geom instanceof ImplicitGeometryHolder) {
continue; continue;
} }
if (geom.getType() == GeometryType.MULTI_SURFACE) { if (geom.getType() == GeometryType.MULTI_SURFACE) {
...@@ -146,6 +147,7 @@ public class BridgeObject extends CityObject { ...@@ -146,6 +147,7 @@ public class BridgeObject extends CityObject {
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to bridges"); throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to bridges");
} }
} }
public void addBridgeInstallation(Installation coBi) { public void addBridgeInstallation(Installation coBi) {
bridgeInstallations.add(coBi); bridgeInstallations.add(coBi);
coBi.setParent(this); coBi.setParent(this);
......
...@@ -12,7 +12,8 @@ public class BridgeRoom extends AbstractRoom { ...@@ -12,7 +12,8 @@ public class BridgeRoom extends AbstractRoom {
private BridgeObject parent; private BridgeObject parent;
private BridgeRoom(){} private BridgeRoom() {
}
public BridgeRoom(BridgeObject parent) { public BridgeRoom(BridgeObject parent) {
this.parent = parent; this.parent = parent;
...@@ -20,7 +21,7 @@ public class BridgeRoom extends AbstractRoom { ...@@ -20,7 +21,7 @@ public class BridgeRoom extends AbstractRoom {
} }
public void setGmlObject(org.citygml4j.core.model.bridge.BridgeRoom cgmlRoom){ public void setGmlObject(org.citygml4j.core.model.bridge.BridgeRoom cgmlRoom) {
super.cgmlRoom = cgmlRoom; super.cgmlRoom = cgmlRoom;
} }
...@@ -30,14 +31,14 @@ public class BridgeRoom extends AbstractRoom { ...@@ -30,14 +31,14 @@ public class BridgeRoom extends AbstractRoom {
} }
@Override @Override
public void fillValues(Copyable original, CopyHandler handler){ public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler); super.fillValues(original, handler);
BridgeRoom oRoom = (BridgeRoom) original; BridgeRoom oRoom = (BridgeRoom) original;
parent = handler.getCopyInstance(oRoom.getParent()); parent = handler.getCopyInstance(oRoom.getParent());
} }
@Override @Override
public void collectInstances(CopyHandler handler){ public void collectInstances(CopyHandler handler) {
super.collectInstances(handler); super.collectInstances(handler);
handler.addInstance(parent); handler.addInstance(parent);
} }
......
...@@ -15,7 +15,7 @@ public class BridgeRoomFurniture extends AbstractFurniture { ...@@ -15,7 +15,7 @@ public class BridgeRoomFurniture extends AbstractFurniture {
} }
@Override @Override
public Copyable createCopyInstance(){ public Copyable createCopyInstance() {
return new BridgeRoomFurniture(); return new BridgeRoomFurniture();
} }
} }
/*- /*-
* 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,158 +18,157 @@ ...@@ -18,158 +18,157 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
import org.citygml4j.core.model.building.BuildingInstallation;
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.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError; import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId; import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
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 org.citygml4j.core.model.building.BuildingInstallation;
import org.citygml4j.core.model.building.BuildingInstallationProperty;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.util.geometry.GeometryFactory;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class Building extends AbstractBuilding { public class Building extends AbstractBuilding {
@Serial @Serial
private static final long serialVersionUID = 588480113268630052L; private static final long serialVersionUID = 588480113268630052L;
private final 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;
} }
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config); super.reCreateGeometries(factory, config);
for (BuildingPart bp : buildingParts) { for (BuildingPart bp : buildingParts) {
bp.reCreateGeometries(factory, config); bp.reCreateGeometries(factory, config);
} }
} }
@Override @Override
public void accept(Check c) { public void accept(Check c) {
super.accept(c); super.accept(c);
if (c.canExecute(this)) { if (c.canExecute(this)) {
c.check(this); c.check(this);
} }
for (BuildingPart bp : buildingParts) { for (BuildingPart bp : buildingParts) {
bp.accept(c); bp.accept(c);
} }
} }
@Override @Override
public void clearAllContainedCheckResults() { public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults(); super.clearAllContainedCheckResults();
for (BuildingPart bp : buildingParts) { for (BuildingPart bp : buildingParts) {
bp.clearAllContainedCheckResults(); bp.clearAllContainedCheckResults();
} }
} }
@Override @Override
public void collectContainedErrors(List<CheckError> errors) { public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors); super.collectContainedErrors(errors);
for (BuildingPart bp : buildingParts) { for (BuildingPart bp : buildingParts) {
bp.collectContainedErrors(errors); bp.collectContainedErrors(errors);
} }
} }
@Override @Override
public boolean containsAnyError() { public boolean containsAnyError() {
boolean hasError = super.containsAnyError(); boolean hasError = super.containsAnyError();
if (hasError) { if (hasError) {
return true; return true;
} }
for (BuildingPart bp : buildingParts) { for (BuildingPart bp : buildingParts) {
if (bp.containsAnyError()) { if (bp.containsAnyError()) {
return true; return true;
} }
} }
return false; return false;
} }
@Override @Override
public boolean containsError(CheckId checkIdentifier) { public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier); boolean hasError = super.containsError(checkIdentifier);
if (hasError) { if (hasError) {
return true; return true;
} }
for (BuildingPart bp : buildingParts) { for (BuildingPart bp : buildingParts) {
if (bp.containsError(checkIdentifier)) { if (bp.containsError(checkIdentifier)) {
return true; return true;
} }
} }
return false; return false;
} }
public void addBuildingPart(BuildingPart buildingPart) { public void addBuildingPart(BuildingPart buildingPart) {
buildingParts.add(buildingPart); buildingParts.add(buildingPart);
} }
@Override @Override
public String toString() { public String toString() {
return "Building [id=" + getGmlId() + "]"; return "Building [id=" + getGmlId() + "]";
} }
public void anonymize() { public void anonymize() {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
geom.anonymize(); geom.anonymize();
} }
org.citygml4j.core.model.building.Building gmlB = new org.citygml4j.core.model.building.Building(); org.citygml4j.core.model.building.Building gmlB = new org.citygml4j.core.model.building.Building();
gmlB.setId(GmlId.generateId().getGmlString()); gmlB.setId(GmlId.generateId().getGmlString());
for (Installation bi : getBuildingInstallations()) { for (Installation bi : getBuildingInstallations()) {
bi.anonymize(); bi.anonymize();
gmlB.getBuildingInstallations().add(new BuildingInstallationProperty((BuildingInstallation) bi.getGmlObject())); gmlB.getBuildingInstallations().add(new BuildingInstallationProperty((BuildingInstallation) bi.getGmlObject()));
} }
for (BoundarySurface bs : getBoundarySurfaces()) { for (BoundarySurface bs : getBoundarySurfaces()) {
bs.anonymize(); bs.anonymize();
gmlB.addBoundary(new AbstractSpaceBoundaryProperty(bs.getGmlObject())); gmlB.addBoundary(new AbstractSpaceBoundaryProperty(bs.getGmlObject()));
} }
setCityGmlBuilding(gmlB); setCityGmlBuilding(gmlB);
} }
@Override @Override
public void clearMetaInformation() { public void clearMetaInformation() {
super.clearMetaInformation(); super.clearMetaInformation();
for (BuildingPart part : buildingParts) { for (BuildingPart part : buildingParts) {
part.clearMetaInformation(); part.clearMetaInformation();
} }
} }
@Override @Override
public void prepareForChecking() { public void prepareForChecking() {
super.prepareForChecking(); super.prepareForChecking();
for (BuildingPart part : buildingParts) { for (BuildingPart part : buildingParts) {
part.prepareForChecking(); part.prepareForChecking();
} }
} }
@Override @Override
public void fillValues(Copyable original, CopyHandler handler) { public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler); super.fillValues(original, handler);
Building originalBuilding = (Building) original; Building originalBuilding = (Building) original;
for (BuildingPart originalBp : originalBuilding.buildingParts) { for (BuildingPart originalBp : originalBuilding.buildingParts) {
buildingParts.add(handler.getCopyInstance(originalBp)); buildingParts.add(handler.getCopyInstance(originalBp));
} }
} }
@Override @Override
public void collectInstances(CopyHandler handler) { public void collectInstances(CopyHandler handler) {
super.collectInstances(handler); super.collectInstances(handler);
for (BuildingPart bp : buildingParts) { for (BuildingPart bp : buildingParts) {
handler.addInstance(bp); handler.addInstance(bp);
} }
} }
@Override @Override
public Copyable createCopyInstance() { public Copyable createCopyInstance() {
return new Building(); return new Building();
} }
} }
/*- /*-
* 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
...@@ -24,50 +24,50 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable; ...@@ -24,50 +24,50 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial; import java.io.Serial;
public class BuildingPart extends AbstractBuilding { public class BuildingPart extends AbstractBuilding {
@Serial
private static final long serialVersionUID = 8200322261958679163L;
private Building parent;
private BuildingPart() {
}
public BuildingPart(Building parent) {
this.parent = parent;
parent.addBuildingPart(this);
}
public Building getParent() {
return parent;
}
@Override
public FeatureType getFeatureType() {
return FeatureType.BUILDING_PART;
}
@Override @Serial
public String toString() { private static final long serialVersionUID = 8200322261958679163L;
return "BuildingPart [id=" + getGmlId() + "]";
} private Building parent;
@Override private BuildingPart() {
public void fillValues(Copyable original, CopyHandler handler) { }
super.fillValues(original, handler);
BuildingPart originalPart = (BuildingPart) original; public BuildingPart(Building parent) {
parent = handler.getCopyInstance(originalPart.parent); this.parent = parent;
} parent.addBuildingPart(this);
}
@Override
public void collectInstances(CopyHandler handler) { public Building getParent() {
super.collectInstances(handler); return parent;
handler.addInstance(parent); }
}
@Override
public FeatureType getFeatureType() {
return FeatureType.BUILDING_PART;
}
@Override
public String toString() {
return "BuildingPart [id=" + getGmlId() + "]";
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
BuildingPart originalPart = (BuildingPart) original;
parent = handler.getCopyInstance(originalPart.parent);
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(parent);
}
@Override @Override
public Copyable createCopyInstance() { public Copyable createCopyInstance() {
return new BuildingPart(); return new BuildingPart();
} }
} }
...@@ -8,19 +8,19 @@ import java.io.Serial; ...@@ -8,19 +8,19 @@ import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class BuildingRoom extends AbstractRoom{ public class BuildingRoom extends AbstractRoom {
@Serial @Serial
private static final long serialVersionUID = -276088332165299253L; private static final long serialVersionUID = -276088332165299253L;
private final List<BuildingFurnitureProperty> furnitureRefs = new ArrayList<>(2); private final List<BuildingFurnitureProperty> furnitureRefs = new ArrayList<>(2);
private CityObject parent; private CityObject parent;
public void setGmlObject(org.citygml4j.core.model.building.BuildingRoom cgmlRoom){ public void setGmlObject(org.citygml4j.core.model.building.BuildingRoom cgmlRoom) {
super.cgmlRoom = cgmlRoom; super.cgmlRoom = cgmlRoom;
} }
public void setParent(CityObject parent){ public void setParent(CityObject parent) {
this.parent = parent; this.parent = parent;
} }
...@@ -31,6 +31,7 @@ public class BuildingRoom extends AbstractRoom{ ...@@ -31,6 +31,7 @@ public class BuildingRoom extends AbstractRoom{
/** /**
* Returns the list of citygml3 furniture objects registered to this room. * Returns the list of citygml3 furniture objects registered to this room.
* The reference objects only hold a HRef to the actual furniture object. * The reference objects only hold a HRef to the actual furniture object.
*
* @return * @return
*/ */
public List<BuildingFurnitureProperty> getFurnitureRefs() { public List<BuildingFurnitureProperty> getFurnitureRefs() {
...@@ -42,7 +43,7 @@ public class BuildingRoom extends AbstractRoom{ ...@@ -42,7 +43,7 @@ public class BuildingRoom extends AbstractRoom{
} }
@Override @Override
public void fillValues(Copyable original, CopyHandler handler){ public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler); super.fillValues(original, handler);
BuildingRoom oRoom = (BuildingRoom) original; BuildingRoom oRoom = (BuildingRoom) original;
...@@ -50,7 +51,7 @@ public class BuildingRoom extends AbstractRoom{ ...@@ -50,7 +51,7 @@ public class BuildingRoom extends AbstractRoom{
} }
@Override @Override
public void collectInstances(CopyHandler handler){ public void collectInstances(CopyHandler handler) {
super.collectInstances(handler); super.collectInstances(handler);
handler.addInstance(parent); handler.addInstance(parent);
} }
......
...@@ -16,7 +16,7 @@ public class BuildingRoomFurniture extends AbstractFurniture { ...@@ -16,7 +16,7 @@ public class BuildingRoomFurniture extends AbstractFurniture {
} }
@Override @Override
public Copyable createCopyInstance(){ public Copyable createCopyInstance() {
return new BuildingRoomFurniture(); return new BuildingRoomFurniture();
} }
......
...@@ -12,7 +12,7 @@ import java.io.Serial; ...@@ -12,7 +12,7 @@ import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class BuildingUnit extends AbstractBuildingSubdivision{ public class BuildingUnit extends AbstractBuildingSubdivision {
@Serial @Serial
private static final long serialVersionUID = -2931788311665810322L; private static final long serialVersionUID = -2931788311665810322L;
......
...@@ -14,7 +14,7 @@ import org.xmlobjects.gml.model.geometry.primitives.SolidProperty; ...@@ -14,7 +14,7 @@ import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import java.io.Serial; import java.io.Serial;
public class CityFurniture extends CityObject{ public class CityFurniture extends CityObject {
@Serial @Serial
private static final long serialVersionUID = 3325661061543962473L; private static final long serialVersionUID = 3325661061543962473L;
...@@ -53,7 +53,7 @@ public class CityFurniture extends CityObject{ ...@@ -53,7 +53,7 @@ public class CityFurniture extends CityObject{
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder){ if (geom instanceof ImplicitGeometryHolder) {
continue; continue;
} }
if (geom.getType() == GeometryType.MULTI_SURFACE) { if (geom.getType() == GeometryType.MULTI_SURFACE) {
......
/*- /*-
* 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,184 +18,182 @@ ...@@ -18,184 +18,182 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
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.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError; import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId; import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
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 org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.util.geometry.GeometryFactory;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/** /**
* Abstract class for general features such as Buildings, Water objects, ... * Abstract class for general features such as Buildings, Water objects, ...
* <br> * <br>
* Contains the geometries * Contains the geometries
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public abstract class CityObject extends GmlElement { public abstract class CityObject extends GmlElement {
@Serial @Serial
private static final long serialVersionUID = 651712070755024188L; private static final long serialVersionUID = 651712070755024188L;
private final 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
* deleted from the data structure as was mapped to the city doctor data * deleted from the data structure as was mapped to the city doctor data
* structure. For writing CityGML files the geometry has to be restored. Also * structure. For writing CityGML files the geometry has to be restored. Also
* maps changes to geometry back to CityGML4j * maps changes to geometry back to CityGML4j
* *
* @param factory needed to create CityGML4j data structures * @param factory needed to create CityGML4j data structures
* @param config contains information whether a city doctor point was * @param config contains information whether a city doctor point was
* transformed to a different coordinate system. It would need to * transformed to a different coordinate system. It would need to
* be transformed to the original coordinate system * be transformed to the original coordinate system
*/ */
public abstract void reCreateGeometries(GeometryFactory factory, ParserConfiguration config); public abstract void reCreateGeometries(GeometryFactory factory, ParserConfiguration config);
/** /**
* Getter for the CityGML4j data object * Getter for the CityGML4j data object
* *
* @return the CityGML4j data object * @return the CityGML4j data object
*/ */
public abstract AbstractCityObject getGmlObject(); 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(); public abstract void unsetGmlGeometries();
public void addGeometry(Geometry geom) { public void addGeometry(Geometry geom) {
Objects.requireNonNull(geom); Objects.requireNonNull(geom);
geometryList.add(geom); geometryList.add(geom);
geom.setParent(this); geom.setParent(this);
} }
public List<Geometry> getGeometries() { public List<Geometry> getGeometries() {
return geometryList; return geometryList;
} }
public void removeGeometry(Lod lod) { public void removeGeometry(Lod lod) {
geometryList.removeIf(geom -> geom.getLod() == lod); geometryList.removeIf(geom -> geom.getLod() == lod);
} }
public void removeGeometry(Lod lod, GeometryType type) { public void removeGeometry(Lod lod, GeometryType type) {
geometryList.removeIf(geom -> geom.getLod() == lod && geom.getType() == type); geometryList.removeIf(geom -> geom.getLod() == lod && geom.getType() == type);
} }
public Geometry getHighestLodGeometry() { public Geometry getHighestLodGeometry() {
Geometry highestLodGeometry = null; Geometry highestLodGeometry = null;
Lod highestLod = null; Lod highestLod = null;
for (Geometry geom : geometryList) { for (Geometry geom : geometryList) {
if (highestLod == null || geom.getLod().isHigher(highestLod)) { if (highestLod == null || geom.getLod().isHigher(highestLod)) {
highestLodGeometry = geom; highestLodGeometry = geom;
highestLod = geom.getLod(); highestLod = geom.getLod();
} }
} }
return highestLodGeometry; return highestLodGeometry;
} }
public abstract FeatureType getFeatureType(); public abstract FeatureType getFeatureType();
@Override @Override
public void accept(Check c) { public void accept(Check c) {
super.accept(c); super.accept(c);
if (c.canExecute(this)) { if (c.canExecute(this)) {
c.check(this); c.check(this);
} }
for (Geometry geom : geometryList) { for (Geometry geom : geometryList) {
geom.accept(c); geom.accept(c);
} }
} }
@Override @Override
public boolean containsError(CheckId checkIdentifier) { public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier); boolean hasError = super.containsError(checkIdentifier);
if (hasError) { if (hasError) {
return true; return true;
} }
for (Geometry geom : geometryList) { for (Geometry geom : geometryList) {
if (geom.containsError(checkIdentifier)) { if (geom.containsError(checkIdentifier)) {
return true; return true;
} }
} }
return false; return false;
} }
@Override @Override
public void clearAllContainedCheckResults() { public void clearAllContainedCheckResults() {
super.clearCheckResults(); super.clearCheckResults();
for (Geometry geom : geometryList) { for (Geometry geom : geometryList) {
geom.clearAllContainedCheckResults(); geom.clearAllContainedCheckResults();
} }
} }
@Override @Override
public void collectContainedErrors(List<CheckError> errors) { public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors); super.collectContainedErrors(errors);
for (Geometry geom : geometryList) { for (Geometry geom : geometryList) {
geom.collectContainedErrors(errors); geom.collectContainedErrors(errors);
} }
} }
@Override @Override
public boolean containsAnyError() { public boolean containsAnyError() {
boolean hasError = super.containsAnyError(); boolean hasError = super.containsAnyError();
if (hasError) { if (hasError) {
return true; return true;
} }
for (Geometry geom : geometryList) { for (Geometry geom : geometryList) {
if (geom.containsAnyError()) { if (geom.containsAnyError()) {
return true; return true;
} }
} }
return false; return false;
} }
public Geometry getGeometry(GeometryType type, Lod lod) { public Geometry getGeometry(GeometryType type, Lod lod) {
for (Geometry geom : geometryList) { for (Geometry geom : geometryList) {
if (geom.getType() == type && geom.getLod() == lod) { if (geom.getType() == type && geom.getLod() == lod) {
return geom; return geom;
} }
} }
return null; return null;
} }
@Override @Override
public void prepareForChecking() { public void prepareForChecking() {
for (Geometry geom : geometryList) { for (Geometry geom : geometryList) {
geom.prepareForChecking(); geom.prepareForChecking();
} }
} }
@Override @Override
public void clearMetaInformation() { public void clearMetaInformation() {
for (Geometry geom : geometryList) { for (Geometry geom : geometryList) {
geom.clearMetaInformation(); geom.clearMetaInformation();
} }
} }
@Override @Override
public void collectInstances(CopyHandler handler) { public void collectInstances(CopyHandler handler) {
for (Geometry geom : geometryList) { for (Geometry geom : geometryList) {
handler.addInstance(geom); handler.addInstance(geom);
} }
} }
@Override @Override
public void fillValues(Copyable original, CopyHandler handler) { public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler); super.fillValues(original, handler);
CityObject originalCo = (CityObject) original; CityObject originalCo = (CityObject) original;
for (Geometry geom : originalCo.geometryList) { for (Geometry geom : originalCo.geometryList) {
geometryList.add(handler.getCopyInstance(geom)); geometryList.add(handler.getCopyInstance(geom));
} }
} }
} }
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