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
a28be5d9
Commit
a28be5d9
authored
Jul 28, 2026
by
Luna Riegel
Browse files
Refactor: Simplify util connection visitor
parent
e5a1279a
Changes
1
Show whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/checks/topology/MisalignedUtilityConnectionCheck.java
View file @
a28be5d9
...
@@ -91,6 +91,7 @@ public class MisalignedUtilityConnectionCheck extends Check {
...
@@ -91,6 +91,7 @@ public class MisalignedUtilityConnectionCheck extends Check {
@Override
@Override
public
void
init
(
Map
<
CheckId
,
Map
<
String
,
String
>>
params
,
ParserConfiguration
config
,
CityObjectCache
cache
)
{
public
void
init
(
Map
<
CheckId
,
Map
<
String
,
String
>>
params
,
ParserConfiguration
config
,
CityObjectCache
cache
)
{
Map
<
String
,
String
>
localParameters
=
params
.
get
(
getCheckId
());
Map
<
String
,
String
>
localParameters
=
params
.
get
(
getCheckId
());
this
.
cache
=
cache
;
if
(
localParameters
==
null
)
{
if
(
localParameters
==
null
)
{
// no parameters
// no parameters
return
;
return
;
...
@@ -99,7 +100,6 @@ public class MisalignedUtilityConnectionCheck extends Check {
...
@@ -99,7 +100,6 @@ public class MisalignedUtilityConnectionCheck extends Check {
if
(
epsilonString
!=
null
)
{
if
(
epsilonString
!=
null
)
{
epsilon
=
Double
.
parseDouble
(
epsilonString
);
epsilon
=
Double
.
parseDouble
(
epsilonString
);
}
}
this
.
cache
=
cache
;
}
}
...
@@ -140,16 +140,22 @@ public class MisalignedUtilityConnectionCheck extends Check {
...
@@ -140,16 +140,22 @@ public class MisalignedUtilityConnectionCheck extends Check {
boolean
misalignedConnections
=
false
;
boolean
misalignedConnections
=
false
;
boolean
freeFloating
=
false
;
boolean
freeFloating
=
false
;
for
(
Geometry
sGeo
:
subjGeoms
)
{
for
(
Geometry
sGeo
:
subjGeoms
)
{
final
boolean
[]
connected
=
{
false
}
;
boolean
connected
=
false
;
final
boolean
[]
misalignment
=
{
false
}
;
boolean
misalignment
=
false
;
for
(
CityObject
candidate
:
candidates
)
{
for
(
CityObject
candidate
:
candidates
)
{
List
<
Geometry
>
candGeoms
=
new
ArrayList
<>();
candidate
.
accept
(
new
CheckableUtilsVisitor
()
{
candidate
.
accept
(
new
CheckableUtilsVisitor
()
{
@Override
@Override
public
void
check
(
Geometry
cGeo
)
{
public
void
check
(
Geometry
cGeo
)
{
if
(
sGeo
.
getLod
()
!=
cGeo
.
getLod
()){
if
(
sGeo
.
getLod
()
==
cGeo
.
getLod
())
{
return
;
candGeoms
.
add
(
cGeo
);
}
}
}
});
for
(
Geometry
cGeo:
candGeoms
){
List
<
PolygonIntersection
>
intersections
=
SelfIntersectionUtil
.
calculateGeometryIntersections
(
sGeo
,
cGeo
,
epsilon
);
List
<
PolygonIntersection
>
intersections
=
SelfIntersectionUtil
.
calculateGeometryIntersections
(
sGeo
,
cGeo
,
epsilon
);
intersections
=
intersections
.
stream
()
intersections
=
intersections
.
stream
()
.
filter
(
isect
->
isect
.
getType
()
!=
PolygonIntersection
.
IntersectionType
.
NONE
)
.
filter
(
isect
->
isect
.
getType
()
!=
PolygonIntersection
.
IntersectionType
.
NONE
)
...
@@ -161,44 +167,44 @@ public class MisalignedUtilityConnectionCheck extends Check {
...
@@ -161,44 +167,44 @@ public class MisalignedUtilityConnectionCheck extends Check {
List
<
Pair
<
Vertex
,
Vertex
>>
pairs
=
getVertexPairs
(
sGeo
,
cGeo
);
List
<
Pair
<
Vertex
,
Vertex
>>
pairs
=
getVertexPairs
(
sGeo
,
cGeo
);
if
(
pairs
.
size
()
<
3
)
{
if
(
pairs
.
size
()
<
3
)
{
if
(!
pairs
.
isEmpty
())
{
if
(!
pairs
.
isEmpty
())
{
subject
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_TO_UTILITY_CONNECTION_MISALIGNED
,
subject
.
addCheckResult
(
new
CheckResult
(
this
,
ResultStatus
.
ERROR
,
new
MisalignedConnectionError
(
sGeo
,
subject
,
candidate
.
getGmlId
(),
ResultStatus
.
ERROR
,
new
MisalignedConnectionError
(
sGeo
,
subject
,
candidate
.
getGmlId
(),
MisalignedConnectionError
.
MisalignmentType
.
HANGING
,
ErrorType
.
ERROR
)));
MisalignedConnectionError
.
MisalignmentType
.
HANGING
,
ErrorType
.
ERROR
)));
}
}
}
else
{
}
else
{
switch
(
checkConnectionAlignment
(
sGeo
,
cGeo
,
pairs
))
{
ConnectionAlignmentType
alignment
=
checkConnectionAlignment
(
sGeo
,
cGeo
,
pairs
);
switch
(
alignment
)
{
case
ALIGNED:
case
ALIGNED:
connected
[
0
]
=
true
;
connected
=
true
;
break
;
break
;
case
ASYMMETRIC_ROTATION:
case
ASYMMETRIC_ROTATION:
subject
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_TO_UTILITY_CONNECTION_MISALIGNED
,
subject
.
addCheckResult
(
new
CheckResult
(
this
,
ResultStatus
.
ERROR
,
new
MisalignedConnectionError
(
sGeo
,
subject
,
candidate
.
getGmlId
(),
ResultStatus
.
ERROR
,
new
MisalignedConnectionError
(
sGeo
,
subject
,
candidate
.
getGmlId
(),
MisalignmentType
.
ASYMMETRIC_ROTATION
,
ErrorType
.
ERROR
)));
MisalignmentType
.
ASYMMETRIC_ROTATION
,
ErrorType
.
ERROR
)));
misalignment
[
0
]
=
true
;
misalignment
=
true
;
break
;
break
;
case
SHEARED:
case
SHEARED:
subject
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_TO_UTILITY_CONNECTION_MISALIGNED
,
subject
.
addCheckResult
(
new
CheckResult
(
this
,
ResultStatus
.
ERROR
,
new
MisalignedConnectionError
(
sGeo
,
subject
,
candidate
.
getGmlId
(),
ResultStatus
.
ERROR
,
new
MisalignedConnectionError
(
sGeo
,
subject
,
candidate
.
getGmlId
(),
MisalignmentType
.
SHEARED
,
ErrorType
.
ERROR
)));
MisalignmentType
.
SHEARED
,
ErrorType
.
ERROR
)));
misalignment
[
0
]
=
true
;
misalignment
=
true
;
break
;
break
;
case
UNKNOWN:
case
UNKNOWN:
subject
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_TO_UTILITY_CONNECTION_MISALIGNED
,
subject
.
addCheckResult
(
new
CheckResult
(
this
,
ResultStatus
.
WARNING
,
new
MisalignedConnectionError
(
sGeo
,
subject
,
candidate
.
getGmlId
(),
ResultStatus
.
WARNING
,
new
MisalignedConnectionError
(
sGeo
,
subject
,
candidate
.
getGmlId
(),
MisalignmentType
.
UNKNOWN
,
ErrorType
.
WARNING
)));
MisalignmentType
.
UNKNOWN
,
ErrorType
.
WARNING
)));
misalignment
[
0
]
=
true
;
misalignment
=
true
;
break
;
break
;
}
}
}
}
}
}
});
if
(!
connected
)
{
if
(!
connected
[
0
])
{
// Geometry has no connections and is "floating in space"
// Geometry has no connections and is "floating in space"
freeFloating
=
true
;
freeFloating
=
true
;
FloatingUtilityError
err
=
new
FloatingUtilityError
(
subject
,
sGeo
);
FloatingUtilityError
err
=
new
FloatingUtilityError
(
subject
,
sGeo
);
subject
.
addCheckResult
(
new
CheckResult
(
this
,
ResultStatus
.
ERROR
,
err
));
subject
.
addCheckResult
(
new
CheckResult
(
this
,
ResultStatus
.
ERROR
,
err
));
}
else
if
(
misalignment
[
0
]
)
{
}
else
if
(
misalignment
)
{
misalignedConnections
=
true
;
misalignedConnections
=
true
;
}
}
}
}
...
...
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