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
*
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
......@@ -18,184 +18,191 @@
*/
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.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
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 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, ...
* <br>
* Contains the geometries
*
* @author Matthias Betz
*
* @author Matthias Betz
*/
public abstract class CityObject extends GmlElement {
@Serial
private static final long serialVersionUID = 651712070755024188L;
private final List<Geometry> geometryList = new ArrayList<>();
/**
* Recreates the CityGML4j geometry in this object. The CityGML4j geometry is
* 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
* maps changes to geometry back to CityGML4j
*
* @param factory needed to create CityGML4j data structures
* @param config contains information whether a city doctor point was
* transformed to a different coordinate system. It would need to
* be transformed to the original coordinate system
*/
public abstract void reCreateGeometries(GeometryFactory factory, ParserConfiguration config);
/**
* Getter for the CityGML4j data object
*
* @return the CityGML4j data object
*/
public abstract AbstractCityObject getGmlObject();
/**
* Remove the CityGML4j geometries from the data structure to save memory.
*/
public abstract void unsetGmlGeometries();
public void addGeometry(Geometry geom) {
Objects.requireNonNull(geom);
geometryList.add(geom);
geom.setParent(this);
}
public List<Geometry> getGeometries() {
return geometryList;
}
public void removeGeometry(Lod lod) {
@Serial
private static final long serialVersionUID = 651712070755024188L;
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
* 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
* maps changes to geometry back to CityGML4j
*
* @param factory needed to create CityGML4j data structures
* @param config contains information whether a city doctor point was
* transformed to a different coordinate system. It would need to
* be transformed to the original coordinate system
*/
public abstract void reCreateGeometries(GeometryFactory factory, ParserConfiguration config);
/**
* Getter for the CityGML4j data object
*
* @return the CityGML4j data object
*/
public abstract AbstractCityObject getGmlObject();
/**
* Remove the CityGML4j geometries from the data structure to save memory.
*/
public abstract void unsetGmlGeometries();
public void addGeometry(Geometry geom) {
Objects.requireNonNull(geom);
geometryList.add(geom);
geom.setParent(this);
}
public List<Geometry> getGeometries() {
return geometryList;
}
public void removeGeometry(Lod 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);
}
public Geometry getHighestLodGeometry() {
Geometry highestLodGeometry = null;
Lod highestLod = null;
for (Geometry geom : geometryList) {
if (highestLod == null || geom.getLod().isHigher(highestLod)) {
highestLodGeometry = geom;
highestLod = geom.getLod();
}
}
return highestLodGeometry;
}
public abstract FeatureType getFeatureType();
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (Geometry geom : geometryList) {
geom.accept(c);
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (Geometry geom : geometryList) {
if (geom.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public void clearAllContainedCheckResults() {
super.clearCheckResults();
for (Geometry geom : geometryList) {
geom.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (Geometry geom : geometryList) {
geom.collectContainedErrors(errors);
}
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (Geometry geom : geometryList) {
if (geom.containsAnyError()) {
return true;
}
}
return false;
}
public Geometry getGeometry(GeometryType type, Lod lod) {
for (Geometry geom : geometryList) {
if (geom.getType() == type && geom.getLod() == lod) {
return geom;
}
}
return null;
}
@Override
public void prepareForChecking() {
for (Geometry geom : geometryList) {
geom.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
for (Geometry geom : geometryList) {
geom.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
for (Geometry geom : geometryList) {
handler.addInstance(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));
}
}
}
public Geometry getHighestLodGeometry() {
Geometry highestLodGeometry = null;
Lod highestLod = null;
for (Geometry geom : geometryList) {
if (highestLod == null || geom.getLod().isHigher(highestLod)) {
highestLodGeometry = geom;
highestLod = geom.getLod();
}
}
return highestLodGeometry;
}
public void addGenericAttribute(GenericAttribute genericAttribute) {
genericAttributeList.add(genericAttribute);
}
public List<GenericAttribute> getGenericAttributes() {
return genericAttributeList;
}
public abstract FeatureType getFeatureType();
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (Geometry geom : geometryList) {
geom.accept(c);
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (Geometry geom : geometryList) {
if (geom.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public void clearAllContainedCheckResults() {
super.clearCheckResults();
for (Geometry geom : geometryList) {
geom.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (Geometry geom : geometryList) {
geom.collectContainedErrors(errors);
}
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (Geometry geom : geometryList) {
if (geom.containsAnyError()) {
return true;
}
}
return false;
}
public Geometry getGeometry(GeometryType type, Lod lod) {
for (Geometry geom : geometryList) {
if (geom.getType() == type && geom.getLod() == lod) {
return geom;
}
}
return null;
}
@Override
public void prepareForChecking() {
for (Geometry geom : geometryList) {
geom.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
for (Geometry geom : geometryList) {
geom.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
for (Geometry geom : geometryList) {
handler.addInstance(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 @@
*/
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.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
......@@ -33,6 +28,11 @@ import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* A polygon that actually contains the rings and points representing the
* geometry
......@@ -49,12 +49,11 @@ public class ConcretePolygon extends Polygon {
private List<LinearRing> innerRings;
private BoundarySurface partOfSurface;
private Installation partfOfInstallation;
private CompositeCollection partOfComposite = null;
private Geometry parent;
private LinkedPolygon linkedFromPolygon;
public ConcretePolygon() {
// TODO Auto-generated constructor stub
}
public ConcretePolygon() {}
/*
* (non-Javadoc)
......@@ -138,6 +137,18 @@ public class ConcretePolygon extends Polygon {
parent = geometry;
}
protected void setPartOfComposite(CompositeCollection comp) {
this.partOfComposite = comp;
}
public CompositeCollection getPartOfComposite() {
return partOfComposite;
}
public boolean isCompositeMember() {
return (partOfComposite != null);
}
/*
* (non-Javadoc)
*
......
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
......@@ -20,13 +20,12 @@ package de.hft.stuttgart.citydoctor2.datastructure;
/**
* Possible feature types in CityGML
*
* @author Matthias Betz
*
* @author Matthias Betz
*/
public enum FeatureType {
BUILDING, TRANSPORTATION, VEGETATION, BRIDGE, LAND, WATER, BOUNDARY_SURFACE, INSTALLATION, OPENING,
BUILDING_PART, BRIDGE_CONSTRUCTION_ELEMENT, BRIDGE_INSTALLATION
BUILDING, TRANSPORTATION, VEGETATION, BRIDGE, LAND, WATER, BOUNDARY_SURFACE, INSTALLATION, OPENING,
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