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

Refactor: Make PolygonPatch collection typesafe

2 merge requests!28Version 3.17.0 Release,!27TransportationObject model rework
Showing with 60 additions and 12 deletions
+60 -12
......@@ -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;
}
......
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 {
@Override
public void visit(Surface surface) {
// TODO: Implement like CompositeSurfaces, just with PolygonPatches
if (surface.getPatches() != null && !surface.getPatches().isSetObjects()) {
logger.warn("Surface {} has no PolygonPatches.", surface.getId());
return;
}
CompositeCollection comp = new CompositeCollection();
List<PolygonPatch> polygonPatches = (List<PolygonPatch>) surface.getPatches().getObjects();
Citygml3GeometryMapper recursiveMapper = new Citygml3GeometryMapper(config, vertexMap);
List<PolygonPatch> polygonPatches = new ArrayList<>();
GeometryWalker patchCollector = new GeometryWalker() {
@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) {
recursiveMapper.parsePolygonPatch(patch.getExterior(), patch.getInterior());
patchMapper.parsePolygonPatch(patch.getExterior(), patch.getInterior());
}
List<ConcretePolygon> compPolys = recursiveMapper.getPolygons();
compPolys.forEach(comp::addCompositeMember);
comp.addAllChildComposites(recursiveMapper.getComposites());
composites.add(comp);
polygons.addAll(compPolys);
List<ConcretePolygon> patchPolys = patchMapper.getPolygons();
patchPolys.forEach(patchCollection::addPatchMember);
polygons.addAll(patchPolys);
}
......
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