Commit 53599b81 authored by Riegel's avatar Riegel
Browse files

Refactor: Make PolygonPatch collection typesafe

parent 1f996e76
...@@ -50,6 +50,7 @@ public class ConcretePolygon extends Polygon { ...@@ -50,6 +50,7 @@ public class ConcretePolygon extends Polygon {
private BoundarySurface partOfSurface; private BoundarySurface partOfSurface;
private Installation partfOfInstallation; private Installation partfOfInstallation;
private CompositeCollection partOfComposite = null; private CompositeCollection partOfComposite = null;
private PatchCollection partOfPatch = null;
private Geometry parent; private Geometry parent;
private LinkedPolygon linkedFromPolygon; private LinkedPolygon linkedFromPolygon;
...@@ -141,6 +142,18 @@ public class ConcretePolygon extends Polygon { ...@@ -141,6 +142,18 @@ public class ConcretePolygon extends Polygon {
this.partOfComposite = comp; 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() { public CompositeCollection getPartOfComposite() {
return partOfComposite; return partOfComposite;
} }
......
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 GmlId gmlId;
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);
}
public void setGmlId(GmlId gmlId) {
this.gmlId = gmlId;
}
public GmlId getGmlId() {
return gmlId;
}
}
...@@ -65,24 +65,26 @@ public class Citygml3GeometryMapper extends GeometryWalker { ...@@ -65,24 +65,26 @@ public class Citygml3GeometryMapper extends GeometryWalker {
@Override @Override
public void visit(Surface surface) { public void visit(Surface surface) {
// TODO: Implement like CompositeSurfaces, just with PolygonPatches
if (surface.getPatches() != null && !surface.getPatches().isSetObjects()) { if (surface.getPatches() != null && !surface.getPatches().isSetObjects()) {
logger.warn("Surface {} has no PolygonPatches.", surface.getId()); logger.warn("Surface {} has no PolygonPatches.", surface.getId());
return; return;
} }
CompositeCollection comp = new CompositeCollection(); List<PolygonPatch> polygonPatches = new ArrayList<>();
List<PolygonPatch> polygonPatches = (List<PolygonPatch>) surface.getPatches().getObjects(); GeometryWalker patchCollector = new GeometryWalker() {
Citygml3GeometryMapper recursiveMapper = new Citygml3GeometryMapper(config, vertexMap); @Override
public void visit(PolygonPatch pp) {
polygonPatches.add(pp);
}
};
surface.getPatches().getObjects().forEach(abstractSurfacePatch -> abstractSurfacePatch.accept(patchCollector));
PatchCollection patchCollection = new PatchCollection();
Citygml3GeometryMapper patchMapper = new Citygml3GeometryMapper(config, vertexMap);
for (PolygonPatch patch : polygonPatches) { for (PolygonPatch patch : polygonPatches) {
recursiveMapper.parsePolygonPatch(patch.getExterior(), patch.getInterior()); patchMapper.parsePolygonPatch(patch.getExterior(), patch.getInterior());
} }
List<ConcretePolygon> patchPolys = patchMapper.getPolygons();
List<ConcretePolygon> compPolys = recursiveMapper.getPolygons(); patchPolys.forEach(patchCollection::addPatchMember);
compPolys.forEach(comp::addCompositeMember); polygons.addAll(patchPolys);
comp.addAllChildComposites(recursiveMapper.getComposites());
composites.add(comp);
polygons.addAll(compPolys);
} }
......
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