Commit 99385663 authored by Riegel's avatar Riegel
Browse files

Refactor: Add BBox calculation for single CityObjects

parent 1970e72e
......@@ -76,7 +76,7 @@ public class DatabaseHandler {
try (Connection con = new ConnectionWrapper(H2GISDBFactory.openSpatialDataBase(DB_NAME))) {
try (PreparedStatement ps = con.prepareStatement("MERGE INTO features VALUES (?, ?, ?, ?)")) {
ps.setString(1, co.getGmlId().toString());
String bbox = BoundingBox.of(co.getHighestLodGeometry().getPolygons()).to2DWkt();
String bbox = BoundingBox.of(co).to2DWkt();
ps.setString(2, bbox);
if (logger.isDebugEnabled()) {
logger.debug("Attempting to serialize city object {} ", co);
......
......@@ -20,6 +20,7 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.utils.BoundingBoxCalculator;
import de.hft.stuttgart.citydoctor2.utils.visitors.MinMaxExtentVisitor;
import java.util.Collection;
import java.util.List;
......@@ -47,6 +48,12 @@ public class BoundingBox {
return BoundingBoxCalculator.calculateBoundingBoxFromPoints(points);
}
public static BoundingBox of(CityObject co) {
MinMaxExtentVisitor mima = new MinMaxExtentVisitor();
co.accept(mima);
return BoundingBox.of(mima.getMinMaxExtent());
}
/**
* Creates an axis aligned bounding box of the whole model.
*
......
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