Commit 5d1a9009 authored by Riegel's avatar Riegel
Browse files

Rework CompositeSurface parsing

parent d0226244
Pipeline #10304 passed with stage
in 1 minute and 9 seconds
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;
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
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.check.Checkable;
import de.hft.stuttgart.citydoctor2.math.Triangle3d;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
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;
/**
* Pseudo-abstract polygon class for parsing and resolving of CompositeSurfaces and references to them.
* <p>CompositePolygons have no exterior or interior LinearRings themselves and need to be filtered out from
* the polygons of a CityObject geometry before further processing steps.
*
* @author Riegel
*/
public final class CompositePolygon extends ConcretePolygon {
@Serial
private static final long serialVersionUID = -1867197873443341287L;
private Geometry parent;
private BoundarySurface partOfSurface;
private Installation partOfInstallation;
private List<ConcretePolygon> compositeMembers = new ArrayList<>();
@Override
public Vector3d calculateNormalNormalized() {
return null;
}
@Override
public void accept(Check c) {
}
@Override
public Class<? extends Checkable> getCheckClass() {
return Polygon.class;
}
@Override
public boolean containsAnyError() {
return false;
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
}
@Override
public void clearAllContainedCheckResults() {
}
public void addCompositeMember(ConcretePolygon p) {
compositeMembers.add(p);
p.setPartOfComposite(this);
}
public List<ConcretePolygon> getCompositeMembers() {
return compositeMembers;
}
@Override
public boolean containsError(CheckId checkIdentifier) {
return false;
}
@Override
public Vector3d calculateNormal() {
return compositeMembers.get(0).calculateNormal();
}
@Override
public TesselatedPolygon tesselate() {
List<Triangle3d> tessPolys = new ArrayList<>();
return new TesselatedPolygon(tessPolys, this);
}
@Override
public LinearRing getExteriorRing() {
return new LinearRing(LinearRing.LinearRingType.EXTERIOR);
}
@Override
public List<LinearRing> getInnerRings() {
return Collections.emptyList();
}
@Override
public boolean isPointInsideExteriorRing(Vector3d v) {
return false;
}
@Override
public Geometry getParent() {
return parent;
}
@Override
public void setParent(Geometry geometry) {
this.parent = geometry;
}
@Override
public void setExteriorRing(LinearRing extRing) {
// ConcretePolygons' exterior ring is not settable
}
@Override
public boolean isPolygonConnectedViaPoint(Polygon other) {
return false;
}
@Override
public void addInteriorRing(LinearRing inter) {
// ConcretePolygons have no interior ring themselves
}
@Override
public BoundarySurface getPartOfSurface() {
return partOfSurface;
}
@Override
public void setPartOfSurface(BoundarySurface bs) {
this.partOfSurface = bs;
}
@Override
public void removeInnerRing(LinearRing ring) {
}
@Override
public void setPartOfInstallation(Installation bi) {
this.partOfInstallation = bi;
}
@Override
public Installation getPartOfInstallation() {
return partOfInstallation;
}
@Override
public boolean hasPointAsCorner(Vertex v) {
return false;
}
@Override
public void removeRings() {
}
@Override
public boolean isLinkedTo() {
return false;
}
@Override
public boolean isLink() {
return false;
}
@Override
public LinkedPolygon getLinkedFromPolygon() {
return null;
}
@Override
void anonymize() {
}
@Override
public double getArea() {
return 0;
}
@Override
public void prepareForChecking() {
}
@Override
public void clearMetaInformation() {
}
@Override
public void collectInstances(CopyHandler handler) {
}
@Override
public Copyable createCopyInstance() {
return null;
}
}
...@@ -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,7 +49,7 @@ public class ConcretePolygon extends Polygon { ...@@ -49,7 +49,7 @@ 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 CompositePolygon partOfComposite = null; private CompositeCollection partOfComposite = null;
private Geometry parent; private Geometry parent;
private LinkedPolygon linkedFromPolygon; private LinkedPolygon linkedFromPolygon;
...@@ -137,11 +137,11 @@ public class ConcretePolygon extends Polygon { ...@@ -137,11 +137,11 @@ public class ConcretePolygon extends Polygon {
parent = geometry; parent = geometry;
} }
protected void setPartOfComposite(CompositePolygon comp) { protected void setPartOfComposite(CompositeCollection comp) {
this.partOfComposite = comp; this.partOfComposite = comp;
} }
public CompositePolygon getPartOfComposite() { public CompositeCollection getPartOfComposite() {
return partOfComposite; return partOfComposite;
} }
......
...@@ -15,7 +15,7 @@ import java.io.Serial; ...@@ -15,7 +15,7 @@ import java.io.Serial;
*/ */
public class ImplicitGeometryHolder extends Geometry { public class ImplicitGeometryHolder extends Geometry {
private static final Logger logger = LogManager.getLogger(LibraryObject.class); private static final Logger logger = LogManager.getLogger(ImplicitGeometryHolder.class);
@Serial @Serial
private static final long serialVersionUID = -8938931081577196349L; private static final long serialVersionUID = -8938931081577196349L;
......
...@@ -79,6 +79,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -79,6 +79,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
private final Path directory; private final Path directory;
private final double neighborDistance; private final double neighborDistance;
private Map<String, ConcretePolygon> polygonMap = new HashMap<>(); private Map<String, ConcretePolygon> polygonMap = new HashMap<>();
private Map<String, CompositeCollection> compositeMap = new HashMap<>();
private List<ResolvableReference> references = new ArrayList<>(); private List<ResolvableReference> references = new ArrayList<>();
private Map<Vertex, Vertex> vertexMap = new HashMap<>(); private Map<Vertex, Vertex> vertexMap = new HashMap<>();
...@@ -147,7 +148,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -147,7 +148,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseAndAddMultiSurface(waterBody.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, wo); parseAndAddMultiSurface(waterBody.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, wo);
parseAndAddSolid(waterBody.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, wo); parseAndAddSolid(waterBody.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, wo);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : waterBody.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : waterBody.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -286,7 +287,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -286,7 +287,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
bo.addBridgeInstallation(bi); bo.addBridgeInstallation(bi);
} }
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : ab.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : ab.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -315,7 +316,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -315,7 +316,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi); parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi);
bi.unsetGmlGeometries(); bi.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -417,7 +418,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -417,7 +418,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
cdTunnel.addTunnelConstructiveElement(tc); cdTunnel.addTunnelConstructiveElement(tc);
} }
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTunnel.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : gmlTunnel.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -450,7 +451,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -450,7 +451,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, ti); parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, ti);
ti.unsetGmlGeometries(); ti.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTi.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : gmlTi.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -481,7 +482,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -481,7 +482,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
tHollow.setGmlObject(gmlHo); tHollow.setGmlObject(gmlHo);
mapAbstractUnoccupiedSpace(gmlHo, tHollow); mapAbstractUnoccupiedSpace(gmlHo, tHollow);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlHo.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : gmlHo.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -521,7 +522,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -521,7 +522,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
tf.setGmlObject(gmlTf); tf.setGmlObject(gmlTf);
mapAbstractOccupiedSpace(gmlTf, tf); mapAbstractOccupiedSpace(gmlTf, tf);
tf.unsetGmlGeometries(); tf.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTf.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : gmlTf.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -544,7 +545,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -544,7 +545,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
TunnelConstructiveElement te = new TunnelConstructiveElement(gmlTe); TunnelConstructiveElement te = new TunnelConstructiveElement(gmlTe);
mapAbstractOccupiedSpace(gmlTe, te); mapAbstractOccupiedSpace(gmlTe, te);
te.unsetGmlGeometries(); te.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTe.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : gmlTe.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -577,7 +578,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -577,7 +578,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
private void mapConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement ele, BridgeConstructiveElement bce) { private void mapConstructiveElement(org.citygml4j.core.model.bridge.BridgeConstructiveElement ele, BridgeConstructiveElement bce) {
mapAbstractConstructiveElement(ele, bce); mapAbstractConstructiveElement(ele, bce);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : ele.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : ele.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -830,18 +831,16 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -830,18 +831,16 @@ public class Citygml3FeatureMapper extends ObjectWalker {
href = href.substring(1); href = href.substring(1);
} }
Geometry geom = ref.geometry(); Geometry geom = ref.geometry();
CompositeCollection comp = compositeMap.get(href);
if (comp != null) {
comp.getCompositeMembers().forEach(geom::addPolygon);
} else {
ConcretePolygon concPoly = polygonMap.get(href); ConcretePolygon concPoly = polygonMap.get(href);
if (concPoly == null) { if (concPoly == null) {
if (logger.isWarnEnabled()) { if (logger.isWarnEnabled()) {
logger.warn(Localization.getText("FeatureMapper.polygonUnreferenced"), href); logger.warn(Localization.getText("FeatureMapper.polygonUnreferenced"), href);
} }
continue;
}
if (concPoly instanceof CompositePolygon comp) {
resolveCompositePolygon(comp).forEach(geom::addPolygon);
} else { } else {
//
LinkedPolygon lPoly = new LinkedPolygon(concPoly, geom); LinkedPolygon lPoly = new LinkedPolygon(concPoly, geom);
if (geom.getParent() instanceof BoundarySurface bs) { if (geom.getParent() instanceof BoundarySurface bs) {
lPoly.setPartOfSurface(bs); lPoly.setPartOfSurface(bs);
...@@ -852,6 +851,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -852,6 +851,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
geom.addPolygon(lPoly); geom.addPolygon(lPoly);
} }
} }
}
// clear storage for polygons and vertices // clear storage for polygons and vertices
// probably faster than .clear() ? // probably faster than .clear() ?
...@@ -860,18 +860,6 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -860,18 +860,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
polygonMap = new HashMap<>(); polygonMap = new HashMap<>();
} }
private List<ConcretePolygon> resolveCompositePolygon(CompositePolygon comp) {
List<ConcretePolygon> polygons = new ArrayList<>();
for (ConcretePolygon conc : comp.getCompositeMembers()) {
if (conc instanceof CompositePolygon recComp) {
polygons.addAll(resolveCompositePolygon(recComp));
} else {
polygons.add(conc);
}
}
return polygons;
}
private void readAbstractBuilding(org.citygml4j.core.model.building.AbstractBuilding gmlAb, private void readAbstractBuilding(org.citygml4j.core.model.building.AbstractBuilding gmlAb,
AbstractBuilding cdBuilding) { AbstractBuilding cdBuilding) {
mapAbstractOccupiedSpace(gmlAb, cdBuilding); mapAbstractOccupiedSpace(gmlAb, cdBuilding);
...@@ -916,7 +904,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -916,7 +904,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
} }
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlAb.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : gmlAb.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -960,7 +948,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -960,7 +948,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
br.setGmlObject(gmlBr); br.setGmlObject(gmlBr);
mapAbstractUnoccupiedSpace(gmlBr, br); mapAbstractUnoccupiedSpace(gmlBr, br);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBr.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : gmlBr.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -1002,7 +990,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -1002,7 +990,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
bf.setGmlObject(gmlAF); bf.setGmlObject(gmlAF);
mapAbstractOccupiedSpace(gmlAF, bf); mapAbstractOccupiedSpace(gmlAF, bf);
bf.unsetGmlGeometries(); bf.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlAF.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : gmlAF.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -1027,7 +1015,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -1027,7 +1015,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
storey.setGmlObject(gmlStorey); storey.setGmlObject(gmlStorey);
mapAbstractSpace(gmlStorey, storey); mapAbstractSpace(gmlStorey, storey);
storey.unsetGmlGeometries(); storey.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlStorey.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : gmlStorey.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -1051,7 +1039,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -1051,7 +1039,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
bu.setGmlObject(gmlBU); bu.setGmlObject(gmlBU);
mapAbstractSpace(gmlBU, bu); mapAbstractSpace(gmlBU, bu);
bu.unsetGmlGeometries(); bu.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBU.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : gmlBU.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -1093,7 +1081,7 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -1093,7 +1081,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi); parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi);
bi.unsetGmlGeometries(); bi.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config); SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) { for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) {
if (!surfaceProp.isSetObject()) { if (!surfaceProp.isSetObject()) {
continue; continue;
...@@ -1183,9 +1171,6 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -1183,9 +1171,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
List<ConcretePolygon> polygons = geometryMapper.getPolygons(); List<ConcretePolygon> polygons = geometryMapper.getPolygons();
for (ConcretePolygon concretePoly : polygons) { for (ConcretePolygon concretePoly : polygons) {
if (concretePoly instanceof CompositePolygon) {
continue;
}
geom.addPolygon(concretePoly); geom.addPolygon(concretePoly);
if (concretePoly.hasExistingGmlId()) { if (concretePoly.hasExistingGmlId()) {
polygonMap.put(concretePoly.getGmlId().getGmlString(), concretePoly); polygonMap.put(concretePoly.getGmlId().getGmlString(), concretePoly);
...@@ -1206,9 +1191,6 @@ public class Citygml3FeatureMapper extends ObjectWalker { ...@@ -1206,9 +1191,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
for (Geometry geom : co.getGeometries()) { for (Geometry geom : co.getGeometries()) {
KDTree tree = new KDTree(); KDTree tree = new KDTree();
for (Polygon poly : geom.getPolygons()) { for (Polygon poly : geom.getPolygons()) {
if (poly instanceof CompositePolygon) {
continue;
}
LinearRing lr = poly.getExteriorRing(); LinearRing lr = poly.getExteriorRing();
updateRing(tree, lr); updateRing(tree, lr);
for (LinearRing innerRing : poly.getInnerRings()) { for (LinearRing innerRing : poly.getInnerRings()) {
......
...@@ -43,6 +43,7 @@ public class Citygml3GeometryMapper extends GeometryWalker { ...@@ -43,6 +43,7 @@ public class Citygml3GeometryMapper extends GeometryWalker {
private static final Logger logger = LogManager.getLogger(Citygml3GeometryMapper.class); private static final Logger logger = LogManager.getLogger(Citygml3GeometryMapper.class);
private final List<ConcretePolygon> polygons = new ArrayList<>(); private final List<ConcretePolygon> polygons = new ArrayList<>();
private final List<CompositeCollection> composites = new ArrayList<>();
private LinearRing currentRing = null; private LinearRing currentRing = null;
private final ParserConfiguration config; private final ParserConfiguration config;
private final ProjCoordinate p1 = new ProjCoordinate(); private final ProjCoordinate p1 = new ProjCoordinate();
...@@ -99,7 +100,7 @@ public class Citygml3GeometryMapper extends GeometryWalker { ...@@ -99,7 +100,7 @@ public class Citygml3GeometryMapper extends GeometryWalker {
} }
List<SurfaceProperty> surfaceMember = cs.getSurfaceMembers(); List<SurfaceProperty> surfaceMember = cs.getSurfaceMembers();
Citygml3GeometryMapper recursiveMapper = new Citygml3GeometryMapper(config, vertexMap); Citygml3GeometryMapper recursiveMapper = new Citygml3GeometryMapper(config, vertexMap);
CompositePolygon comp = new CompositePolygon(); CompositeCollection comp = new CompositeCollection();
if (cs.getId() == null) { if (cs.getId() == null) {
comp.setGmlId(GmlId.generateId()); comp.setGmlId(GmlId.generateId());
} else { } else {
...@@ -114,7 +115,8 @@ public class Citygml3GeometryMapper extends GeometryWalker { ...@@ -114,7 +115,8 @@ public class Citygml3GeometryMapper extends GeometryWalker {
} }
List<ConcretePolygon> compPolys = recursiveMapper.getPolygons(); List<ConcretePolygon> compPolys = recursiveMapper.getPolygons();
compPolys.forEach(comp::addCompositeMember); compPolys.forEach(comp::addCompositeMember);
polygons.add(comp); comp.addAllChildComposites(recursiveMapper.getComposites());
composites.add(comp);
polygons.addAll(compPolys); polygons.addAll(compPolys);
} }
...@@ -201,4 +203,8 @@ public class Citygml3GeometryMapper extends GeometryWalker { ...@@ -201,4 +203,8 @@ public class Citygml3GeometryMapper extends GeometryWalker {
return polygons; return polygons;
} }
public List<CompositeCollection> getComposites() {
return composites;
}
} }
...@@ -37,15 +37,18 @@ public class SurfaceMapper extends ObjectWalker { ...@@ -37,15 +37,18 @@ public class SurfaceMapper extends ObjectWalker {
private final List<BoundarySurface> surfaces = new ArrayList<>(); private final List<BoundarySurface> surfaces = new ArrayList<>();
private final Map<String, ConcretePolygon> polygonMap; private final Map<String, ConcretePolygon> polygonMap;
private final Map<String, CompositeCollection> compositeMap;
private final List<ResolvableReference> references; private final List<ResolvableReference> references;
private final Map<Vertex, Vertex> vertexMap; private final Map<Vertex, Vertex> vertexMap;
private final ParserConfiguration config; private final ParserConfiguration config;
public SurfaceMapper(Map<String, ConcretePolygon> polygonMap, List<ResolvableReference> references, public SurfaceMapper(Map<String, ConcretePolygon> polygonMap, List<ResolvableReference> references,
Map<Vertex, Vertex> vertexMap, ParserConfiguration config) { Map<String, CompositeCollection> compositeMap, Map<Vertex, Vertex> vertexMap,
ParserConfiguration config) {
this.polygonMap = polygonMap; this.polygonMap = polygonMap;
this.references = references; this.references = references;
this.vertexMap = vertexMap; this.vertexMap = vertexMap;
this.compositeMap = compositeMap;
this.config = config; this.config = config;
} }
...@@ -125,17 +128,18 @@ public class SurfaceMapper extends ObjectWalker { ...@@ -125,17 +128,18 @@ public class SurfaceMapper extends ObjectWalker {
} }
List<ConcretePolygon> polygons = geometryMapper.getPolygons(); List<ConcretePolygon> polygons = geometryMapper.getPolygons();
List<CompositeCollection> composites = geometryMapper.getComposites();
for (CompositeCollection cc : composites) {
references.add(new ResolvableReference(cc.getGmlId().toString(), geom));
compositeMap.put(cc.getGmlId().getGmlString(), cc);
}
for (ConcretePolygon concretePoly : polygons) { for (ConcretePolygon concretePoly : polygons) {
if (concretePoly instanceof CompositePolygon comp) {
references.add(new ResolvableReference(comp.getGmlId().toString(), geom));
polygonMap.put(comp.getGmlId().toString(), comp);
} else {
geom.addPolygon(concretePoly); geom.addPolygon(concretePoly);
if (concretePoly.hasExistingGmlId()) { if (concretePoly.hasExistingGmlId()) {
polygonMap.put(concretePoly.getGmlId().getGmlString(), concretePoly); polygonMap.put(concretePoly.getGmlId().getGmlString(), concretePoly);
} }
} }
}
} }
@Override @Override
......
...@@ -75,12 +75,14 @@ public final class CityGmlUtils { ...@@ -75,12 +75,14 @@ public final class CityGmlUtils {
return gmlPoly; return gmlPoly;
} }
public static CompositeSurface createGmlComposite(GeometryFactory factory, CompositePolygon cdPoly, public static CompositeSurface createGmlComposite(GeometryFactory factory, CompositeCollection comp,
ParserConfiguration config) { ParserConfiguration config) {
List<ConcretePolygon> cdMembers = cdPoly.getCompositeMembers();
List<SurfaceProperty> surfaces = new ArrayList<>(); List<SurfaceProperty> surfaces = new ArrayList<>();
for (ConcretePolygon cd : cdMembers) { for (ConcretePolygon cd : comp.getNonRecursiveCompositeMembers()) {
surfaces.add(resolveCompositeMember(factory, cd, config)); surfaces.add(new SurfaceProperty(createGmlPolygon(factory, cd, config)));
}
for (CompositeCollection cc : comp.getChildComposites()) {
surfaces.add(new SurfaceProperty(createGmlComposite(factory, cc, config)));
} }
if (surfaces.isEmpty()) { if (surfaces.isEmpty()) {
return null; return null;
...@@ -88,14 +90,6 @@ public final class CityGmlUtils { ...@@ -88,14 +90,6 @@ public final class CityGmlUtils {
return new CompositeSurface(surfaces); return new CompositeSurface(surfaces);
} }
private static SurfaceProperty resolveCompositeMember(GeometryFactory factory, ConcretePolygon cdPoly,
ParserConfiguration config) {
if (cdPoly instanceof CompositePolygon comp) {
return new SurfaceProperty(createGmlComposite(factory, comp, config));
} else {
return new SurfaceProperty(createGmlPolygon(factory, cdPoly, config));
}
}
public static org.xmlobjects.gml.model.geometry.primitives.LinearRing createGmlRing(GeometryFactory factory, public static org.xmlobjects.gml.model.geometry.primitives.LinearRing createGmlRing(GeometryFactory factory,
ParserConfiguration config, LinearRing lr) { ParserConfiguration config, LinearRing lr) {
...@@ -161,12 +155,10 @@ public final class CityGmlUtils { ...@@ -161,12 +155,10 @@ public final class CityGmlUtils {
throw new IllegalArgumentException("This can only handle MultiSurfaces"); throw new IllegalArgumentException("This can only handle MultiSurfaces");
} }
List<SurfaceProperty> surfaces = new ArrayList<>(); List<SurfaceProperty> surfaces = new ArrayList<>();
Set<CompositePolygon> compositePolygons = new HashSet<>(); Set<CompositeCollection> compositeCollections = new HashSet<>();
for (Polygon cdPoly : geom.getPolygons()) { for (Polygon cdPoly : geom.getPolygons()) {
if (cdPoly instanceof ConcretePolygon conc && conc.isCompositeMember()) { if (cdPoly instanceof ConcretePolygon conc && conc.isCompositeMember()) {
compositePolygons.add(conc.getPartOfComposite()); compositeCollections.add(conc.getPartOfComposite());
} else if (cdPoly instanceof CompositePolygon composite) {
compositePolygons.add(composite);
} else if (!cdPoly.isLink()) { } else if (!cdPoly.isLink()) {
// is not part of a boundary surface // is not part of a boundary surface
org.xmlobjects.gml.model.geometry.primitives.Polygon gmlPoly = createGmlPolygon(factory, cdPoly, config); org.xmlobjects.gml.model.geometry.primitives.Polygon gmlPoly = createGmlPolygon(factory, cdPoly, config);
...@@ -178,7 +170,7 @@ public final class CityGmlUtils { ...@@ -178,7 +170,7 @@ public final class CityGmlUtils {
surfaces.add(new SurfaceProperty("#" + cdPoly.getGmlId().getGmlString())); surfaces.add(new SurfaceProperty("#" + cdPoly.getGmlId().getGmlString()));
} }
} }
for (CompositePolygon cdPoly : compositePolygons) { for (CompositeCollection cdPoly : compositeCollections) {
surfaces.add(new SurfaceProperty(createGmlComposite(factory, cdPoly, config))); surfaces.add(new SurfaceProperty(createGmlComposite(factory, cdPoly, config)));
} }
if (surfaces.isEmpty()) { if (surfaces.isEmpty()) {
......
...@@ -658,9 +658,6 @@ public class Renderer { ...@@ -658,9 +658,6 @@ public class Renderer {
private void addGeometryDataToView(Geometry geom) { private void addGeometryDataToView(Geometry geom) {
for (Polygon p : geom.getPolygons()) { for (Polygon p : geom.getPolygons()) {
if (p instanceof CompositePolygon) {
continue;
}
addPolygonToView(p); addPolygonToView(p);
} }
for (Edge e : geom.getEdges()) { for (Edge e : geom.getEdges()) {
...@@ -1060,7 +1057,6 @@ public class Renderer { ...@@ -1060,7 +1057,6 @@ public class Renderer {
for (Polygon p : geom.getPolygons()) { for (Polygon p : geom.getPolygons()) {
if (p.getOriginal().getPartOfSurface() != null && if (p.getOriginal().getPartOfSurface() != null &&
!roofFilter.allowedToUse(p.getOriginal().getPartOfSurface(), p.getParent())) continue; !roofFilter.allowedToUse(p.getOriginal().getPartOfSurface(), p.getParent())) continue;
if (p instanceof CompositePolygon) continue;
polygons.add(p.getOriginal()); polygons.add(p.getOriginal());
} }
} }
......
...@@ -45,9 +45,6 @@ public class TriangulatedGeometry { ...@@ -45,9 +45,6 @@ public class TriangulatedGeometry {
private static void addPolygonDataToTriGeom(Collection<? extends Polygon> polygons, Color basePolygonColor, private static void addPolygonDataToTriGeom(Collection<? extends Polygon> polygons, Color basePolygonColor,
TriangulatedGeometry triGeom) { TriangulatedGeometry triGeom) {
for (Polygon p : polygons) { for (Polygon p : polygons) {
if (p instanceof CompositePolygon){
continue;
}
TesselatedPolygon tp = p.tesselate(); TesselatedPolygon tp = p.tesselate();
TriangleMesh triMesh = new TriangleMesh(VertexFormat.POINT_TEXCOORD); TriangleMesh triMesh = new TriangleMesh(VertexFormat.POINT_TEXCOORD);
Map<Vector3d, Integer> indexMap = new HashMap<>(); Map<Vector3d, Integer> indexMap = new HashMap<>();
......
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