Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
CityDoctor2
Commits
4e6dafd4
Commit
4e6dafd4
authored
Jun 23, 2025
by
Riegel
Browse files
Feat: Implement getting all Features from database
parent
6ebc2949
Changes
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/database/DatabaseHandler.java
View file @
4e6dafd4
...
...
@@ -20,7 +20,6 @@ import java.sql.ResultSet;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
public
class
DatabaseHandler
{
...
...
@@ -98,7 +97,7 @@ public class DatabaseHandler {
public
static
CityObject
unmarshallCityObject
(
GmlId
id
)
{
try
(
Connection
con
=
new
ConnectionWrapper
(
H2GISDBFactory
.
openSpatialDataBase
(
DB_NAME
)))
{
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"SELECT
*
FROM features WHERE gmlid = ?"
))
{
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"SELECT
gmlid, bbox, data, type
FROM features WHERE gmlid = ?"
))
{
ps
.
setString
(
1
,
id
.
toString
());
ResultSet
rs
=
ps
.
executeQuery
();
if
(
rs
.
next
())
{
...
...
@@ -119,8 +118,20 @@ public class DatabaseHandler {
return
null
;
}
public
static
List
<?
extends
CityObject
>
getBufferIntersectingObjects
(
CityObject
co
,
Double
buffersize
)
{
ResultSet
rs
=
null
;
public
static
List
<
CityObject
>
getAllCityObjects
()
{
List
<
CityObject
>
cos
=
new
ArrayList
<>();
try
(
Connection
con
=
new
ConnectionWrapper
(
H2GISDBFactory
.
openSpatialDataBase
(
DB_NAME
)))
{
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"SELECT gmlid, bbox, data, type FROM features"
))
{
ResultSet
rs
=
ps
.
executeQuery
();
cos
.
addAll
(
retrieveCityObjects
(
rs
));
}
}
catch
(
SQLException
e
)
{
logger
.
error
(
"Connection to database failed while trying to get all CityObjects!"
);
logger
.
debug
(
e
.
getMessage
());
}
return
cos
;
}
public
static
List
<
CityObject
>
getBufferIntersectingObjects
(
CityObject
co
,
Double
buffersize
)
{
List
<
CityObject
>
intersectingObjects
=
new
ArrayList
<>();
try
(
Connection
con
=
new
ConnectionWrapper
(
H2GISDBFactory
.
openSpatialDataBase
(
DB_NAME
)))
{
...
...
@@ -143,7 +154,7 @@ public class DatabaseHandler {
List
<
CityObject
>
intersectingObjects
=
new
ArrayList
<>();
try
(
Connection
con
=
new
ConnectionWrapper
(
H2GISDBFactory
.
openSpatialDataBase
(
DB_NAME
)))
{
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"SELECT
*
FROM features AS tab1"
+
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"SELECT
gmlid, bbox, data, type
FROM features AS tab1"
+
" WHERE ST_INTERSECTS(tab1.geom, (SELECT GEOM FROM features WHERE gmlid = ?)) AND tab1.gmlid <> ?"
))
{
ps
.
setString
(
1
,
co
.
getGmlId
().
toString
());
ps
.
setString
(
2
,
co
.
getGmlId
().
toString
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment