Commit ca719316 authored by Riegel's avatar Riegel
Browse files

Refactor: Use new method for clearing of GML-geometry

parent ae344b1a
......@@ -25,13 +25,6 @@ public class BuildingUnit extends AbstractBuildingSubdivision {
}
@Override
public void unsetGmlGeometries() {
super.unsetGmlGeometries();
for (Storey storey : storeys) {
storey.unsetGmlGeometries();
}
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
......
......@@ -24,6 +24,7 @@ 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 de.hft.stuttgart.citydoctor2.utils.UnsetGeometriesVisitor;
import javafx.scene.paint.Color;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.util.geometry.GeometryFactory;
......@@ -73,6 +74,10 @@ public abstract class CityObject extends GmlElement {
*/
public abstract void unsetGmlGeometries();
public final void clearGmlGeometries() {
this.accept(new UnsetGeometriesVisitor());
}
public void addGeometry(Geometry geom) {
Objects.requireNonNull(geom);
geometryList.add(geom);
......
......@@ -412,7 +412,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, bi);
GeometryProperty<?> lod4Prop = gmlBi.getDeprecatedProperties().getLod4Geometry();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi);
bi.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) {
......@@ -484,11 +483,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
}
cdTunnel.unsetGmlGeometries();
resolveAndClearReferences();
updateEdgesAndVertices(cdTunnel);
}
private void parseTunnelBoundarySurfaces(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel) {
......@@ -563,7 +557,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, ti);
GeometryProperty<?> lod4Prop = gmlTi.getDeprecatedProperties().getLod4Geometry();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, ti);
ti.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTi.getBoundaries()) {
......@@ -635,7 +629,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
TunnelFurniture tf = new TunnelFurniture();
tf.setGmlObject(gmlTf);
mapAbstractOccupiedSpace(gmlTf, tf);
tf.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTf.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
......@@ -659,7 +653,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
org.citygml4j.core.model.tunnel.TunnelConstructiveElement gmlTe) {
TunnelConstructiveElement te = new TunnelConstructiveElement(gmlTe);
mapAbstractOccupiedSpace(gmlTe, te);
te.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTe.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
......@@ -800,7 +793,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
private void finishCityObjectConstruction(CityObject co) {
parseId(co.getGmlObject(), co);
co.accept(new UnsetGeometriesVisitor());
co.clearGmlGeometries();
resolveAndClearReferences();
updateEdgesAndVertices(co);
}
......@@ -1069,9 +1062,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
updatePartOfSurface(cdBuilding, surfaceMapper);
cdBuilding.unsetGmlGeometries();
resolveAndClearReferences();
updateEdgesAndVertices(cdBuilding);
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
updateEdgesAndVertices(bs);
for (Opening o : bs.getOpenings()) {
......@@ -1174,7 +1164,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
BuildingRoomFurniture bf = new BuildingRoomFurniture();
bf.setGmlObject(gmlAF);
mapAbstractOccupiedSpace(gmlAF, bf);
bf.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlAF.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
......@@ -1199,7 +1188,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
de.hft.stuttgart.citydoctor2.datastructure.Storey storey = new de.hft.stuttgart.citydoctor2.datastructure.Storey();
storey.setGmlObject(gmlStorey);
mapAbstractSpace(gmlStorey, storey);
storey.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlStorey.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
......@@ -1223,7 +1211,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit bu = new de.hft.stuttgart.citydoctor2.datastructure.BuildingUnit();
bu.setGmlObject(gmlBU);
mapAbstractSpace(gmlBU, bu);
bu.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBU.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
......@@ -1264,7 +1251,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, bi);
GeometryProperty<?> lod4Prop = gmlBi.getDeprecatedProperties().getLod4Geometry();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, bi);
bi.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlBi.getBoundaries()) {
......
......@@ -25,6 +25,8 @@ import java.nio.file.Path;
import java.util.List;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipArchive;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.ade.ADEException;
......@@ -160,6 +162,7 @@ public class CityDoctorValidation {
logger.error("Input file '{}' does not exist.", input);
System.exit(1);
}
if (inputFile.getName().endsWith(".gml")) {
startFileValidation(inputFile, xmlOutput, pdfOutput, config, outputFile);
} else if (inputFile.getName().endsWith(".zip")) {
......
......@@ -263,7 +263,7 @@ public class Healer {
co.reCreateGeometries(factory, checker.getConfig().getParserConfiguration());
byte[] gml = writeCityGml(co.getGmlObject());
// remove them again to save memory
co.unsetGmlGeometries();
co.clearGmlGeometries();
SvrlContentHandler handler = Checker.executeSchematronValidationIfAvailable(config,
new ByteArrayInputStream(gml));
if (handler != 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