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
37c28627
Commit
37c28627
authored
Feb 16, 2026
by
Luna Riegel
Browse files
Refactor: Extract nested static class
parent
be7abbb1
Changes
3
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/check/error/FeatureCollisionError.java
View file @
37c28627
...
...
@@ -12,6 +12,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import
de.hft.stuttgart.citydoctor2.datastructure.GmlElement
;
import
de.hft.stuttgart.citydoctor2.datastructure.GmlId
;
import
de.hft.stuttgart.citydoctor2.datastructure.Polygon
;
import
de.hft.stuttgart.citydoctor2.utils.CollisionRecord
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -19,38 +20,38 @@ import java.util.StringJoiner;
public
class
FeatureCollisionError
implements
CheckError
{
private
final
CityObject
subjectFeature
;
private
final
Geometry
subjectGeom
;
private
final
Geometry
collidingGeom
;
private
final
GmlId
collidingFeatureId
;
private
final
Map
<
Polygon
,
List
<
Polygon
>>
collisionMap
;
public
FeatureCollisionError
(
CityObject
subjectFeature
,
Geometry
subjectGeom
,
GmlId
collidingFeatureId
,
Geometry
collidingGeom
,
Map
<
Polygon
,
List
<
Polygon
>>
collisionMap
)
{
this
.
subjectFeature
=
subjectFeature
;
this
.
subjectGeom
=
subjectGeom
;
this
.
collidingFeatureId
=
collidingFeatureId
;
this
.
collidingGeom
=
collidingGeom
;
this
.
collisionMap
=
collisionMap
;
private
final
CollisionRecord
collisionRecord
;
private
final
CityObject
subject
;
public
FeatureCollisionError
(
CollisionRecord
collisionRecord
,
CityObject
subject
)
{
this
.
collisionRecord
=
collisionRecord
;
this
.
subject
=
subject
;
}
public
CityObject
getSubjectFeature
()
{
return
subjectFeature
;
public
GmlId
getSubjectFeatureId
()
{
return
collisionRecord
.
getSubjectFeatureId
();
}
public
Geometry
getSubjectGeom
()
{
return
s
ubjectGeom
;
return
collisionRecord
.
getS
ubjectGeom
()
;
}
public
Geometry
getCollidingGeom
()
{
return
collidingGeom
;
return
colli
sionRecord
.
getColli
dingGeom
()
;
}
public
GmlId
getCollidingFeatureId
()
{
return
collidingFeatureId
;
return
colli
sionRecord
.
getColli
dingFeatureId
()
;
}
public
Map
<
Polygon
,
List
<
Polygon
>>
getCollisionMap
()
{
return
collisionMap
;
return
collisionRecord
.
getCollisionMap
();
}
public
CollisionRecord
getCollisionRecord
()
{
return
collisionRecord
;
}
@Override
...
...
@@ -65,9 +66,10 @@ public class FeatureCollisionError implements CheckError {
@Override
public
GmlElement
getFeature
()
{
return
subject
Feature
;
return
subject
;
}
@Override
public
void
accept
(
ErrorVisitor
errorVisitor
)
{
errorVisitor
.
visit
(
this
);
...
...
@@ -81,15 +83,16 @@ public class FeatureCollisionError implements CheckError {
@Override
public
void
report
(
ErrorReport
report
)
{
report
.
add
(
"Geometry"
,
s
ubjectGeom
.
getGmlId
().
toString
());
report
.
add
(
"Colliding with Feature"
,
collidingFeatureId
.
toString
());
report
.
add
(
"In Geometry"
,
collidingGeom
.
getGmlId
().
toString
());
collisionMap
.
forEach
((
subjectPoly
,
collisionList
)
->
{
report
.
add
(
"Geometry"
,
collisionRecord
.
getS
ubjectGeom
()
.
getGmlId
().
toString
());
report
.
add
(
"Colliding with Feature"
,
colli
sionRecord
.
getColli
dingFeatureId
()
.
toString
());
report
.
add
(
"In Geometry"
,
colli
sionRecord
.
getColli
dingGeom
()
.
getGmlId
().
toString
());
for
(
Map
.
Entry
<
Polygon
,
List
<
Polygon
>>
entry
:
collisionRecord
.
getCollisionMap
().
entrySet
())
{
StringJoiner
sj
=
new
StringJoiner
(
", "
);
collisionList
.
forEach
(
polygon
->
sj
.
add
(
polygon
.
getGmlId
().
toString
()));
report
.
add
(
"On Subject Polygon"
,
subjectPoly
.
toString
());
entry
.
getValue
()
.
forEach
(
polygon
->
sj
.
add
(
polygon
.
getGmlId
().
toString
()));
report
.
add
(
"On Subject Polygon"
,
entry
.
getKey
().
getGmlId
()
.
toString
());
report
.
add
(
"With Polygons"
,
sj
.
toString
());
});
}
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/CollisionRecord.java
0 → 100644
View file @
37c28627
package
de.hft.stuttgart.citydoctor2.utils
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.Geometry
;
import
de.hft.stuttgart.citydoctor2.datastructure.GmlId
;
import
de.hft.stuttgart.citydoctor2.datastructure.Polygon
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
CollisionRecord
implements
Serializable
{
private
final
Geometry
subjectGeom
;
private
final
Geometry
collidingGeom
;
private
final
GmlId
subjectFeatureId
;
private
final
GmlId
collidingFeatureId
;
private
final
Map
<
Polygon
,
List
<
Polygon
>>
collisionMap
;
public
CollisionRecord
(
Geometry
subjectGeom
,
Geometry
collidingGeom
,
CityObject
subjectFeature
,
CityObject
collidingFeature
,
List
<
Pair
<
Polygon
,
Polygon
>>
collisionPairs
)
{
this
.
subjectGeom
=
subjectGeom
;
this
.
collidingGeom
=
collidingGeom
;
this
.
subjectFeatureId
=
subjectFeature
.
getGmlId
();
this
.
collidingFeatureId
=
collidingFeature
.
getGmlId
();
this
.
collisionMap
=
new
HashMap
<>();
collisionPairs
.
forEach
(
pair
->
addCollision
(
pair
.
getValue0
(),
pair
.
getValue1
()));
}
private
void
addCollision
(
Polygon
subjectPoly
,
Polygon
collidingPoly
){
List
<
Polygon
>
polyList
=
collisionMap
.
computeIfAbsent
(
subjectPoly
,
k
->
new
ArrayList
<>());
polyList
.
add
(
collidingPoly
);
}
public
Map
<
Polygon
,
List
<
Polygon
>>
getCollisionMap
()
{
return
Collections
.
unmodifiableMap
(
collisionMap
);
}
public
Geometry
getSubjectGeom
()
{
return
subjectGeom
;
}
public
Geometry
getCollidingGeom
()
{
return
collidingGeom
;
}
public
GmlId
getSubjectFeatureId
()
{
return
subjectFeatureId
;
}
public
GmlId
getCollidingFeatureId
()
{
return
collidingFeatureId
;
}
}
CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/checks/topology/FeatureCollisionCheck.java
View file @
37c28627
...
...
@@ -29,12 +29,14 @@ import de.hft.stuttgart.citydoctor2.datastructure.TopLevelTransportFeature;
import
de.hft.stuttgart.citydoctor2.datastructure.Vegetation
;
import
de.hft.stuttgart.citydoctor2.edge.PolygonPolygonIntersection
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.CollisionRecord
;
import
de.hft.stuttgart.citydoctor2.utils.Pair
;
import
de.hft.stuttgart.citydoctor2.utils.PolygonIntersection
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -137,51 +139,42 @@ public class FeatureCollisionCheck extends Check{
}
});
List
<
CollisionRecord
>
collisions
=
new
ArrayList
<>();
subjGeoms
.
forEach
(
sGeo
->{
candidates
.
forEach
(
candidate
->{
if
(
candidate
.
getGmlId
().
equals
(
subject
.
getGmlId
()))
return
;
for
(
Geometry
sGeo
:
subjGeoms
)
{
for
(
CityObject
candidate
:
candidates
)
{
if
(
candidate
.
getGmlId
().
equals
(
subject
.
getGmlId
()))
{
continue
;
}
candidate
.
accept
(
new
CheckableUtilsVisitor
()
{
@Override
public
void
check
(
Geometry
geom
)
{
List
<
PolygonIntersection
>
intersections
=
getPolygonIntersections
(
sGeo
,
geom
);
if
(!
intersections
.
isEmpty
()){
CollisionRecord
collRec
=
new
CollisionRecord
(
sGeo
,
geom
,
candidate
);
for
(
PolygonIntersection
intersection
:
intersections
)
{
if
(
intersection
.
getType
()
==
PolygonIntersection
.
IntersectionType
.
NONE
){
continue
;
}
collRec
.
addCollision
(
intersection
.
getP1
(),
intersection
.
getP2
());
}
if
(!
collRec
.
getCollisionMap
().
isEmpty
())
collisions
.
add
(
collRec
);
List
<
Pair
<
Polygon
,
Polygon
>>
collisionPairs
=
getCollisionPairs
(
sGeo
,
geom
);
if
(!
collisionPairs
.
isEmpty
())
{
collisions
.
add
(
new
CollisionRecord
(
sGeo
,
geom
,
subject
,
candidate
,
collisionPairs
));
}
// List<PolygonPolygonIntersection> intersections =
// GeometryCollisionUtil.getGeometryIntersections(sGeo, geom, epsilon);
// if(!intersections.isEmpty()){
// CollisionRecord collRec = new CollisionRecord(sGeo, geom, candidate);
// intersections.forEach(ppi ->
// collRec.addCollision(ppi.getPolygon1().getOriginal(), ppi.getPolygon2().getOriginal()));
// collisions.add(collRec);
// }
}
});
}
);
}
);
}
}
if
(
collisions
.
isEmpty
()){
subject
.
addCheckResult
(
new
CheckResult
(
this
,
ResultStatus
.
OK
,
null
));
}
else
{
for
(
CollisionRecord
collRec
:
collisions
){
subject
.
addCheckResult
(
new
CheckResult
(
this
,
ResultStatus
.
ERROR
,
new
FeatureCollisionError
(
subject
,
collRec
.
getSubjectGeom
(),
collRec
.
getCollidingFeatureId
(),
collRec
.
getCollidingGeom
(),
collRec
.
getCollisionMap
())
));
}
collisions
.
forEach
(
collision
->
subject
.
addCheckResult
(
new
CheckResult
(
this
,
ResultStatus
.
ERROR
,
new
FeatureCollisionError
(
collision
,
subject
))));
}
}
private
List
<
Pair
<
Polygon
,
Polygon
>>
getCollisionPairs
(
Geometry
subjectGeom
,
Geometry
candidateGeom
){
List
<
PolygonIntersection
>
intersections
=
getPolygonIntersections
(
subjectGeom
,
candidateGeom
);
return
intersections
.
stream
()
.
filter
(
polySect
->
polySect
.
getType
()
!=
PolygonIntersection
.
IntersectionType
.
NONE
)
.
map
(
polySect
->
new
Pair
<>(
polySect
.
getP1
(),
polySect
.
getP2
()))
.
toList
();
}
private
List
<
PolygonIntersection
>
getPolygonIntersections
(
Geometry
subject
,
Geometry
candidate
){
List
<
PolygonIntersection
>
intersections
=
new
ArrayList
<>();
...
...
@@ -194,44 +187,6 @@ public class FeatureCollisionCheck extends Check{
}
private
static
class
CollisionRecord
{
private
final
Geometry
subjectGeom
;
private
final
Geometry
collidingGeom
;
private
final
GmlId
collidingFeatureId
;
private
final
Map
<
Polygon
,
List
<
Polygon
>>
collisionMap
;
public
CollisionRecord
(
Geometry
subjectGeom
,
Geometry
collidingGeom
,
CityObject
collidingFeature
){
this
.
subjectGeom
=
subjectGeom
;
this
.
collidingGeom
=
collidingGeom
;
this
.
collidingFeatureId
=
collidingFeature
.
getGmlId
();
this
.
collisionMap
=
new
HashMap
<>();
}
public
void
addCollision
(
Polygon
subjectPoly
,
Polygon
collidingPoly
){
List
<
Polygon
>
polyList
=
collisionMap
.
computeIfAbsent
(
subjectPoly
,
k
->
new
ArrayList
<>());
polyList
.
add
(
collidingPoly
);
}
public
Map
<
Polygon
,
List
<
Polygon
>>
getCollisionMap
()
{
return
collisionMap
;
}
public
Geometry
getSubjectGeom
()
{
return
subjectGeom
;
}
public
Geometry
getCollidingGeom
()
{
return
collidingGeom
;
}
public
GmlId
getCollidingFeatureId
()
{
return
collidingFeatureId
;
}
}
@Override
public
Check
createNewInstance
()
{
...
...
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