Commit a10cd195 authored by Matthias Betz's avatar Matthias Betz
Browse files

low memory consumption mode implementation, when loading a complete model

parent 0ce879fa
Pipeline #1253 passed with stage
in 2 minutes and 7 seconds
......@@ -42,11 +42,11 @@ public abstract class Checkable implements Serializable {
private EnumMap<CheckId, CheckResult> checkResults = new EnumMap<>(CheckId.class);
private boolean isValidated = false;
protected void setValidated(boolean validated) {
isValidated = validated;
}
public boolean isValidated() {
return isValidated;
}
......@@ -75,6 +75,19 @@ public abstract class Checkable implements Serializable {
*/
public abstract GmlId getGmlId();
/**
* This should be called before executing a check if low memory consumption
* method has been enabled. This should create edges and additional meta
* information necessary to perform checks.
*/
public abstract void prepareForChecking();
/**
* This should be called after checking has been done. This should remove any
* created meta information like edges to free up additional memory space
*/
public abstract void clearMetaInformation();
/**
* This method checks if the object or any object contained within this
* checkable has an error. It counts as an error if the result status if the
......
......@@ -257,4 +257,26 @@ public abstract class AbstractBuilding extends CityObject {
public List<BuildingInstallation> getBuildingInstallations() {
return buildingInstallations;
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (BuildingInstallation bi : buildingInstallations) {
bi.prepareForChecking();
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (BuildingInstallation bi : buildingInstallations) {
bi.clearMetaInformation();
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.clearMetaInformation();
}
}
}
......@@ -295,4 +295,20 @@ public class BoundarySurface extends CityObject {
opening.setPartOfSurface(this);
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (Opening o : openings) {
o.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (Opening o : openings) {
o.clearMetaInformation();
}
}
}
......@@ -214,5 +214,21 @@ public class BridgeObject extends CityObject {
public String toString() {
return "BridgeObject [type=" + type + ", id=" + getGmlId() + "]";
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (BoundarySurface bs : boundarySurfaces) {
bs.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (BoundarySurface bs : boundarySurfaces) {
bs.clearMetaInformation();
}
}
}
......@@ -134,4 +134,20 @@ public class Building extends AbstractBuilding {
}
setCityGmlBuilding(gmlB);
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (BuildingPart part : buildingParts) {
part.clearMetaInformation();
}
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (BuildingPart part : buildingParts) {
part.prepareForChecking();
}
}
}
......@@ -193,6 +193,22 @@ public class BuildingInstallation extends CityObject {
return boundarySurfaces;
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (BoundarySurface bs : boundarySurfaces) {
bs.clearMetaInformation();
}
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (BoundarySurface bs : boundarySurfaces) {
bs.prepareForChecking();
}
}
}
......@@ -172,4 +172,18 @@ public abstract class CityObject extends GmlElement {
}
return null;
}
@Override
public void prepareForChecking() {
for (Geometry geom : geometryList) {
geom.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
for (Geometry geom : geometryList) {
geom.clearMetaInformation();
}
}
}
......@@ -440,4 +440,14 @@ public class ConcretePolygon extends Polygon {
void setLinkedTo(LinkedPolygon linkedPolygon) {
linkedFromPolygon = linkedPolygon;
}
@Override
public void prepareForChecking() {
parent.prepareForChecking();
}
@Override
public void clearMetaInformation() {
parent.clearMetaInformation();
}
}
......@@ -405,4 +405,16 @@ public class Geometry extends GmlElement {
public Geometry copy() {
return (Geometry) super.copy();
}
@Override
public void prepareForChecking() {
updateEdgesAndVertices();
}
@Override
public void clearMetaInformation() {
edges = null;
vertices = null;
edgeMap = null;
}
}
......@@ -246,5 +246,14 @@ public class LinearRing extends GmlElement {
public void addAllVertices(List<Vertex> extRing) {
vertices.addAll(extRing);
}
@Override
public void prepareForChecking() {
parent.getParent().prepareForChecking();
}
@Override
public void clearMetaInformation() {
parent.getParent().clearMetaInformation();
}
}
......@@ -246,5 +246,15 @@ public class LinkedPolygon extends Polygon {
public ConcretePolygon getOriginal() {
return poly;
}
@Override
public void prepareForChecking() {
poly.prepareForChecking();
}
@Override
public void clearMetaInformation() {
poly.clearMetaInformation();
}
}
......@@ -51,7 +51,7 @@ public class TransportationObject extends CityObject {
}
private AbstractTransportationObject ato;
private List<TransportationObject> composesOf = new ArrayList<>();
private List<TransportationObject> composesOf = new ArrayList<>(1);
private TransportationType type;
public TransportationObject(TransportationType type) {
......@@ -253,5 +253,21 @@ public class TransportationObject extends CityObject {
public String toString() {
return "TransportationObject [id=" + getGmlId() + "]";
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (TransportationObject child : composesOf) {
child.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (TransportationObject child : composesOf) {
child.clearMetaInformation();
}
}
}
......@@ -154,7 +154,6 @@ public class FeatureMapper extends FeatureWalker {
}
private void updateEdgesAndVertices(CityObject co) {
for (Geometry geom : co.getGeometries()) {
geom.updateVertices();
KDTree tree = new KDTree();
......@@ -170,8 +169,16 @@ public class FeatureMapper extends FeatureWalker {
v.addNeighbor(neighbor);
}
}
geom.updateEdges();
if (config.useLowMemoryConsumption()) {
// do not create edges and vertices
// vertices were already created because they were needed for the kd tree
// remove them again
geom.clearMetaInformation();
} else {
// create edges
geom.updateEdges();
}
}
}
......
......@@ -46,15 +46,21 @@ public class ParserConfiguration implements Serializable {
private String targetTransformString;
private String originalTransformString;
private boolean hasTransformation = false;
private boolean useLowMemoryConsumption = false;
private transient double fromMetres = 1.0;
public ParserConfiguration(int numberOfRoundingPlaces, boolean validate) {
this(numberOfRoundingPlaces, validate, false);
}
public ParserConfiguration(int numberOfRoundingPlaces, boolean validate, boolean lowMemory) {
if (numberOfRoundingPlaces < 0) {
throw new IllegalArgumentException("Number of rounding places must be a positive value");
}
roundingPlaces = numberOfRoundingPlaces;
this.validate = validate;
useLowMemoryConsumption = lowMemory;
}
public boolean getValidate() {
......@@ -107,5 +113,9 @@ public class ParserConfiguration implements Serializable {
public double getFromMetres() {
return fromMetres;
}
public boolean useLowMemoryConsumption() {
return useLowMemoryConsumption;
}
}
......@@ -110,4 +110,5 @@ CityGmlParser.noEPSG=Could not read EPSG code, assuming metric system
OpenFileDialog.loadFailed=Failed to load CityGML File
MainWindow.memoryLabel=Memory:
CheckDialog.checksReenabledAlert=Some checks have been reenabled so that other wanted checks can be executed\nSee the log for more information.
MainWindow.availableLabel=Available:
\ No newline at end of file
MainWindow.availableLabel=Available:
OpenFileDialog.lowMemoryLabel=Low Memory Consumption Mode
\ No newline at end of file
......@@ -108,4 +108,5 @@ CityGmlParser.noEPSG=Konnte EPSG Code nicht lesen, nehme metrisches System an
OpenFileDialog.loadFailed=Konnte CityGML Datei nicht laden
MainWindow.memoryLabel=Speicher:
CheckDialog.checksReenabledAlert=Manche Pr\u00fcfungen wurden reaktiviert damit andere gewollte Pr\u00fcfungen durchgef\u00fchrt werden k\u00f6nnen\nMehr Details sind im Log geschrieben
MainWindow.availableLabel=Verf\u00fcgbar:
\ No newline at end of file
MainWindow.availableLabel=Verf\u00fcgbar:
OpenFileDialog.lowMemoryLabel=Reduzierter Speicherverbrauchsmodus
\ No newline at end of file
......@@ -362,8 +362,17 @@ public class Checker {
// stupid lamda with final variable restrictions
int[] currentFeature = new int[1];
features.forEach(co -> {
if (config.getParserConfiguration().useLowMemoryConsumption()) {
// no edges have been created yet, create them
co.prepareForChecking();
}
// check every feature
executeChecksForCityObject(co);
if (config.getParserConfiguration().useLowMemoryConsumption()) {
// low memory consumption, remove edges again
co.clearMetaInformation();
}
if (l != null) {
currentFeature[0]++;
l.updateProgress(currentFeature[0] / featureSum);
......
Markdown is supported
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