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
04b94412
Commit
04b94412
authored
Feb 17, 2026
by
Luna Riegel
Browse files
Refactor: Convert Class to Record
parent
fb1d1c4f
Changes
4
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/check/error/FeatureCollisionError.java
View file @
04b94412
...
@@ -31,23 +31,23 @@ public class FeatureCollisionError implements CheckError {
...
@@ -31,23 +31,23 @@ public class FeatureCollisionError implements CheckError {
public
GmlId
getSubjectFeatureId
()
{
public
GmlId
getSubjectFeatureId
()
{
return
collisionRecord
.
getS
ubjectFeatureId
();
return
collisionRecord
.
s
ubjectFeatureId
();
}
}
public
Geometry
getSubjectGeom
()
{
public
Geometry
getSubjectGeom
()
{
return
collisionRecord
.
getS
ubjectGeom
();
return
collisionRecord
.
s
ubjectGeom
();
}
}
public
Geometry
getCollidingGeom
()
{
public
Geometry
getCollidingGeom
()
{
return
collisionRecord
.
getC
ollidingGeom
();
return
collisionRecord
.
c
ollidingGeom
();
}
}
public
GmlId
getCollidingFeatureId
()
{
public
GmlId
getCollidingFeatureId
()
{
return
collisionRecord
.
getC
ollidingFeatureId
();
return
collisionRecord
.
c
ollidingFeatureId
();
}
}
public
Map
<
Polygon
,
List
<
Polygon
>>
getCollisionMap
()
{
public
Map
<
Polygon
,
List
<
Polygon
>>
getCollisionMap
()
{
return
collisionRecord
.
getC
ollisionMap
();
return
collisionRecord
.
c
ollisionMap
();
}
}
public
CollisionRecord
getCollisionRecord
()
{
public
CollisionRecord
getCollisionRecord
()
{
...
@@ -83,10 +83,10 @@ public class FeatureCollisionError implements CheckError {
...
@@ -83,10 +83,10 @@ public class FeatureCollisionError implements CheckError {
@Override
@Override
public
void
report
(
ErrorReport
report
)
{
public
void
report
(
ErrorReport
report
)
{
report
.
add
(
"Geometry"
,
collisionRecord
.
getS
ubjectGeom
().
getGmlId
().
toString
());
report
.
add
(
"Geometry"
,
collisionRecord
.
s
ubjectGeom
().
getGmlId
().
toString
());
report
.
add
(
"Colliding with Feature"
,
collisionRecord
.
getC
ollidingFeatureId
().
toString
());
report
.
add
(
"Colliding with Feature"
,
collisionRecord
.
c
ollidingFeatureId
().
toString
());
report
.
add
(
"In Geometry"
,
collisionRecord
.
getC
ollidingGeom
().
getGmlId
().
toString
());
report
.
add
(
"In Geometry"
,
collisionRecord
.
c
ollidingGeom
().
getGmlId
().
toString
());
for
(
Map
.
Entry
<
Polygon
,
List
<
Polygon
>>
entry
:
collisionRecord
.
getC
ollisionMap
().
entrySet
())
{
for
(
Map
.
Entry
<
Polygon
,
List
<
Polygon
>>
entry
:
collisionRecord
.
c
ollisionMap
().
entrySet
())
{
StringJoiner
sj
=
new
StringJoiner
(
", "
);
StringJoiner
sj
=
new
StringJoiner
(
", "
);
entry
.
getValue
().
forEach
(
polygon
->
sj
.
add
(
polygon
.
getGmlId
().
toString
()));
entry
.
getValue
().
forEach
(
polygon
->
sj
.
add
(
polygon
.
getGmlId
().
toString
()));
report
.
add
(
"On Subject Polygon"
,
entry
.
getKey
().
getGmlId
().
toString
());
report
.
add
(
"On Subject Polygon"
,
entry
.
getKey
().
getGmlId
().
toString
());
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/CollisionRecord.java
View file @
04b94412
...
@@ -12,49 +12,25 @@ import java.util.HashMap;
...
@@ -12,49 +12,25 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
public
class
CollisionRecord
implements
Serializable
{
public
record
CollisionRecord
(
Geometry
subjectGeom
,
Geometry
collidingGeom
,
GmlId
subjectFeatureId
,
GmlId
collidingFeatureId
,
private
final
Geometry
subjectGeom
;
Map
<
Polygon
,
List
<
Polygon
>>
collisionMap
)
implements
Serializable
{
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
,
public
CollisionRecord
(
Geometry
subjectGeom
,
Geometry
collidingGeom
,
CityObject
subjectFeature
,
CityObject
collidingFeature
,
List
<
Pair
<
Polygon
,
Polygon
>>
collisionPairs
)
{
CityObject
collidingFeature
,
List
<
Pair
<
Polygon
,
Polygon
>>
collisionPairs
)
{
this
.
subjectGeom
=
subjectGeom
;
this
(
subjectGeom
,
collidingGeom
,
subjectFeature
.
getGmlId
(),
collidingFeature
.
getGmlId
(),
new
HashMap
<>());
this
.
collidingGeom
=
collidingGeom
;
this
.
subjectFeatureId
=
subjectFeature
.
getGmlId
();
this
.
collidingFeatureId
=
collidingFeature
.
getGmlId
();
this
.
collisionMap
=
new
HashMap
<>();
collisionPairs
.
forEach
(
pair
->
addCollision
(
pair
.
getValue0
(),
pair
.
getValue1
()));
collisionPairs
.
forEach
(
pair
->
addCollision
(
pair
.
getValue0
(),
pair
.
getValue1
()));
}
}
private
void
addCollision
(
Polygon
subjectPoly
,
Polygon
collidingPoly
){
private
void
addCollision
(
Polygon
subjectPoly
,
Polygon
collidingPoly
)
{
List
<
Polygon
>
polyList
=
collisionMap
.
computeIfAbsent
(
subjectPoly
,
k
->
new
ArrayList
<>());
List
<
Polygon
>
polyList
=
collisionMap
.
computeIfAbsent
(
subjectPoly
,
k
->
new
ArrayList
<>());
polyList
.
add
(
collidingPoly
);
polyList
.
add
(
collidingPoly
);
}
}
public
Map
<
Polygon
,
List
<
Polygon
>>
getCollisionMap
()
{
@Override
public
Map
<
Polygon
,
List
<
Polygon
>>
collisionMap
()
{
return
Collections
.
unmodifiableMap
(
collisionMap
);
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 @
04b94412
...
@@ -147,10 +147,13 @@ public class FeatureCollisionCheck extends Check{
...
@@ -147,10 +147,13 @@ public class FeatureCollisionCheck extends Check{
}
}
candidate
.
accept
(
new
CheckableUtilsVisitor
()
{
candidate
.
accept
(
new
CheckableUtilsVisitor
()
{
@Override
@Override
public
void
check
(
Geometry
geom
)
{
public
void
check
(
Geometry
cGeo
)
{
List
<
Pair
<
Polygon
,
Polygon
>>
collisionPairs
=
getCollisionPairs
(
sGeo
,
geom
);
if
(
sGeo
.
getLod
()
!=
cGeo
.
getLod
()){
return
;
}
List
<
Pair
<
Polygon
,
Polygon
>>
collisionPairs
=
getCollisionPairs
(
sGeo
,
cGeo
);
if
(!
collisionPairs
.
isEmpty
())
{
if
(!
collisionPairs
.
isEmpty
())
{
collisions
.
add
(
new
CollisionRecord
(
sGeo
,
g
eo
m
,
subject
,
candidate
,
collisionPairs
));
collisions
.
add
(
new
CollisionRecord
(
sGeo
,
cG
eo
,
subject
,
candidate
,
collisionPairs
));
}
}
}
}
});
});
...
...
CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/HighlightController.java
View file @
04b94412
...
@@ -66,6 +66,11 @@ public class HighlightController {
...
@@ -66,6 +66,11 @@ public class HighlightController {
}
}
}
}
/**
* Adds a highlight
* @param p
* @param currentTriGeom
*/
public
void
highlight
(
Polygon
p
,
TriangulatedGeometry
currentTriGeom
)
{
public
void
highlight
(
Polygon
p
,
TriangulatedGeometry
currentTriGeom
)
{
clearHighlights
();
clearHighlights
();
addPolygonHighlight
(
p
,
currentTriGeom
,
Color
.
RED
,
Color
.
BLUE
,
Color
.
ORANGE
);
addPolygonHighlight
(
p
,
currentTriGeom
,
Color
.
RED
,
Color
.
BLUE
,
Color
.
ORANGE
);
...
@@ -233,7 +238,7 @@ public class HighlightController {
...
@@ -233,7 +238,7 @@ public class HighlightController {
}
}
public
void
highlightGeometryCollisions
(
CollisionRecord
collRecord
,
TriangulatedGeometry
currentTriGeom
)
{
public
void
highlightGeometryCollisions
(
CollisionRecord
collRecord
,
TriangulatedGeometry
currentTriGeom
)
{
Map
<
Polygon
,
List
<
Polygon
>>
collisionMap
=
collRecord
.
getC
ollisionMap
();
Map
<
Polygon
,
List
<
Polygon
>>
collisionMap
=
collRecord
.
c
ollisionMap
();
collisionMap
.
keySet
().
forEach
(
subject
->
addPolygonHighlight
(
subject
,
currentTriGeom
,
Color
.
RED
,
Color
.
BLUE
,
Color
.
ORANGE
));
collisionMap
.
keySet
().
forEach
(
subject
->
addPolygonHighlight
(
subject
,
currentTriGeom
,
Color
.
RED
,
Color
.
BLUE
,
Color
.
ORANGE
));
Set
<
Polygon
>
collidingPolys
=
collisionMap
.
values
().
stream
().
flatMap
(
List:
:
stream
).
collect
(
Collectors
.
toSet
());
Set
<
Polygon
>
collidingPolys
=
collisionMap
.
values
().
stream
().
flatMap
(
List:
:
stream
).
collect
(
Collectors
.
toSet
());
collidingPolys
.
forEach
(
poly
->
addPolygonHighlight
(
poly
,
currentTriGeom
,
Color
.
DARKRED
,
Color
.
NAVY
,
Color
.
DARKORANGE
));
collidingPolys
.
forEach
(
poly
->
addPolygonHighlight
(
poly
,
currentTriGeom
,
Color
.
DARKRED
,
Color
.
NAVY
,
Color
.
DARKORANGE
));
...
...
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