Commit d9d18caa authored by Luna Riegel's avatar Luna Riegel
Browse files

Refactor: Build feature bboxes during parsing

parent 7a51e009
......@@ -22,6 +22,8 @@ import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.utils.BoundingBoxCalculator;
import de.hft.stuttgart.citydoctor2.utils.visitors.MinMaxExtentVisitor;
import java.io.Serial;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
......@@ -31,7 +33,10 @@ import java.util.Locale;
*
* @author Matthias Betz
*/
public class BoundingBox {
public class BoundingBox implements Serializable {
@Serial
private static final long serialVersionUID = 1998769586245522486L;
private final Vector3d[] bbox;
......
......@@ -43,7 +43,7 @@ public abstract class CityObject extends GmlElement {
@Serial
private static final long serialVersionUID = 651712070755024188L;
private BoundingBox bbox;
private final List<Geometry> geometryList = new ArrayList<>();
private final List<GenericAttribute> genericAttributeList = new ArrayList<>();
......@@ -88,6 +88,14 @@ public abstract class CityObject extends GmlElement {
this.accept(new UnsetGeometriesVisitor());
}
public void setBbox(BoundingBox bbox){
this.bbox = bbox;
}
public BoundingBox getBbox(){
return bbox;
}
/**
* Adds a Geometry to this object.
* @param geom the Geometry to add.
......
......@@ -61,6 +61,7 @@ public class ImplicitGeometryHolder extends Geometry {
if(!deferredRelGeomObjects.isEmpty()) {
logger.info("Resolving deferred relative geometries");
}
Set<GmlId> changedFeatures = new HashSet<>();
for (ImplicitGeometryHolder key : deferredRelGeomObjects.keySet()) {
ImplicitGeometry ig = deferredRelGeomObjects.get(key);
String hrefId = ig.getRelativeGeometry().getHref();
......@@ -72,10 +73,15 @@ public class ImplicitGeometryHolder extends Geometry {
CityObject parent = cache.get(key.getParent().getGmlId());
parent.removeGeometry(igh.getLod(), igh.getType());
parent.addGeometry(igh);
changedFeatures.add(parent.getTopLevelCityObject().getGmlId());
} else {
missingGeoms.add(gmlId);
}
}
changedFeatures.forEach(gmlId -> {
CityObject co = cache.get(gmlId);
co.setBbox(BoundingBox.of(co));
});
if (!missingGeoms.isEmpty()) {
logger.warn("RelativeGeometries of the following gmlIDs could not be resolved: {}", missingGeoms);
}
......
......@@ -28,6 +28,7 @@ import java.util.function.Function;
import de.hft.stuttgart.citydoctor2.database.FeatureCache;
import de.hft.stuttgart.citydoctor2.database.UnconnectedCache;
import de.hft.stuttgart.citydoctor2.datastructure.BoundingBox;
import de.hft.stuttgart.citydoctor2.datastructure.OtherConstructionObject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -940,6 +941,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
co.clearGmlGeometries();
resolveAndClearReferences(co);
updateEdgesAndVertices(co);
co.setBbox(BoundingBox.of(co));
}
private void mapAbstractTransportationSpace(AbstractTransportationSpace ats, TransportationSpace trsp) {
......
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