Commit ad3589e8 authored by Riegel's avatar Riegel
Browse files

Add export of CompositeSurfaces

parent a6da3282
Pipeline #10295 passed with stage
in 1 minute and 12 seconds
Showing with 48 additions and 6 deletions
+48 -6
...@@ -54,6 +54,7 @@ public final class CompositePolygon extends ConcretePolygon{ ...@@ -54,6 +54,7 @@ public final class CompositePolygon extends ConcretePolygon{
public void addCompositeMember(ConcretePolygon p){ public void addCompositeMember(ConcretePolygon p){
compositeMembers.add(p); compositeMembers.add(p);
p.setPartOfComposite(this);
} }
public List<ConcretePolygon> getCompositeMembers(){ public List<ConcretePolygon> getCompositeMembers(){
......
...@@ -49,6 +49,7 @@ public class ConcretePolygon extends Polygon { ...@@ -49,6 +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 Geometry parent; private Geometry parent;
private LinkedPolygon linkedFromPolygon; private LinkedPolygon linkedFromPolygon;
...@@ -138,6 +139,18 @@ public class ConcretePolygon extends Polygon { ...@@ -138,6 +139,18 @@ public class ConcretePolygon extends Polygon {
parent = geometry; parent = geometry;
} }
protected void setPartOfComposite(CompositePolygon comp) {
this.partOfComposite = comp;
}
public CompositePolygon getPartOfComposite() {
return partOfComposite;
}
public boolean isCompositeMember() {
return (partOfComposite != null);
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
......
...@@ -19,8 +19,11 @@ ...@@ -19,8 +19,11 @@
package de.hft.stuttgart.citydoctor2.utils; package de.hft.stuttgart.citydoctor2.utils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import de.hft.stuttgart.citydoctor2.datastructure.*;
import org.citygml4j.core.util.geometry.GeometryFactory; import org.citygml4j.core.util.geometry.GeometryFactory;
import org.locationtech.proj4j.BasicCoordinateTransform; import org.locationtech.proj4j.BasicCoordinateTransform;
import org.locationtech.proj4j.ProjCoordinate; import org.locationtech.proj4j.ProjCoordinate;
...@@ -32,11 +35,6 @@ import org.xmlobjects.gml.model.geometry.primitives.ShellProperty; ...@@ -32,11 +35,6 @@ import org.xmlobjects.gml.model.geometry.primitives.ShellProperty;
import org.xmlobjects.gml.model.geometry.primitives.Solid; import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty; import org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
/** /**
...@@ -81,6 +79,28 @@ public final class CityGmlUtils { ...@@ -81,6 +79,28 @@ public final class CityGmlUtils {
return gmlPoly; return gmlPoly;
} }
public static CompositeSurface createGmlComposite(GeometryFactory factory, CompositePolygon cdPoly,
ParserConfiguration config) {
List<ConcretePolygon> cdMembers = cdPoly.getCompositeMembers();
List<SurfaceProperty> surfaces = new ArrayList<>();
for (ConcretePolygon cd : cdMembers) {
surfaces.add(resolveCompositeMember(factory, cd, config));
}
if (surfaces.isEmpty()){
return null;
}
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) {
...@@ -145,8 +165,13 @@ public final class CityGmlUtils { ...@@ -145,8 +165,13 @@ 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<>();
for (Polygon cdPoly : geom.getPolygons()) { for (Polygon cdPoly : geom.getPolygons()) {
if (!cdPoly.isLink()) { if (cdPoly instanceof ConcretePolygon conc && conc.isCompositeMember()) {
compositePolygons.add(conc.getPartOfComposite());
}else if (cdPoly instanceof CompositePolygon composite) {
compositePolygons.add(composite);
} 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);
if (gmlPoly != null) { if (gmlPoly != null) {
...@@ -157,6 +182,9 @@ public final class CityGmlUtils { ...@@ -157,6 +182,9 @@ public final class CityGmlUtils {
surfaces.add(new SurfaceProperty("#" + cdPoly.getGmlId().getGmlString())); surfaces.add(new SurfaceProperty("#" + cdPoly.getGmlId().getGmlString()));
} }
} }
for (CompositePolygon cdPoly : compositePolygons) {
surfaces.add(new SurfaceProperty(createGmlComposite(factory, cdPoly, config)));
}
if (surfaces.isEmpty()) { if (surfaces.isEmpty()) {
return null; return null;
} }
......
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