Commit 6ebc2949 authored by Riegel's avatar Riegel
Browse files

Feat: Implement selection via buffer in database

parent 47cc6a9f
......@@ -121,13 +121,22 @@ public class DatabaseHandler {
public static List<? extends CityObject> getBufferIntersectingObjects(CityObject co, Double buffersize) {
ResultSet rs = null;
public static List<CityObject> getBufferIntersectingObjects(CityObject co, Double buffersize) {
List<CityObject> intersectingObjects = new ArrayList<>();
try (Connection con = new ConnectionWrapper(H2GISDBFactory.openSpatialDataBase(DB_NAME))) {
try (PreparedStatement ps = con.prepareStatement("SELECT gmlid, bbox, data, type FROM features AS tab1" +
" WHERE ST_INTERSECTS(ST_BUFFER(tab1.geom,?), (SELECT GEOM FROM features WHERE gmlid = ?)) AND tab1.gmlid <> ?")) {
ps.setDouble(1, buffersize);
ps.setString(2, co.getGmlId().toString());
ps.setString(3, co.getGmlId().toString());
ResultSet rs = ps.executeQuery();
intersectingObjects.addAll(retrieveCityObjects(rs));
}
} catch (SQLException e) {
logger.error("Connection to database failed while trying to get buffer intersecting objects!");
logger.debug(e.getMessage());
}
return Collections.emptyList();
return intersectingObjects;
}
public static List<CityObject> getBBoxIntersectingObjects(CityObject co) {
......
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