Commit 0f3d9a85 authored by Riegel's avatar Riegel
Browse files

Merge branch 'dev' into 'master'

CityDoctor Release Version 3.16.0

See merge request !11
parents b7b8f5fe b2d40f78
Pipeline #10323 passed with stage
in 1 minute and 25 seconds
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import java.io.Serial;
public class CityFurniture extends CityObject {
@Serial
private static final long serialVersionUID = 3325661061543962473L;
private org.citygml4j.core.model.cityfurniture.CityFurniture cgmlCityFurniture;
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
}
@Override
public AbstractCityObject getGmlObject() {
return cgmlCityFurniture;
}
public void setGmlObject(org.citygml4j.core.model.cityfurniture.CityFurniture gmlCityFurniture) {
cgmlCityFurniture = gmlCityFurniture;
}
@Override
public void unsetGmlGeometries() {
cgmlCityFurniture.setLod0MultiSurface(null);
cgmlCityFurniture.setLod2MultiSurface(null);
cgmlCityFurniture.setLod3MultiSurface(null);
cgmlCityFurniture.setLod1Solid(null);
cgmlCityFurniture.setLod2Solid(null);
cgmlCityFurniture.setLod3Solid(null);
cgmlCityFurniture.getDeprecatedProperties().setLod4Geometry(null);
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms);
} else {
Solid solid = CityGmlUtils.createSolid(geom, factory, config);
setSolidAccordingToLod(geom, solid);
}
}
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
switch (geom.getLod()) {
case LOD0:
cgmlCityFurniture.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
cgmlCityFurniture.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
cgmlCityFurniture.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to buildings");
}
}
private void setSolidAccordingToLod(Geometry geom, Solid solid) {
switch (geom.getLod()) {
case LOD1:
cgmlCityFurniture.setLod1Solid(new SolidProperty(solid));
break;
case LOD2:
cgmlCityFurniture.setLod2Solid(new SolidProperty(solid));
break;
case LOD3:
cgmlCityFurniture.setLod3Solid(new SolidProperty(solid));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to buildings");
}
}
@Override
public FeatureType getFeatureType() {
return FeatureType.CITY_FURNITURE;
}
@Override
public Copyable createCopyInstance() {
return new CityFurniture();
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
CityFurniture originalCF = (CityFurniture) original;
cgmlCityFurniture = originalCF.cgmlCityFurniture;
}
}
/*- /*-
* 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,191 @@ ...@@ -18,184 +18,191 @@
*/ */
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<>();
private final List<GenericAttribute> genericAttributeList = 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() {
return geometryList; public List<Geometry> getGeometries() {
} 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 void addGenericAttribute(GenericAttribute genericAttribute) {
genericAttributeList.add(genericAttribute);
@Override }
public void accept(Check c) {
super.accept(c); public List<GenericAttribute> getGenericAttributes() {
if (c.canExecute(this)) { return genericAttributeList;
c.check(this); }
}
for (Geometry geom : geometryList) { public abstract FeatureType getFeatureType();
geom.accept(c);
} @Override
} public void accept(Check c) {
super.accept(c);
@Override if (c.canExecute(this)) {
public boolean containsError(CheckId checkIdentifier) { c.check(this);
boolean hasError = super.containsError(checkIdentifier); }
if (hasError) { for (Geometry geom : geometryList) {
return true; geom.accept(c);
} }
for (Geometry geom : geometryList) { }
if (geom.containsError(checkIdentifier)) {
return true; @Override
} public boolean containsError(CheckId checkIdentifier) {
} boolean hasError = super.containsError(checkIdentifier);
return false; if (hasError) {
} return true;
}
@Override for (Geometry geom : geometryList) {
public void clearAllContainedCheckResults() { if (geom.containsError(checkIdentifier)) {
super.clearCheckResults(); return true;
for (Geometry geom : geometryList) { }
geom.clearAllContainedCheckResults(); }
} return false;
} }
@Override @Override
public void collectContainedErrors(List<CheckError> errors) { public void clearAllContainedCheckResults() {
super.collectContainedErrors(errors); super.clearCheckResults();
for (Geometry geom : geometryList) { for (Geometry geom : geometryList) {
geom.collectContainedErrors(errors); geom.clearAllContainedCheckResults();
} }
} }
@Override @Override
public boolean containsAnyError() { public void collectContainedErrors(List<CheckError> errors) {
boolean hasError = super.containsAnyError(); super.collectContainedErrors(errors);
if (hasError) { for (Geometry geom : geometryList) {
return true; geom.collectContainedErrors(errors);
} }
for (Geometry geom : geometryList) { }
if (geom.containsAnyError()) {
return true; @Override
} public boolean containsAnyError() {
} boolean hasError = super.containsAnyError();
return false; if (hasError) {
} return true;
}
public Geometry getGeometry(GeometryType type, Lod lod) { for (Geometry geom : geometryList) {
for (Geometry geom : geometryList) { if (geom.containsAnyError()) {
if (geom.getType() == type && geom.getLod() == lod) { return true;
return geom; }
} }
} return false;
return null; }
}
public Geometry getGeometry(GeometryType type, Lod lod) {
@Override for (Geometry geom : geometryList) {
public void prepareForChecking() { if (geom.getType() == type && geom.getLod() == lod) {
for (Geometry geom : geometryList) { return geom;
geom.prepareForChecking(); }
} }
} return null;
}
@Override
public void clearMetaInformation() { @Override
for (Geometry geom : geometryList) { public void prepareForChecking() {
geom.clearMetaInformation(); for (Geometry geom : geometryList) {
} geom.prepareForChecking();
} }
}
@Override
public void collectInstances(CopyHandler handler) { @Override
for (Geometry geom : geometryList) { public void clearMetaInformation() {
handler.addInstance(geom); for (Geometry geom : geometryList) {
} geom.clearMetaInformation();
} }
}
@Override
public void fillValues(Copyable original, CopyHandler handler) { @Override
super.fillValues(original, handler); public void collectInstances(CopyHandler handler) {
CityObject originalCo = (CityObject) original; for (Geometry geom : geometryList) {
for (Geometry geom : originalCo.geometryList) { handler.addInstance(geom);
geometryList.add(handler.getCopyInstance(geom)); }
} }
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
CityObject originalCo = (CityObject) original;
for (Geometry geom : originalCo.geometryList) {
geometryList.add(handler.getCopyInstance(geom));
}
}
} }
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Riegel
*/
public final class CompositeCollection {
@Serial
private static final long serialVersionUID = -1867197873443341287L;
private GmlId gmlId;
private List<ConcretePolygon> compositeMembers = new ArrayList<>();
private List<CompositeCollection> childComposites = new ArrayList<>();
public void addCompositeMember(ConcretePolygon p) {
compositeMembers.add(p);
p.setPartOfComposite(this);
}
public void addAllChildComposites(List<CompositeCollection> children) {
childComposites.addAll(children);
}
public List<CompositeCollection> getChildComposites() {
return childComposites;
}
public List<ConcretePolygon> getCompositeMembers() {
List<ConcretePolygon> copy = new ArrayList<>(compositeMembers);
for (CompositeCollection c : childComposites) {
copy.addAll(c.getCompositeMembers());
}
return copy;
}
public List<ConcretePolygon> getNonRecursiveCompositeMembers() {
return compositeMembers;
}
public void setGmlId(GmlId gmlId) {
this.gmlId = gmlId;
}
public GmlId getGmlId() {
return gmlId;
}
}
...@@ -18,11 +18,6 @@ ...@@ -18,11 +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.Collections;
import java.util.List;
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;
...@@ -33,6 +28,11 @@ import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon; ...@@ -33,6 +28,11 @@ import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler; import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable; import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** /**
* A polygon that actually contains the rings and points representing the * A polygon that actually contains the rings and points representing the
* geometry * geometry
...@@ -49,12 +49,11 @@ public class ConcretePolygon extends Polygon { ...@@ -49,12 +49,11 @@ public class ConcretePolygon extends Polygon {
private List<LinearRing> innerRings; private List<LinearRing> innerRings;
private BoundarySurface partOfSurface; private BoundarySurface partOfSurface;
private Installation partfOfInstallation; private Installation partfOfInstallation;
private CompositeCollection partOfComposite = null;
private Geometry parent; private Geometry parent;
private LinkedPolygon linkedFromPolygon; private LinkedPolygon linkedFromPolygon;
public ConcretePolygon() { public ConcretePolygon() {}
// TODO Auto-generated constructor stub
}
/* /*
* (non-Javadoc) * (non-Javadoc)
...@@ -138,6 +137,18 @@ public class ConcretePolygon extends Polygon { ...@@ -138,6 +137,18 @@ public class ConcretePolygon extends Polygon {
parent = geometry; parent = geometry;
} }
protected void setPartOfComposite(CompositeCollection comp) {
this.partOfComposite = comp;
}
public CompositeCollection getPartOfComposite() {
return partOfComposite;
}
public boolean isCompositeMember() {
return (partOfComposite != null);
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
......
/*- /*-
* 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,13 +20,12 @@ package de.hft.stuttgart.citydoctor2.datastructure; ...@@ -20,13 +20,12 @@ package de.hft.stuttgart.citydoctor2.datastructure;
/** /**
* Possible feature types in CityGML * Possible feature types in CityGML
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public enum FeatureType { public enum FeatureType {
BUILDING, TRANSPORTATION, VEGETATION, BRIDGE, LAND, WATER, BOUNDARY_SURFACE, INSTALLATION, OPENING, BUILDING, TRANSPORTATION, VEGETATION, BRIDGE, LAND, WATER, BOUNDARY_SURFACE, INSTALLATION, OPENING,
BUILDING_PART, BRIDGE_CONSTRUCTION_ELEMENT, BRIDGE_INSTALLATION BUILDING_PART, BUILDING_SUBDIVISION, BRIDGE_CONSTRUCTION_ELEMENT, BRIDGE_INSTALLATION, ROOM, FURNITURE, CITY_FURNITURE,
GENERIC_CITY_OBJECT, TUNNEL, TUNNEL_PART, TUNNEL_CONSTRUCTION_ELEMENT, TUNNEL_INSTALLATION,
} }
package de.hft.stuttgart.citydoctor2.datastructure;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.AbstractGenericAttributeProperty;
import org.citygml4j.core.model.generics.*;
public class GenericAttribute {
private static final Logger logger = LogManager.getLogger(GenericAttribute.class);
private final AbstractGenericAttributeProperty original;
private String type;
private String name;
private String value;
public GenericAttribute(AbstractGenericAttributeProperty attributeProperty) {
original = attributeProperty;
if (attributeProperty.getObject() == null) {
logger.warn("GenericAttribute {} is null", attributeProperty);
return;
}
name = attributeProperty.getObject().getName();
if (attributeProperty.getObject() instanceof StringAttribute sa) {
type = "StringAttribute";
value = sa.getValue();
} else if (attributeProperty.getObject() instanceof IntAttribute ia) {
type = "IntAttribute";
value = ia.getValue().toString();
} else if (attributeProperty.getObject() instanceof DoubleAttribute da) {
type = "DoubleAttribute";
value = da.getValue().toString();
} else if (attributeProperty.getObject() instanceof DateAttribute date) {
type = "DateAttribute";
value = date.getValue().toString();
} else if (attributeProperty.getObject() instanceof UriAttribute ua) {
type = "UriAttribute";
value = ua.getValue();
} else if (attributeProperty.getObject() instanceof MeasureAttribute ma) {
type = "MeasureAttribute";
value = ma.getValue().toString();
} else if (attributeProperty.getObject() instanceof CodeAttribute ca) {
type = "CodeAttribute";
value = ca.getValue().toString();
} else {
logger.warn("GenericAttribute {} is of unknown type {}", attributeProperty, attributeProperty.getObject());
value = attributeProperty.getObject().getValue().toString();
type = "Unknown type";
}
}
public AbstractGenericAttributeProperty getOriginal() {
return original;
}
public String getName() {
return name;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.format("%s: [ %s = %s ]", type, name, value);
}
}
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