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
a85b7b19
Commit
a85b7b19
authored
Dec 01, 2025
by
Luna Riegel
Browse files
Style: Rename functions and add JavaDoc
parent
670b2a9f
Changes
2
Show whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/database/EmbeddedDatabaseHandler.java
View file @
a85b7b19
...
@@ -225,60 +225,86 @@ public class EmbeddedDatabaseHandler {
...
@@ -225,60 +225,86 @@ public class EmbeddedDatabaseHandler {
}
}
/**
public
List
<
GmlId
>
getBufferIntersectingObjects
(
CityObject
co
,
double
bufferSize
)
{
* Retrieves a List of GmlIds of CityObjects that are candidates for a buffer collision with a given CityObject(subject),
return
getBufferIntersectingObjects
(
co
.
getGmlId
(),
bufferSize
);
* meaning the candidate's bbox intersects the subject's buffered bbox.
public
List
<
GmlId
>
getBufferCollisionCandidates
(
CityObject
co
,
double
bufferSize
)
{
* @param subject the subject CityObject
return
getBufferCollisionCandidates
(
co
.
getGmlId
(),
bufferSize
);
* @param bufferSize the buffer distance
* @return a List of GmlIds of buffer collision candidates
*/
public
List
<
GmlId
>
getBufferCollisionCandidates
(
CityObject
subject
,
double
bufferSize
)
{
return
getBufferCollisionCandidates
(
subject
.
getGmlId
(),
bufferSize
);
}
}
public
List
<
GmlId
>
getBufferCollisionCandidates
(
GmlId
gmlID
,
double
bufferSize
)
{
/**
* Retrieves a List of GmlIds of CityObjects that are candidates for a buffer collision with a given CityObject(subject),
* meaning the candidate's bbox intersects the subject's buffered bbox.
* @param subjectId the subject CityObject's GmlId
* @param bufferSize the buffer distance
* @return a List of GmlIds of buffer collision candidates
*/
public
List
<
GmlId
>
getBufferCollisionCandidates
(
GmlId
subjectId
,
double
bufferSize
)
{
List
<
GmlId
>
intersectingObjects
=
new
ArrayList
<>();
List
<
GmlId
>
intersectingObjects
=
new
ArrayList
<>();
try
(
Connection
con
=
dataSource
.
getConnection
())
{
try
(
Connection
con
=
dataSource
.
getConnection
())
{
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"SELECT gmlid FROM features AS tab1"
+
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"SELECT gmlid FROM features AS tab1"
+
" WHERE ST_INTERSECTS(ST_BUFFER(tab1.bbox,?), (SELECT bbox FROM features WHERE gmlid = ?)) "
+
" WHERE ST_INTERSECTS(ST_BUFFER(tab1.bbox,?), (SELECT bbox FROM features WHERE gmlid = ?)) "
+
"AND tab1.gmlid <> ?"
))
{
"AND tab1.gmlid <> ?"
))
{
ps
.
setDouble
(
1
,
bufferSize
);
ps
.
setDouble
(
1
,
bufferSize
);
ps
.
setString
(
2
,
gmlID
.
toString
());
ps
.
setString
(
2
,
subjectId
.
toString
());
ps
.
setString
(
3
,
gmlID
.
toString
());
ps
.
setString
(
3
,
subjectId
.
toString
());
ResultSet
rs
=
ps
.
executeQuery
();
ResultSet
rs
=
ps
.
executeQuery
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
intersectingObjects
.
add
(
new
GmlId
(
rs
.
getString
(
"gmlid"
)));
intersectingObjects
.
add
(
new
GmlId
(
rs
.
getString
(
"gmlid"
)));
}
}
}
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
logger
.
error
(
Localization
.
getText
(
"DatabaseHandler.getBufferIntersectFailure"
),
gmlID
);
logger
.
error
(
Localization
.
getText
(
"DatabaseHandler.getBufferIntersectFailure"
),
subjectId
);
logger
.
debug
(
e
.
getMessage
());
logger
.
debug
(
e
.
getMessage
());
}
}
return
intersectingObjects
;
return
intersectingObjects
;
}
}
public
List
<
GmlId
>
getBBoxCollisionCandidates
(
CityObject
co
)
{
/**
return
getBBoxCollisionCandidates
(
co
.
getGmlId
());
* Retrieves a List of GmlIds of CityObjects that are candidates for a geometry collision with a given CityObject(subject),
* meaning the bounding boxes of candidate and subject intersect.
* @param subject the subject CityObject
* @return a List of GmlIds of buffer collision candidates
*/
public
List
<
GmlId
>
getGeometryCollisionCandidates
(
CityObject
subject
)
{
return
getGeometryCollisionCandidates
(
subject
.
getGmlId
());
}
}
public
List
<
GmlId
>
getBBoxCollisionCandidates
(
GmlId
id
)
{
/**
* Retrieves a List of GmlIds of CityObjects that are candidates for a geometry collision with a given CityObject(subject),
* meaning the bounding boxes of candidate and subject intersect.
* @param subjectId the subject CityObject
* @return a List of GmlIds of buffer collision candidates
*/
public
List
<
GmlId
>
getGeometryCollisionCandidates
(
GmlId
subjectId
)
{
List
<
GmlId
>
intersectingObjects
=
new
ArrayList
<>();
List
<
GmlId
>
intersectingObjects
=
new
ArrayList
<>();
try
(
Connection
con
=
dataSource
.
getConnection
())
{
try
(
Connection
con
=
dataSource
.
getConnection
())
{
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"SELECT gmlid FROM features AS tab1"
+
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"SELECT gmlid FROM features AS tab1"
+
" WHERE ST_INTERSECTS(tab1.bbox, (SELECT bbox FROM features WHERE gmlid = ?)) AND tab1.gmlid <> ?"
))
" WHERE ST_INTERSECTS(tab1.bbox, (SELECT bbox FROM features WHERE gmlid = ?)) AND tab1.gmlid <> ?"
))
{
{
ps
.
setString
(
1
,
i
d
.
toString
());
ps
.
setString
(
1
,
subjectI
d
.
toString
());
ps
.
setString
(
2
,
i
d
.
toString
());
ps
.
setString
(
2
,
subjectI
d
.
toString
());
ResultSet
rs
=
ps
.
executeQuery
();
ResultSet
rs
=
ps
.
executeQuery
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
intersectingObjects
.
add
(
new
GmlId
(
rs
.
getString
(
"gmlid"
)));
intersectingObjects
.
add
(
new
GmlId
(
rs
.
getString
(
"gmlid"
)));
}
}
}
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
logger
.
error
(
Localization
.
getText
(
"DatabaseHandler.getBBoxIntersectFailure"
),
i
d
);
logger
.
error
(
Localization
.
getText
(
"DatabaseHandler.getBBoxIntersectFailure"
),
subjectI
d
);
logger
.
debug
(
e
.
getMessage
());
logger
.
debug
(
e
.
getMessage
());
}
}
return
intersectingObjects
;
return
intersectingObjects
;
}
}
/**
* Returns the number of top-level CityObjects entries that are currently in the embedded database.
* @return the count of top-level CityObjects in the database
*/
public
int
getFeatureCount
()
{
public
int
getFeatureCount
()
{
int
count
=
-
1
;
int
count
=
-
1
;
...
...
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/database/DataBaseHandlerTest.java
→
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/database/
Embedded
DataBaseHandlerTest.java
View file @
a85b7b19
...
@@ -27,7 +27,7 @@ import static org.junit.Assert.assertEquals;
...
@@ -27,7 +27,7 @@ import static org.junit.Assert.assertEquals;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
fail
;
import
static
org
.
junit
.
Assert
.
fail
;
public
class
DataBaseHandlerTest
{
public
class
Embedded
DataBaseHandlerTest
{
private
EmbeddedDatabaseHandler
handler
;
private
EmbeddedDatabaseHandler
handler
;
...
@@ -112,7 +112,7 @@ public class DataBaseHandlerTest {
...
@@ -112,7 +112,7 @@ public class DataBaseHandlerTest {
handler
.
marshallCityObject
(
b4
);
handler
.
marshallCityObject
(
b4
);
assertEquals
(
4
,
handler
.
getFeatureCount
());
assertEquals
(
4
,
handler
.
getFeatureCount
());
List
<
GmlId
>
objects
=
handler
.
get
BBox
CollisionCandidates
(
b
);
List
<
GmlId
>
objects
=
handler
.
get
Geometry
CollisionCandidates
(
b
);
assertEquals
(
1
,
objects
.
size
());
assertEquals
(
1
,
objects
.
size
());
assertEquals
(
4
,
handler
.
getFeatureCount
());
assertEquals
(
4
,
handler
.
getFeatureCount
());
...
...
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