Commit 3dac795e authored by Riegel's avatar Riegel
Browse files

Merge branch 'dev' into 'master'

Version 3.17.0 Release

See merge request !28
1 merge request!28Version 3.17.0 Release
Pipeline #11012 passed with stage
in 1 minute and 10 seconds
Showing with 207 additions and 64 deletions
+207 -64
......@@ -52,6 +52,11 @@ public class Building extends AbstractBuilding {
}
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
@Override
public void accept(Check c) {
super.accept(c);
......
......@@ -42,6 +42,11 @@ public class BuildingPart extends AbstractBuilding {
return parent;
}
@Override
public CityObject getTopLevelCityObject() {
return getParent().getTopLevelCityObject();
}
@Override
public FeatureType getFeatureType() {
return FeatureType.BUILDING_PART;
......
......@@ -50,6 +50,11 @@ public class BuildingRoom extends AbstractRoom {
parent = handler.getCopyInstance(oRoom.getParent());
}
@Override
public CityObject getTopLevelCityObject() {
return getParent().getTopLevelCityObject();
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
......
......@@ -126,4 +126,8 @@ public class BuildingUnit extends AbstractBuildingSubdivision {
}
this.abs = originalBu.abs;
}
public List<Storey> getStoreys() {
return storeys;
}
}
......@@ -50,6 +50,11 @@ public class CityFurniture extends CityObject {
cgmlCityFurniture.getDeprecatedProperties().setLod4Geometry(null);
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
......@@ -71,12 +76,18 @@ public class CityFurniture extends CityObject {
case LOD0:
cgmlCityFurniture.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD1:
cgmlCityFurniture.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD2:
cgmlCityFurniture.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
cgmlCityFurniture.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
cgmlCityFurniture.getDeprecatedProperties().setLod4Geometry(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to buildings");
}
......@@ -93,6 +104,8 @@ public class CityFurniture extends CityObject {
case LOD3:
cgmlCityFurniture.setLod3Solid(new SolidProperty(solid));
break;
case LOD4:
cgmlCityFurniture.getDeprecatedProperties().setLod4Geometry(new SolidProperty(solid));
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to buildings");
}
......
......@@ -102,6 +102,11 @@ public abstract class CityObject extends GmlElement {
return highestLodGeometry;
}
/**
* Returns the top-level CityObject (like Building or Tunnel) belonging to this object.
*/
public abstract CityObject getTopLevelCityObject();
public void addGenericAttribute(GenericAttribute genericAttribute) {
genericAttributeList.add(genericAttribute);
}
......
......@@ -2,6 +2,7 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
......@@ -9,7 +10,7 @@ import java.util.List;
*
* @author Riegel
*/
public final class CompositeCollection {
public final class CompositeCollection implements Serializable {
@Serial
private static final long serialVersionUID = -1867197873443341287L;
......@@ -31,6 +32,7 @@ public final class CompositeCollection {
return childComposites;
}
//TODO stream
public List<ConcretePolygon> getCompositeMembers() {
List<ConcretePolygon> copy = new ArrayList<>(compositeMembers);
for (CompositeCollection c : childComposites) {
......
......@@ -50,6 +50,7 @@ public class ConcretePolygon extends Polygon {
private BoundarySurface partOfSurface;
private Installation partfOfInstallation;
private CompositeCollection partOfComposite = null;
private PatchCollection partOfPatch = null;
private Geometry parent;
private LinkedPolygon linkedFromPolygon;
......@@ -141,6 +142,18 @@ public class ConcretePolygon extends Polygon {
this.partOfComposite = comp;
}
protected void setPartOfPatch(PatchCollection pc) {
this.partOfPatch = pc;
}
public PatchCollection getPartOfPatch(PatchCollection pc) {
return partOfPatch;
}
public boolean isPatchMember() {
return partOfPatch != null;
}
public CompositeCollection getPartOfComposite() {
return partOfComposite;
}
......
......@@ -26,7 +26,7 @@ public class GenericAttribute {
if (attributeProperty.getObject() instanceof StringAttribute sa) {
type = "StringAttribute";
value = sa.getValue();
value = String.format("\"%s\"", sa.getValue());
} else if (attributeProperty.getObject() instanceof IntAttribute ia) {
type = "IntAttribute";
value = ia.getValue().toString();
......@@ -41,10 +41,10 @@ public class GenericAttribute {
value = ua.getValue();
} else if (attributeProperty.getObject() instanceof MeasureAttribute ma) {
type = "MeasureAttribute";
value = ma.getValue().toString();
value = String.format("%s %s", ma.getValue().getValue().toString(), ma.getValue().getUom());
} else if (attributeProperty.getObject() instanceof CodeAttribute ca) {
type = "CodeAttribute";
value = ca.getValue().toString();
type = String.format("CodeAttribute (%s)", ca.getValue().getLanguage());
value = String.format("'''%s''' %n CodeSpace: %s", ca.getValue().getValue(), ca.getValue().getCodeSpace());
} else {
logger.warn("GenericAttribute {} is of unknown type {}", attributeProperty, attributeProperty.getObject());
value = attributeProperty.getObject().getValue().toString();
......
......@@ -84,14 +84,20 @@ public class GenericCityObject extends CityObject {
case LOD0:
cgmlGos.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD1:
cgmlGos.getDeprecatedProperties().setLod1Geometry(new MultiSurfaceProperty(ms));
break;
case LOD2:
cgmlGos.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
cgmlGos.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
cgmlGos.getDeprecatedProperties().setLod4Geometry(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to buildings");
throw new IllegalStateException("Cannot add " + geom.getLod() + " multi surface to generic city object");
}
}
......@@ -106,6 +112,9 @@ public class GenericCityObject extends CityObject {
case LOD3:
cgmlGos.setLod3Solid(new SolidProperty(solid));
break;
case LOD4:
cgmlGos.getDeprecatedProperties().setLod4Geometry(new SolidProperty(solid));
break;
default:
throw new IllegalStateException("Cannot add " + geom.getLod() + " solid to buildings");
}
......@@ -213,6 +222,11 @@ public class GenericCityObject extends CityObject {
}
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
public void setGmlObject(org.citygml4j.core.model.generics.GenericOccupiedSpace gos) {
this.cgmlGos = gos;
}
......
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.List;
import org.citygml4j.core.model.core.ImplicitGeometry;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.math.TransformationMatrix;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.ImplicitGeometry;
import java.io.Serial;
import java.util.List;
/**
* Datastructure for representation and resolving of implicit geometries
......@@ -18,7 +17,6 @@ import java.util.List;
*/
public class ImplicitGeometryHolder extends Geometry {
private static final Logger logger = LogManager.getLogger(ImplicitGeometryHolder.class);
@Serial
private static final long serialVersionUID = -8938931081577196349L;
......
......@@ -195,6 +195,11 @@ public class Installation extends CityObject {
}
}
@Override
public CityObject getTopLevelCityObject() {
return getParent().getTopLevelCityObject();
}
private void removeGeometriesFromBridgeInstallation(BridgeInstallation localBi) {
localBi.getDeprecatedProperties().setLod2Geometry(null);
localBi.getDeprecatedProperties().setLod3Geometry(null);
......
......@@ -105,6 +105,11 @@ public class LandObject extends CityObject {
lu.getDeprecatedProperties().setLod4MultiSurface(null);
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
public void setGmlObject(LandUse landUse) {
lu = landUse;
}
......
......@@ -4,28 +4,30 @@ import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParser;
import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.Serial;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Reference object for handling of implicit geometries with a library object contained in an external file
* Reference object for handling of implicit geometries with a library object
* contained in an external file
*
* @author Riegel
*/
public class LibraryObject extends Geometry {
private static final Logger logger = LogManager.getLogger(LibraryObject.class);
@Serial
private static final long serialVersionUID = -50293435187454911L;
private final String filepath;
private final ParserConfiguration config;
private static Map<String, LibraryObject> libraryObjects = new ConcurrentHashMap<>();
private static final Logger logger = LogManager.getLogger(LibraryObject.class);
@Serial
private static final long serialVersionUID = -50293435187454911L;
private static Map<String, LibraryObject> libraryObjects = new ConcurrentHashMap<>();
public static LibraryObject of(Path path, ParserConfiguration config) {
if (libraryObjects.containsKey(path.toString())) {
......@@ -35,42 +37,45 @@ public class LibraryObject extends Geometry {
if (protoGeom == null) {
return null;
}
LibraryObject libOb = new LibraryObject(protoGeom.getType(), protoGeom.getLod(), path, config);
LibraryObject libOb = new LibraryObject(protoGeom.getType(), protoGeom.getLod());
protoGeom.getPolygons().forEach(libOb::addPolygon);
libOb.updateEdgesAndVertices();
libraryObjects.put(path.toString(), libOb);
return libOb;
}
private LibraryObject(GeometryType type, Lod lod, Path path, ParserConfiguration config) {
public static LibraryObject of(CityGmlZipEntry entry, ParserConfiguration config) {
String fileName = entry.getEntrySubPath();
if (libraryObjects.containsKey(fileName)){
return libraryObjects.get(fileName);
}
Geometry protoGeom = parseZipEntry(entry, config);
if (protoGeom == null) {
return null;
}
LibraryObject libOb = new LibraryObject(protoGeom.getType(), protoGeom.getLod());
protoGeom.getPolygons().forEach(libOb::addPolygon);
libOb.updateEdgesAndVertices();
libraryObjects.put(fileName, libOb);
return libOb;
}
private LibraryObject(GeometryType type, Lod lod) {
super(type, lod);
this.filepath = path.toString();
this.config = config;
}
private static Geometry parseFile(Path path, ParserConfiguration config) {
Geometry geo = null;
if (path.toFile().exists()) {
if (Files.exists(path)) {
try {
CityGmlParser.gagLogger(true);
CityDoctorModel model = CityGmlParser.parseCityGmlFile(path.toString(), config);
List<CityObject> objects = model.createFeatureStream().toList();
if (objects.isEmpty()) {
throw new InvalidGmlFileException("Referenced library-object's gml file does not contain a CityGML object!");
} else if (objects.size() > 1) {
throw new InvalidGmlFileException("Referenced library-object's gml file contains more than one CityGML object!");
}
geo = objects.get(0).getHighestLodGeometry();
geo = getProtoGeometry(CityGmlParser.parseCityGmlFileSilently(path.toString(), config));
} catch (CityGmlParseException e) {
logger.error(String.format(
"Encountered an error while parsing library object %s", path));
logger.error(e.getStackTrace());
} catch (InvalidGmlFileException e) {
logger.error(e.getStackTrace());
} finally {
// Failsafe to remove gag should parsing fail
CityGmlParser.gagLogger(false);
}
} else {
logger.error(String.format("Implicit geometry references non-existing library object file %s.", path));
......@@ -78,4 +83,32 @@ public class LibraryObject extends Geometry {
return geo;
}
private static Geometry parseZipEntry(CityGmlZipEntry entry, ParserConfiguration config) {
Geometry geo = null;
try {
entry.loadEntry(config);
geo = getProtoGeometry(entry.getModel());
} catch (InvalidGmlFileException e) {
logger.error(e.getStackTrace());
} catch (CityGmlParseException e) {
logger.error(String.format(
"Encountered an error while parsing library object %s", entry.getEntrySubPath()));
logger.error(e.getStackTrace());
}
return geo;
}
private static Geometry getProtoGeometry(CityDoctorModel model) throws InvalidGmlFileException, CityGmlParseException {
if (model == null) {
throw new CityGmlParseException("CityDoctorModel of referenced LibraryObject is null");
}
List<CityObject> objects = model.createFeatureStream().toList();
if (objects.isEmpty()) {
throw new InvalidGmlFileException("Referenced library-object gml file does not contain any CityGML objects!");
} else if (objects.size() > 1) {
throw new InvalidGmlFileException("Referenced library-object gml file contains more than one CityGML object!");
}
return objects.get(0).getHighestLodGeometry();
}
}
......@@ -135,6 +135,11 @@ public class Opening extends CityObject {
ao.getDeprecatedProperties().setLod4MultiSurface(null);
}
@Override
public CityObject getTopLevelCityObject() {
return partOf.getTopLevelCityObject();
}
@Override
public String toString() {
return "Opening [type=" + type + ", id=" + getGmlId() + "]";
......
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public final class PatchCollection implements Serializable {
@Serial
private static final long serialVersionUID = -1748657379840997228L;
private List<ConcretePolygon> patchMembers = new ArrayList<>();
public void addPatchMember(ConcretePolygon patchMember) {
patchMembers.add(patchMember);
patchMember.setPartOfPatch(this);
}
public List<ConcretePolygon> getPatchMembers() {
return new ArrayList<>(patchMembers);
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.Serial;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
......@@ -15,27 +11,23 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class RelativeGeometry extends Geometry {
private static final Logger logger = LogManager.getLogger(RelativeGeometry.class);
@Serial
private static final long serialVersionUID = -686112245455298977L;
private static Map<Geometry, RelativeGeometry> relativeGeometries = new ConcurrentHashMap<>();
public static RelativeGeometry of(Geometry geom) {
if (relativeGeometries.containsKey(geom)) {
return relativeGeometries.get(geom);
}
RelativeGeometry relGeo = new RelativeGeometry(geom.getType(), geom.getLod());
geom.getPolygons().forEach(relGeo::addPolygon);
relGeo.updateEdgesAndVertices();
relativeGeometries.put(geom, relGeo);
return relGeo;
}
private RelativeGeometry(GeometryType type, Lod lod) {
super(type, lod);
}
@Serial
private static final long serialVersionUID = -686112245455298977L;
private static Map<Geometry, RelativeGeometry> relativeGeometries = new ConcurrentHashMap<>();
public static RelativeGeometry of(Geometry geom) {
if (relativeGeometries.containsKey(geom)) {
return relativeGeometries.get(geom);
}
RelativeGeometry relGeo = new RelativeGeometry(geom.getType(), geom.getLod());
geom.getPolygons().forEach(relGeo::addPolygon);
relGeo.updateEdgesAndVertices();
relativeGeometries.put(geom, relGeo);
return relGeo;
}
private RelativeGeometry(GeometryType type, Lod lod) {
super(type, lod);
}
}
......@@ -146,6 +146,11 @@ public class ReliefObject extends CityObject {
// no geometries
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
@Override
public FeatureType getFeatureType() {
return FeatureType.LAND;
......
......@@ -125,4 +125,8 @@ public class Storey extends AbstractBuildingSubdivision {
}
this.abs = originalSt.abs;
}
public List<BuildingUnit> getBuildingUnits() {
return buildingUnits;
}
}
......@@ -91,6 +91,11 @@ public class TinObject extends CityObject {
gmlRelief.setTin(null);
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
@Override
public FeatureType getFeatureType() {
return FeatureType.LAND;
......
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