Skip to content

Commit

Permalink
#368 improve structure analysis for roundabouts
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarc committed Aug 13, 2024
1 parent e9384f5 commit 98fffc6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class RouteSegmentAnalyzer(context: RouteDetailAnalysisContext) {
def analyze(): Seq[RouteAnalysisSegment] = {
Triplet.slide(context.links.routeLinkWays).foreach { case Triplet(previousRouteLinkWayOption, currentRouteLinkWay, nextRouteLinkWayOption) =>
if (isRoundabout(currentRouteLinkWay)) {
handleRoundabout(previousRouteLinkWayOption, currentRouteLinkWay, nextRouteLinkWayOption)
handleRoundabout(currentRouteLinkWay, nextRouteLinkWayOption)
}
else {
val linkFragments = StructureUtil.split(currentRouteLinkWay.nodeIds, context.nodes.nodeIds).map { nodeIds =>
Expand Down Expand Up @@ -81,19 +81,16 @@ class RouteSegmentAnalyzer(context: RouteDetailAnalysisContext) {
}

private def handleRoundabout(
previousRouteLinkWayOption: Option[RouteLinkWay],
currentRouteLinkWay: RouteLinkWay,
nextRouteLinkWayOption: Option[RouteLinkWay]
) = {
): Unit = {

finalizeSegmentElement()

nextRouteLinkWayOption match {
case None =>
// this is a closed loop at the end of the route
// elements += buildFragmentElement(currentRouteLinkWay, RoutePathDirection.Bidirectional, currentRouteLinkWay.nodeIds)
// should not be possible to get to this point in the code, because of following condition above:
// currentRouteLinkWay.link.hasNext
// this is a closed loop at the end of the route
elements += buildFragmentElement(currentRouteLinkWay, RoutePathDirection.Forward, currentRouteLinkWay.nodeIds)

case Some(nextRouteLinkWay) =>

Expand Down Expand Up @@ -298,6 +295,6 @@ class RouteSegmentAnalyzer(context: RouteDetailAnalysisContext) {
}

private def isRoundabout(routeLinkWay: RouteLinkWay): Boolean = {
routeLinkWay.link.direction == LinkDirection.RoundaboutRight && routeLinkWay.isClosedLoop && routeLinkWay.link.hasNext
routeLinkWay.link.direction == LinkDirection.RoundaboutRight && routeLinkWay.isClosedLoop
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ class Structure_53_WayRoundaboutTest extends UnitTest {
context.segments.shouldMatchTo(
Seq(
"segment-1 1>3",
" element-1 1>3 ↔ nodes=1, 2, 3, 4, 5, 6, 3",
" element-1 1>3 ↔ nodes=1, 2, 3",
" way-11 p n ■ loop fp bp head tail d forward",
" element-2 3>3 → nodes=3, 4, 5, 6, 3",
" way-12 p ■ n loop fp bp head tail d roundaboutright"
)
)

context.paths.shouldMatchTo(
Seq(
"forward=1>3 nodes=1, 2, 3, 4, 5, 6, 3",
"backward=3>1 nodes=3, 6, 5, 4, 3, 2, 1", // TODO redesign - this is NOK? nodeIds = Seq(3, 4, 5, 6, 3, 2, 1)
"backward=3>1 nodes=3, 2, 1",
)
)
pending
}
}

0 comments on commit 98fffc6

Please sign in to comment.