From f19bef13b393d8c23dae2defb99c7b784bae370a Mon Sep 17 00:00:00 2001 From: vmarc Date: Fri, 12 Jul 2024 10:40:06 +0200 Subject: [PATCH] #368 migrate structure tests --- .../analysis/route/RouteNodeAnalysis.scala | 10 +- .../route/RouteNodeAnalysisFormatter.scala | 6 +- .../route/analyzers/RouteNodeAnalyzer.scala | 10 +- .../route/report/RouteLinksReport.scala | 6 +- .../report/RouteNodeAnalysisReport.scala | 6 +- .../route/report/RouteSegmentReport.scala | 6 +- .../report/StructureElementGroupsReport.scala | 6 +- .../structure/OldStructureAnalyzer.scala | 4 +- .../structure/RouteSegmentAnalyzer.scala | 36 +- .../route/structure/StructureAnalyzer.scala | 67 +- .../route/RouteAnalysisInspector.scala | 190 ------ .../analysis/route/RouteAnalysisTest.scala | 643 ------------------ .../RouteAnalyzerRouteWithoutWaysTest.scala | 2 +- .../ExpectedNameRouteAnalyzerTest.scala | 6 +- .../IncompleteRouteAnalyzerTest.scala | 2 +- .../analyzers/RouteNameAnalyzerTest.scala | 2 +- .../UnexpectedNodeRouteAnalyzerTest.scala | 6 +- .../RouteDetailAnalysisTestContext.scala | 26 +- .../structure/StructureTestSetupBuilder.scala | 14 +- ...ucture_01_SingleWayBidirectionalTest.scala | 2 +- .../Structure_02_SingleWayForwardTest.scala | 2 +- .../Structure_03_SingleWayBackwardTest.scala | 2 +- ...cture_04_SingleWayRoundaboutLoopTest.scala | 2 +- ...e_05_SingleWayRoundaboutNotALoopTest.scala | 2 +- .../Structure_11_DerivedDirectionTest.scala | 2 +- ...cture_12_DerivedDirectionReverseTest.scala | 2 +- ...cture_13_DerivedDirectionForwardTest.scala | 2 +- ...ture_14_DerivedDirectionBackwardTest.scala | 2 +- ...DerivedDirectionBackwardBackwardTest.scala | 2 +- .../Structure_21_ContinuousTest.scala | 2 +- ...re_22_ContinuousFirstWayReversedTest.scala | 2 +- ...tinuousSecondAndThirdWayReversedTest.scala | 2 +- ...tructure_31_GapSecondWayBackwardTest.scala | 2 +- .../structure/Structure_32_GapTest.scala | 2 +- .../structure/Structure_33_GapTest.scala | 2 +- .../structure/Structure_34_GapTest.scala | 2 +- ...ructure_41_ForwardNoBackwardPathTest.scala | 2 +- .../Structure_42_ForwardGapTest.scala | 2 +- .../Structure_43_ForwardBackwardTest.scala | 2 +- .../Structure_44_ForwardBackwardTest.scala | 2 +- .../Structure_45_ForwardForwardTest.scala | 2 +- .../Structure_46_ForwardForwardGapTest.scala | 2 +- .../Structure_51_RoundaboutTest.scala | 2 +- ...tructure_52_RoundaboutRoundaboutTest.scala | 2 +- .../Structure_53_WayRoundaboutTest.scala | 2 +- .../Structure_54_WayRoundaboutWayTest.scala | 2 +- .../Structure_55_DoubleRoundaboutTest.scala | 2 +- ...ructure_61_NonCircularRoundaboutTest.scala | 2 +- ...ructure_62_NonCircularRoundaboutTest.scala | 2 +- .../structure/Structure_71_5444896_Test.scala | 2 +- .../Structure_72_SplitRoundabout_Test.scala | 2 +- .../structure/Structure_73_Split_Test.scala | 2 +- .../structure/Structure_75_Split_Test.scala | 2 +- .../structure/Structure_76_Split_Test.scala | 2 +- .../structure/Structure_77_Split_Test.scala | 2 +- .../route/structure/Structure_N01_Test.scala | 20 +- .../route/structure/Structure_N02_Test.scala | 11 +- .../route/structure/Structure_N03_Test.scala | 11 +- .../route/structure/Structure_N04_Test.scala | 16 +- .../route/structure/Structure_N05_Test.scala | 24 +- .../route/structure/Structure_N06_Test.scala | 55 +- .../route/structure/Structure_N07_Test.scala | 67 +- .../route/structure/Structure_N08_Test.scala | 67 +- .../route/structure/Structure_N09_Test.scala | 74 +- .../route/structure/Structure_N10_Test.scala | 66 +- .../route/structure/Structure_N11_Test.scala | 45 +- .../route/structure/Structure_N12_Test.scala | 45 +- .../route/structure/Structure_N13_Test.scala | 38 +- .../route/structure/Structure_N14_Test.scala | 70 +- .../route/structure/Structure_N15_Test.scala | 70 +- .../route/structure/Structure_N16_Test.scala | 48 +- .../route/structure/Structure_N17_Test.scala | 47 +- .../route/structure/Structure_N18_Test.scala | 29 +- .../route/structure/Structure_N19_Test.scala | 29 +- .../route/structure/Structure_N20_Test.scala | 28 +- .../route/structure/Structure_N21_Test.scala | 69 ++ .../route/structure/Structure_N22_Test.scala | 70 ++ .../route/structure/Structure_N23_Test.scala | 70 ++ .../route/structure/Structure_N24_Test.scala | 70 ++ 79 files changed, 1183 insertions(+), 1076 deletions(-) delete mode 100644 server/src/test/scala/kpn/server/analyzer/engine/analysis/route/RouteAnalysisInspector.scala delete mode 100644 server/src/test/scala/kpn/server/analyzer/engine/analysis/route/RouteAnalysisTest.scala create mode 100644 server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N21_Test.scala create mode 100644 server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N22_Test.scala create mode 100644 server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N23_Test.scala create mode 100644 server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N24_Test.scala diff --git a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/RouteNodeAnalysis.scala b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/RouteNodeAnalysis.scala index c6a95a51e..19836f3c0 100644 --- a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/RouteNodeAnalysis.scala +++ b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/RouteNodeAnalysis.scala @@ -3,11 +3,13 @@ package kpn.server.analyzer.engine.analysis.route case class RouteNodeAnalysis( reversed: Boolean = false, // TODO redesign - obsolete? freeNodes: Seq[RouteNodeData] = Seq.empty, // TODO redesign - obsolete? - startNodes: Seq[RouteNodeData] = Seq.empty, - endNodes: Seq[RouteNodeData] = Seq.empty, + startNode: Option[RouteNodeData] = None, + endNode: Option[RouteNodeData] = None, + startTentacleFromNodes: Seq[RouteNodeData] = Seq.empty, + endTentacleToNodes: Seq[RouteNodeData] = Seq.empty, redundantNodes: Seq[RouteNodeData] = Seq.empty ) { - def nodes: Seq[RouteNodeData] = freeNodes ++ startNodes ++ endNodes ++ redundantNodes + def nodes: Seq[RouteNodeData] = startNode.toSeq ++ endNode.toSeq ++ startTentacleFromNodes ++ endTentacleToNodes - def nodeIds: Seq[Long] = (startNodes ++ endNodes).map(_.node.id) + def nodeIds: Seq[Long] = nodes.map(_.node.id) } diff --git a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/RouteNodeAnalysisFormatter.scala b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/RouteNodeAnalysisFormatter.scala index fbc465053..c25dc2505 100644 --- a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/RouteNodeAnalysisFormatter.scala +++ b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/RouteNodeAnalysisFormatter.scala @@ -5,8 +5,10 @@ class RouteNodeAnalysisFormatter(analysis: RouteNodeAnalysis) { def nodeStrings: Seq[String] = { List( nodeStrings("Free", analysis.freeNodes), - nodeStrings("Start", analysis.startNodes), - nodeStrings("End", analysis.endNodes), + nodeStrings("Start", analysis.startNode.toSeq), + nodeStrings("End", analysis.endNode.toSeq), + nodeStrings("Start tentacle from", analysis.startTentacleFromNodes), + nodeStrings("End tentacle to", analysis.endTentacleToNodes), nodeStrings("Redundant", analysis.redundantNodes), if (analysis.reversed) Seq("(reversed)") else Seq.empty ).flatten diff --git a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/analyzers/RouteNodeAnalyzer.scala b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/analyzers/RouteNodeAnalyzer.scala index 3666e85e7..066028b86 100644 --- a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/analyzers/RouteNodeAnalyzer.scala +++ b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/analyzers/RouteNodeAnalyzer.scala @@ -92,15 +92,17 @@ class RouteNodeAnalyzer(context: RouteDetailAnalysisContext) { val routeNodeAnalysis = RouteNodeAnalysis( reversed = false, freeNodes = Seq.empty, - startNodes = startNodes, - endNodes = endNodes, + startNode = startNodes.lastOption, + endNode = endNodes.headOption, + startTentacleFromNodes = startNodes.dropRight(1), + endTentacleToNodes = endNodes.drop(1), redundantNodes = redundantNodes ) - if (routeNodeAnalysis.startNodes.nonEmpty && !routeNodeAnalysis.startNodes.exists(_.isInWay)) { + if (routeNodeAnalysis.startNode.nonEmpty && !routeNodeAnalysis.startNode.exists(_.isInWay)) { facts += RouteNodeMissingInWays } - else if (routeNodeAnalysis.endNodes.nonEmpty && !routeNodeAnalysis.endNodes.exists(_.isInWay)) { + else if (routeNodeAnalysis.endNode.nonEmpty && !routeNodeAnalysis.endNode.exists(_.isInWay)) { facts += RouteNodeMissingInWays } diff --git a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/RouteLinksReport.scala b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/RouteLinksReport.scala index e0c0ac471..9462009bd 100644 --- a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/RouteLinksReport.scala +++ b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/RouteLinksReport.scala @@ -86,8 +86,10 @@ class RouteLinksReport(context: RouteDetailAnalysisContext) { private def networkNodeString(nodeIds: Seq[Long]): String = { Seq( - networkNodeStrings(nodeIds, "start", context.routeNodeAnalysis.startNodes), - networkNodeStrings(nodeIds, "end", context.routeNodeAnalysis.endNodes), + networkNodeStrings(nodeIds, "start", context.routeNodeAnalysis.startNode.toSeq), + networkNodeStrings(nodeIds, "end", context.routeNodeAnalysis.endNode.toSeq), + networkNodeStrings(nodeIds, "start tentacle", context.routeNodeAnalysis.startTentacleFromNodes), + networkNodeStrings(nodeIds, "end tentacle", context.routeNodeAnalysis.endTentacleToNodes), networkNodeStrings(nodeIds, "free", context.routeNodeAnalysis.freeNodes), networkNodeStrings(nodeIds, "redundant", context.routeNodeAnalysis.redundantNodes) ).flatten.mkString(", ") diff --git a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/RouteNodeAnalysisReport.scala b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/RouteNodeAnalysisReport.scala index 393e0273e..32c914b1d 100644 --- a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/RouteNodeAnalysisReport.scala +++ b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/RouteNodeAnalysisReport.scala @@ -7,7 +7,7 @@ object RouteNodeAnalysisReport { def report(context: RouteDetailAnalysisContext): String = { val routeNodeAnalysis = context.routeNodeAnalysis - if (routeNodeAnalysis.startNodes.nonEmpty || routeNodeAnalysis.endNodes.nonEmpty || routeNodeAnalysis.freeNodes.nonEmpty || routeNodeAnalysis.redundantNodes.nonEmpty) { + if (routeNodeAnalysis.startNode.nonEmpty || routeNodeAnalysis.endNode.nonEmpty || routeNodeAnalysis.freeNodes.nonEmpty || routeNodeAnalysis.redundantNodes.nonEmpty) { s""" | | @@ -19,8 +19,8 @@ object RouteNodeAnalysisReport { | | | - | ${routeNodeAnalysis.startNodes.map(n => routeNodeReport("startNode", n)).mkString} - | ${routeNodeAnalysis.endNodes.map(n => routeNodeReport("endNode", n)).mkString} + | ${routeNodeAnalysis.startNode.map(n => routeNodeReport("startNode", n)).mkString} + | ${routeNodeAnalysis.endNode.map(n => routeNodeReport("endNode", n)).mkString} | ${routeNodeAnalysis.freeNodes.map(n => routeNodeReport("freeNode", n)).mkString} | ${routeNodeAnalysis.redundantNodes.map(n => routeNodeReport("redundantNode", n)).mkString} | diff --git a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/RouteSegmentReport.scala b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/RouteSegmentReport.scala index 61a9f4b76..940b77f1d 100644 --- a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/RouteSegmentReport.scala +++ b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/RouteSegmentReport.scala @@ -124,8 +124,10 @@ class RouteSegmentReport(context: RouteDetailAnalysisContext) { private def networkNodeString(nodeIds: Seq[Long]): String = { Seq( - networkNodeStrings(nodeIds, "start", context.routeNodeAnalysis.startNodes), - networkNodeStrings(nodeIds, "end", context.routeNodeAnalysis.endNodes), + networkNodeStrings(nodeIds, "start", context.routeNodeAnalysis.startNode.toSeq), + networkNodeStrings(nodeIds, "end", context.routeNodeAnalysis.endNode.toSeq), + networkNodeStrings(nodeIds, "start tentacle", context.routeNodeAnalysis.startTentacleFromNodes), + networkNodeStrings(nodeIds, "end tentacle", context.routeNodeAnalysis.endTentacleToNodes), networkNodeStrings(nodeIds, "free", context.routeNodeAnalysis.freeNodes), networkNodeStrings(nodeIds, "redundant", context.routeNodeAnalysis.redundantNodes) ).flatten.mkString(", ") diff --git a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/StructureElementGroupsReport.scala b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/StructureElementGroupsReport.scala index 106e504c7..ad9908bd4 100644 --- a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/StructureElementGroupsReport.scala +++ b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/report/StructureElementGroupsReport.scala @@ -84,8 +84,10 @@ class StructureElementGroupsReport(context: RouteDetailAnalysisContext) { private def networkNodes(fragment: StructureFragment): String = { Seq( - fragmentNodes(fragment, "start", context.routeNodeAnalysis.startNodes), - fragmentNodes(fragment, "end", context.routeNodeAnalysis.endNodes), + fragmentNodes(fragment, "start", context.routeNodeAnalysis.startNode.toSeq), + fragmentNodes(fragment, "end", context.routeNodeAnalysis.endNode.toSeq), + fragmentNodes(fragment, "start tentacle", context.routeNodeAnalysis.startTentacleFromNodes), + fragmentNodes(fragment, "end tentacle", context.routeNodeAnalysis.endTentacleToNodes), fragmentNodes(fragment, "free", context.routeNodeAnalysis.freeNodes), fragmentNodes(fragment, "redundant", context.routeNodeAnalysis.redundantNodes) ).flatten.mkString(", ") diff --git a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/structure/OldStructureAnalyzer.scala b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/structure/OldStructureAnalyzer.scala index 87e179d44..2e4907fb4 100644 --- a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/structure/OldStructureAnalyzer.scala +++ b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/structure/OldStructureAnalyzer.scala @@ -6,8 +6,8 @@ class OldStructureAnalyzer(traceEnabled: Boolean = false) { def analyze(routeNodeAnalysis: RouteNodeAnalysis, elementGroups: Seq[StructureElementGroup]): OldStructure = { - val mainStartNode = routeNodeAnalysis.startNodes.lastOption - val mainEndNode = routeNodeAnalysis.endNodes.headOption + val mainStartNode = routeNodeAnalysis.startNode.lastOption + val mainEndNode = routeNodeAnalysis.endNode.headOption if (elementGroups.size != 1) { val otherPaths: Seq[OldStructurePath] = { diff --git a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/structure/RouteSegmentAnalyzer.scala b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/structure/RouteSegmentAnalyzer.scala index 3a014a0a6..133b4c7d7 100644 --- a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/structure/RouteSegmentAnalyzer.scala +++ b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/structure/RouteSegmentAnalyzer.scala @@ -37,17 +37,13 @@ class RouteSegmentAnalyzer(context: RouteDetailAnalysisContext) { } if (context.routeNodeAnalysis.nodeIds.contains(linkFragments.head.fromNodeId)) { - if (fragments.nonEmpty) { - elements += buildSegmentElement(fragments.toSeq) - fragments.clear() - } + finalizeSegmentElement() } linkFragments.foreach { fragment => if (context.routeNodeAnalysis.nodeIds.contains(fragment.nodeIds.last)) { fragments += fragment - elements += buildSegmentElement(fragments.toSeq) - fragments.clear() + finalizeSegmentElement() } else { fragments += fragment @@ -55,27 +51,20 @@ class RouteSegmentAnalyzer(context: RouteDetailAnalysisContext) { } if (!currentRouteLinkWay.link.hasNext) { - if (fragments.nonEmpty) { - elements += buildSegmentElement(fragments.toSeq) - fragments.clear() - } + finalizeSegmentElement() segments += buildSegment(segments.size + 1, elements.toSeq) elements.clear() } else { val change = isDirectionChange(currentRouteLinkWay, nextRouteLinkWayOption) if (change) { - elements += buildSegmentElement(fragments.toSeq) - fragments.clear() + finalizeSegmentElement() } } } } - if (fragments.nonEmpty) { // TODO redesign - do we ever get here? - elements += buildSegmentElement(fragments.toSeq) - fragments.clear() - } + finalizeSegmentElement() if (elements.nonEmpty) { // TODO redesign - do we ever get here? segments += buildSegment(segments.size + 1, elements.toSeq) @@ -85,11 +74,7 @@ class RouteSegmentAnalyzer(context: RouteDetailAnalysisContext) { } private def handleRoundabout(previousRouteLinkWayOption: Option[RouteLinkWay], currentRouteLinkWay: RouteLinkWay, nextRouteLinkWayOption: Option[RouteLinkWay]) = { - // finalize current element, if any - if (fragments.nonEmpty) { - elements += buildSegmentElement(fragments.toSeq) - fragments.clear() - } + finalizeSegmentElement() nextRouteLinkWayOption match { case None => @@ -239,7 +224,7 @@ class RouteSegmentAnalyzer(context: RouteDetailAnalysisContext) { } } - def buildFragmentElement(routeLinkWay: RouteLinkWay, direction: RoutePathDirection, nodeIds: Seq[Long]): NewRouteSegmentElement = { + private def buildFragmentElement(routeLinkWay: RouteLinkWay, direction: RoutePathDirection, nodeIds: Seq[Long]): NewRouteSegmentElement = { // this is a closed loop at the end of the route val fragment = NewRouteSegmentElementFragment( fragmentIds.next(), @@ -274,4 +259,11 @@ class RouteSegmentAnalyzer(context: RouteDetailAnalysisContext) { Seq.empty // filled in later during path analysis ) } + + private def finalizeSegmentElement(): Unit = { + if (fragments.nonEmpty) { + elements += buildSegmentElement(fragments.toSeq) + fragments.clear() + } + } } diff --git a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/structure/StructureAnalyzer.scala b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/structure/StructureAnalyzer.scala index e06ccc017..f5a05fce6 100644 --- a/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/structure/StructureAnalyzer.scala +++ b/server/src/main/scala/kpn/server/analyzer/engine/analysis/route/structure/StructureAnalyzer.scala @@ -35,21 +35,18 @@ class StructureAnalyzer(traceEnabled: Boolean = false) { ) } else { - val mainStartNodeOption = routeNodeAnalysis.startNodes.lastOption - val mainEndNodeOption = routeNodeAnalysis.endNodes.headOption - - val structureOption = mainStartNodeOption match { + val structureOption = routeNodeAnalysis.startNode match { case None => None case Some(mainStartNode) => - mainEndNodeOption match { + routeNodeAnalysis.endNode match { case None => None case Some(mainEndNode) => doAnalyzeNodeNetworkRoute( - routeNodeAnalysis: RouteNodeAnalysis, - mainStartNode: RouteNodeData, - mainEndNode: RouteNodeData, - segments: Seq[NewRouteSegment], - paths: Seq[RoutePath] + routeNodeAnalysis, + mainStartNode, + mainEndNode, + segments, + paths ) } } @@ -92,7 +89,7 @@ class StructureAnalyzer(traceEnabled: Boolean = false) { } val backwardPath: Option[StructurePath] = { - paths.reverse.find(_.toNodeId == mainEndNode.node.id) match { + paths.find(_.toNodeId == mainEndNode.node.id) match { case None => None case Some(lastBackwardPath) => Some( @@ -110,32 +107,40 @@ class StructureAnalyzer(traceEnabled: Boolean = false) { } } - val usedPathIds = forwardPath.toSeq.flatMap(_.pathIds) ++ backwardPath.toSeq.flatMap(_.pathIds) - val remainingPaths = paths.filterNot(path => usedPathIds.contains(path.id)) - - val startTentacleFromNodes = routeNodeAnalysis.startNodes.dropRight(1) - val startTentaclePaths = startTentacleFromNodes.flatMap { fromNode => - remainingPaths.find(_.fromNodeId == fromNode.node.id) match { - case None => None - case Some(firstPath) => - Some( - StructurePath( - firstPath.fromNodeId, - firstPath.toNodeId, - Seq( - StructurePathElement( - firstPath, - reversed = false + val startTentaclePaths = { + val usedPathIds = forwardPath.toSeq.flatMap(_.pathIds) ++ backwardPath.toSeq.flatMap(_.pathIds) + val remainingPaths = paths.filterNot(path => usedPathIds.contains(path.id)) + routeNodeAnalysis.startTentacleFromNodes.flatMap { fromNode => + remainingPaths.find(_.fromNodeId == fromNode.node.id) match { + case None => None + case Some(firstPath) => + Some( + StructurePath( + firstPath.fromNodeId, + firstPath.toNodeId, + Seq( + StructurePathElement( + firstPath, + reversed = false + ) ) ) ) - ) + } } } - val endTentacleToNodes = routeNodeAnalysis.endNodes.drop(1) - val endTentaclePaths = endTentacleToNodes.flatMap { toNode => - remainingPaths.find(_.toNodeId == toNode.node.id) match { + val endTentaclePaths = routeNodeAnalysis.endTentacleToNodes.flatMap { toNode => + val usedPathIds = forwardPath.toSeq.flatMap(_.pathIds) ++ backwardPath.toSeq.flatMap(_.pathIds) ++ startTentaclePaths.flatMap(_.pathIds) + val remainingPaths = paths.filterNot(path => usedPathIds.contains(path.id)) + remainingPaths.find { path => + if (path.direction == RoutePathDirection.Backward) { + path.fromNodeId == toNode.node.id + } + else { + path.toNodeId == toNode.node.id + } + } match { case None => None case Some(firstPath) => Some( diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/RouteAnalysisInspector.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/RouteAnalysisInspector.scala deleted file mode 100644 index cffd1bdd1..000000000 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/RouteAnalysisInspector.scala +++ /dev/null @@ -1,190 +0,0 @@ -package kpn.server.analyzer.engine.analysis.route - -import kpn.api.common.SharedTestObjects -import kpn.api.common.data.raw.RawData -import kpn.api.common.data.raw.RawRelation -import kpn.api.custom.Fact -import kpn.api.custom.Tags -import kpn.core.data.DataBuilder -import kpn.server.analyzer.engine.analysis.location.LocationAnalyzerFixed -import kpn.server.analyzer.engine.analysis.route.analyzers.RouteCountryAnalyzerImpl -import kpn.server.analyzer.engine.analysis.route.analyzers.RouteLocationAnalyzer -import kpn.server.analyzer.engine.analysis.route.analyzers.RouteLocationAnalyzerMock -import kpn.server.analyzer.engine.analysis.route.analyzers.RouteTileAnalyzer -import kpn.server.analyzer.engine.analysis.route.domain.RouteDetailAnalysisContext -import kpn.server.analyzer.engine.tile.OldLinesTileCalculatorImpl -import kpn.server.analyzer.engine.tile.OldTileCalculatorImpl -import kpn.server.analyzer.engine.tile.RouteTileCalculatorImpl -import kpn.server.repository.RouteRepository -import org.scalamock.scalatest.MockFactory -import org.scalatest.Assertions - -import scala.collection.mutable.ListBuffer - -class RouteAnalysisInspector extends MockFactory with SharedTestObjects { - - private val factsBuffer = ListBuffer[Fact]() - private val startNodeIdBuffer = ListBuffer[Long]() - private val endNodeIdBuffer = ListBuffer[Long]() - private val startTentacleNodeIdBuffer = ListBuffer[Long]() - private val endTentacleNodeIdBuffer = ListBuffer[Long]() - private val unexpectedNodeIdBuffer = ListBuffer[Long]() - private val forwardNodeIdBuffer = ListBuffer[Long]() - private val backwardNodeIdBuffer = ListBuffer[Long]() - private val tentacleBuffer = ListBuffer[Seq[Long]]() - private val structureBuffer = ListBuffer[String]() - - def fact(fact: Fact): Unit = factsBuffer.append(fact) - - def startNode(nodeId: Long): Unit = startNodeIdBuffer.append(nodeId) - - def endNode(nodeId: Long): Unit = endNodeIdBuffer.append(nodeId) - - def startTentacleNode(nodeId: Long): Unit = startTentacleNodeIdBuffer.append(nodeId) - - def endTentacleNode(nodeId: Long): Unit = endTentacleNodeIdBuffer.append(nodeId) - - def unexpectedNode(nodeId: Long): Unit = unexpectedNodeIdBuffer.append(nodeId) - - def forward(nodeIds: Long*): Unit = forwardNodeIdBuffer.appendAll(nodeIds) - - def backward(nodeIds: Long*): Unit = backwardNodeIdBuffer.appendAll(nodeIds) - - def tentacle(nodeIds: Long*): Unit = tentacleBuffer.append(nodeIds) - - def structure(segmentString: String): Unit = structureBuffer.append(segmentString) - - def analyze(d: RouteTestData): Unit = { - - val tagValues = Seq( - Some("type" -> "route"), - Some("network:type" -> "node_network"), - Some("network" -> d.scopedNetworkType.key), - Some("route" -> d.scopedNetworkType.networkType.routeTagValues.head), - if (d.routeName.nonEmpty) Some("ref" -> d.routeName) else None - ).flatten - - val tags = Tags.from(tagValues *) ++ d.routeTags - - val rr: RawRelation = newRawRelation(10, members = d.members, tags = tags) - val rawData = RawData(None, d.nodes, d.ways, Seq(rr)) - val data = new DataBuilder(rawData).data - val relation = data.relations(rr.id) - - val tileCalculator = new OldTileCalculatorImpl() - val linesTileCalculator = new OldLinesTileCalculatorImpl(tileCalculator) - val routeTileCalculator = new RouteTileCalculatorImpl(linesTileCalculator) - val routeTileAnalyzer = new RouteTileAnalyzer(routeTileCalculator) - val locationAnalyzer = new LocationAnalyzerFixed() - val routeRepository = stub[RouteRepository] - val routeCountryAnalyzer = new RouteCountryAnalyzerImpl(locationAnalyzer, routeRepository) - val routeLocationAnalyzer: RouteLocationAnalyzer = new RouteLocationAnalyzerMock() - val routeAnalyzer = new RouteDetailMainAnalyzerImpl( - routeCountryAnalyzer, - routeLocationAnalyzer, - routeTileAnalyzer - ) - val context = routeAnalyzer.analyze(relation, None).get - - val report = new RouteAnalysisReport(context).report - if (report.nonEmpty) { - Assertions.fail("Route analysis failed!\n" + report) - } - } - - private class RouteAnalysisReport(context: RouteDetailAnalysisContext) { - - def report: String = { - val ra = context.oldRouteDetailAnalysis.routeDetail.analysis - - Seq( - evaluateMissingFacts, - evaluateUnexpectedFacts, - - evaluate("Old start node", startNodeIdBuffer.toSeq, ra.map.startNodes.map(_.id)), - evaluate("New start node", startNodeIdBuffer.toSeq, context.routeNodeAnalysis.startNodes.map(_.node.id).lastOption.toSeq), - - evaluate("Old end node", endNodeIdBuffer.toSeq, context.oldRouteDetailAnalysis.routeDetail.analysis.map.endNodes.map(_.id)), - evaluate("New end node", endNodeIdBuffer.toSeq, context.routeNodeAnalysis.endNodes.map(_.node.id).headOption.toSeq), - - evaluate("Old start tentacle node", startTentacleNodeIdBuffer.toSeq, context.oldRouteDetailAnalysis.routeDetail.analysis.map.startTentacleNodes.map(_.id)), - evaluate("New start tentacle node", startTentacleNodeIdBuffer.toSeq, context.routeNodeAnalysis.startNodes.map(_.node.id).dropRight(1)), - - evaluate("Old end tentacle node", endTentacleNodeIdBuffer.toSeq, context.oldRouteDetailAnalysis.routeDetail.analysis.map.endTentacleNodes.map(_.id)), - evaluate("New end tentacle node", endTentacleNodeIdBuffer.toSeq, context.routeNodeAnalysis.endNodes.map(_.node.id).drop(1)), - - evaluate("Unexpected node", unexpectedNodeIdBuffer.toSeq, context.oldRouteDetailAnalysis.routeDetail.analysis.unexpectedNodeIds), - - evaluate("Old forward nodes", forwardNodeIdBuffer.toSeq, context.structure.forwardNodeIds), - evaluate("New forward nodes", forwardNodeIdBuffer.toSeq, context.newStructure.forwardPath.toSeq.flatMap(_.nodeIds)), - - evaluate("Old backward nodes", backwardNodeIdBuffer.toSeq, context.oldRouteDetailAnalysis.structure.backwardNodeIds), - evaluate("New backward nodes", backwardNodeIdBuffer.toSeq, context.newStructure.backwardPath.toSeq.flatMap(_.nodeIds)), - - evaluateTentacles, - evaluateLong("Structure", structureBuffer.toSeq, context.oldRouteDetailAnalysis.routeDetail.analysis.structureStrings) - // TODO add tests for breakpoints (forward and backward) ? - - ).flatten.map(s => " - " + s).mkString("\n") - } - - private def evaluateMissingFacts: Option[String] = { - val missingFacts = factsBuffer.toSet -- context.oldRouteDetailAnalysis.routeDetail.oldFacts // TODO redesign - switch from oldFacts to facts - if (missingFacts.nonEmpty) { - Some("Missing fact(s): " + missingFacts) - } - else { - None - } - } - - private def evaluateUnexpectedFacts: Option[String] = { - val unexpectedFacts = context.oldRouteDetailAnalysis.routeDetail.oldFacts.toSet -- factsBuffer.toSet // TODO redesign - switch from oldFacts to facts - if (unexpectedFacts.nonEmpty) { - Some("Unexpected fact(s): " + unexpectedFacts.mkString(", ")) - } - else { - None - } - } - - private def evaluate(title: String, expected: Seq[Long], actual: Seq[Long]): Option[String] = { - if (expected != actual) { - Some(title + " mismatch, expected: " + expected.mkString("+") + ", but found: " + actual.mkString("+")) - } - else { - None - } - } - - private def evaluateLong(title: String, expected: Seq[String], actual: Seq[String]): Option[String] = { - if (expected != actual) { - Some(title + " mismatch,\n expected: " + expected.mkString("+") + "\n found: " + actual.mkString("+")) - } - else { - None - } - } - - private def evaluate2(expected: Seq[Seq[String]], actual: Seq[Seq[String]]): Option[String] = { - if (expected != actual) { - Some("Start node mismatch, expected: " + expected.mkString("+") + ", but found: " + actual.mkString("+")) - } - else { - None - } - } - - private def evaluateTentacles: Option[String] = { - val startTentacleNodeIds = context.oldRouteDetailAnalysis.structure.startTentaclePaths.flatMap(_.segments).map(_.nodes.map(_.id)) - val endTentacleNodeIds = context.oldRouteDetailAnalysis.structure.endTentaclePaths.flatMap(_.segments).map(_.nodes.map(_.id)) - val tentacleNodeIds = startTentacleNodeIds ++ endTentacleNodeIds - if (tentacleBuffer != tentacleNodeIds) { - Some("Tentacle mismatch, found: " + tentacleNodeIds.mkString("+") + ", but expected: " + tentacleBuffer.mkString("+") + ".\n") - } - else { - None - } - } - } -} diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/RouteAnalysisTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/RouteAnalysisTest.scala deleted file mode 100644 index 33062d0fe..000000000 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/RouteAnalysisTest.scala +++ /dev/null @@ -1,643 +0,0 @@ -package kpn.server.analyzer.engine.analysis.route - -import kpn.api.custom.Fact.RouteBroken -import kpn.api.custom.Fact.RouteNotBackward -import kpn.api.custom.Fact.RouteNotContinious -import kpn.api.custom.Fact.RouteNotForward -import kpn.api.custom.Fact.RouteNotOneWay -import kpn.api.custom.Fact.RouteOneWay -import kpn.api.custom.Fact.RouteUnusedSegments -import kpn.api.custom.ScopedNetworkType -import kpn.api.custom.Tags -import kpn.core.util.UnitTest - -class RouteAnalysisTest extends UnitTest { - - /* - * TODO: - * - * loops - * tentacle(s) at start - * tentacle(s) at end - * - * route broken in (multiple) tentacles - * - * - start route with way that has "forward" role --> firstNode logic is different from role="" || role="backward" - * - start route with way that has "backward" role - * ==> role is needed for tentacles at the start!? - * - * - * - * - */ - - test("06 tentacle at end") { - - val d = new RouteTestData("01-02") { - node(1, "01") - node(5, "02") - node(7, "02") - - memberWay(10, "", 1, 2) // 01 - memberWay(11, "", 2, 3) - memberWay(12, "", 3, 4) - memberWay(13, "", 4, 5) // first 02 - memberWay(14, "", 5, 6) - memberWay(15, "", 6, 7) // second 02 - } - - new RouteAnalysisInspector() { - - startNode(1) - endNode(5) - endTentacleNode(7) - - forward(1, 2, 3, 4, 5) - backward(5, 4, 3, 2, 1) - tentacle(5, 6, 7) - - structure("forward=(01-02.a via +<01- 10>+<11>+<12>+<-02.a 13>)") - structure("backward=(02.a-01 via -<-02.a 13>-<12>-<11>-<01- 10>)") - structure("endTentacles=(02.a-02.b via +<02.a- 14>+<-02.b 15>)") - }.analyze(d) - } - - test("07 multiple tentacles stacked at end") { - - val d = new RouteTestData("01-02") { - node(1, "01") - node(5, "02") - node(7, "02") - node(9, "02") - - memberWay(10, "", 1, 2) // 01 - memberWay(11, "", 2, 3) - memberWay(12, "", 3, 4) - memberWay(13, "", 4, 5) // first 02 - memberWay(14, "", 5, 6) - memberWay(15, "", 6, 7) // second 02 - memberWay(16, "", 7, 8) - memberWay(17, "", 8, 9) // third 02 - } - - new RouteAnalysisInspector() { - - startNode(1) - endNode(5) - - endTentacleNode(7) - endTentacleNode(9) - - forward(1, 2, 3, 4, 5) - backward(5, 4, 3, 2, 1) - tentacle(5, 6, 7) - tentacle(7, 8, 9) - - structure("forward=(01-02.a via +<01- 10>+<11>+<12>+<-02.a 13>)") - structure("backward=(02.a-01 via -<-02.a 13>-<12>-<11>-<01- 10>)") - structure("endTentacles=(02.a-02.b via +<02.a- 14>+<-02.b 15>,02.b-02.c via +<02.b- 16>+<-02.c 17>)") - }.analyze(d) - } - - test("08 multiple forked tentacles at end") { - - val d = new RouteTestData("01-02") { - node(1, "01") - node(5, "02") - node(7, "02") - node(9, "02") - - memberWay(10, "", 1, 2) // 01 - memberWay(11, "", 2, 3) - memberWay(12, "", 3, 4) - memberWay(13, "", 4, 5) // first 02 - memberWay(14, "forward", 5, 6) - memberWay(15, "forward", 6, 7) // second 02 - memberWay(16, "backward", 5, 8) - memberWay(17, "backward", 8, 9) // third 02 - } - - new RouteAnalysisInspector() { - - startNode(1) - endNode(5) - endTentacleNode(7) - endTentacleNode(9) - - forward(1, 2, 3, 4, 5) - backward(5, 4, 3, 2, 1) - tentacle(5, 6, 7) // TODO would be more logical if nodes within tentacle were in reversed order? - tentacle(9, 8, 5) - - structure("forward=(01-02.a via +<01- 10>+<11>+<12>+<-02.a 13>)") - structure("backward=(02.a-01 via -<-02.a 13>-<12>-<11>-<01- 10>)") - structure("endTentacles=(02.a-02.b via +>02.a- 14>+>-02.b 15>,02.c-02.a via -<-02.c 17<-<02.a- 16<)") - }.analyze(d) - } - - test("09 split way with forward and backward roles") { - - val d = new RouteTestData("01-02") { - - node(1, "01") - node(10, "02") - - memberWay(101, "", 1, 2) - memberWay(102, "", 2, 3) - memberWay(103, "forward", 3, 4) - memberWay(104, "forward", 4, 5) - memberWay(105, "forward", 5, 6) - memberWay(106, "backward", 3, 7) - memberWay(107, "backward", 7, 8) - memberWay(108, "backward", 8, 6) - memberWay(109, "", 6, 9) - memberWay(110, "", 9, 10) - } - - new RouteAnalysisInspector() { - - startNode(1) - endNode(10) - - forward(1, 2, 3, 4, 5, 6, 9, 10) - backward(10, 9, 6, 8, 7, 3, 2, 1) - - structure("forward=(01-02 via +<01- 101>+<102>+>103>+>104>+>105>+<109>+<-02 110>)") - structure("backward=(02-01 via -<-02 110>-<109>-<108<-<107<-<106<-<102>-<01- 101>)") - }.analyze(d) - } - - test("10 split way with forward and forward roles") { - - val d = new RouteTestData("01-02") { - - node(1, "01") - node(10, "02") - - memberWay(101, "", 1, 2) - memberWay(102, "", 2, 3) - memberWay(103, "forward", 3, 4) - memberWay(104, "forward", 4, 5) - memberWay(105, "forward", 5, 6) - memberWay(106, "forward", 7, 3) - memberWay(107, "forward", 8, 7) - memberWay(108, "forward", 6, 8) - memberWay(109, "", 6, 9) - memberWay(110, "", 9, 10) - } - - new RouteAnalysisInspector() { - - startNode(1) - endNode(10) - - forward(1, 2, 3, 4, 5, 6, 9, 10) - backward(10, 9, 6, 8, 7, 3, 2, 1) - - structure("forward=(01-02 via +<01- 101>+<102>+>103>+>104>+>105>+<109>+<-02 110>)") - structure("backward=(02-01 via -<-02 110>-<109>+>108>+>107>+>106>-<102>-<01- 101>)") - }.analyze(d) - } - - ignore("11 roundabout") { - - val d = new RouteTestData("01-02") { - - node(1, "01") - node(10, "02") - - memberWay(10, "", 1, 2, 4) - memberWay(11, roundAboutTags, "", 3, 4, 5, 6, 7, 8, 3) - memberWay(12, "", 7, 9, 10) - } - - new RouteAnalysisInspector() { - - startNode(1) - endNode(10) - - forward(1, 2, 4, 5, 6, 7, 9, 10) - backward(10, 9, 7, 8, 3, 4, 2, 1) - - structure("forward=(01-02 via +<01- 10>+<11(4-5-6-7)>+<-02 12>)") - structure("backward=(02-01 via -<-02 12>+<11(7-8-3)>+<11(3-4)>-<01- 10>)") - }.analyze(d) - } - - test("12 broken in simple route") { - - val d = new RouteTestData("01-02") { - - node(1, "01") - node(6, "02") - - memberNode(1) - memberWay(10, "", 1, 2, 3) // broken - memberWay(11, "", 4, 5) - memberWay(12, "", 5, 6) - memberNode(6) - } - - new RouteAnalysisInspector() { - - fact(RouteBroken) - fact(RouteNotForward) - fact(RouteNotBackward) - fact(RouteNotContinious) - - startNode(1) - endNode(6) - - forward(1, 2, 3) - backward(6, 5, 4) - - structure("forward=(01-None [broken] via +<01- 10>)") - structure("backward=(02-None [broken] via -<-02 12>-<11>)") - }.analyze(d) - } - - test("13 broken in way that 'overshoots'") { - - val d = new RouteTestData("01-02") { - - node(1, "01") - node(6, "02") - - memberWay(10, "", 1, 2) - memberWay(11, "", 2, 3, 4, 5) // overshoot - memberWay(12, "", 3, 6) - } - - new RouteAnalysisInspector() { - - fact(RouteBroken) - fact(RouteUnusedSegments) - - startNode(1) - endNode(6) - - forward(1, 2, 3, 6) - backward(6, 3, 2, 1) - // TODO test unused here? - // TODO analysis.forwardBreakPoint should equal(Some(12 -> 3)) - // TODO analysis.backwardBreakPoint should equal(Some(12 -> 3)) - - structure("forward=(01-02 via +<01- 10>+<11(2-3)>+<-02 12>)") - structure("backward=(02-01 via -<-02 12>-<11(2-3)>-<01- 10>)") - structure("unused=(+<11(3-4-5)>)") - }.analyze(d) - } - - test("14 broken in split way forward segment") { - - val d = new RouteTestData("01-02") { - - node(1, "01") - node(10, "02") - - memberWay(101, "", 1, 2) - memberWay(102, "", 2, 3) - memberWay(103, "forward", 3, 4) - memberWay(104, "forward", 4, 11) // broken - memberWay(105, "forward", 5, 6) - memberWay(106, "backward", 3, 7) - memberWay(107, "backward", 7, 8) - memberWay(108, "backward", 8, 6) - memberWay(109, "", 6, 9) - memberWay(110, "", 9, 10) - } - - new RouteAnalysisInspector() { - - fact(RouteBroken) - fact(RouteNotForward) - fact(RouteNotContinious) - - startNode(1) - endNode(10) - - forward(1, 2, 3, 4, 11) - backward(10, 9, 6, 8, 7, 3, 2, 1) - - structure("forward=(01-None [broken] via +<01- 101>+<102>+>103>+>104>)") - structure("backward=(02-01 via -<-02 110>-<109>-<108<-<107<-<106<-<102>-<01- 101>)") - structure("unused=(+>105>)") - }.analyze(d) - } - - test("15 broken in split way backward segment") { - - val d = new RouteTestData("01-02") { - - node(1, "01") - node(10, "02") - - memberWay(101, "", 1, 2) - memberWay(102, "", 2, 3) - memberWay(103, "forward", 3, 4) - memberWay(104, "forward", 4, 5) - memberWay(105, "forward", 5, 6) - memberWay(106, "backward", 3, 7) - memberWay(107, "backward", 7, 11) // broken - memberWay(108, "backward", 8, 6) - memberWay(109, "", 6, 9) - memberWay(110, "", 9, 10) - } - - new RouteAnalysisInspector() { - - fact(RouteBroken) - fact(RouteNotBackward) - fact(RouteNotContinious) - - startNode(1) - endNode(10) - - forward(1, 2, 3, 4, 5, 6, 9, 10) - backward(10, 9, 6, 8) - - structure("forward=(01-02 via +<01- 101>+<102>+>103>+>104>+>105>+<109>+<-02 110>)") - structure("backward=(02-None [broken] via -<-02 110>-<109>-<108<)") - structure("unused=(+<106<+<107<)") - }.analyze(d) - } - - test("16 broken at roundabout") { - - val d = new RouteTestData("01-02") { - - node(1, "01") - node(10, "02") - - memberWay(10, "", 1, 2) - memberWay(11, roundAboutTags, "", 3, 4, 5, 6, 7, 8) - memberWay(12, "", 7, 9, 10) - } - - new RouteAnalysisInspector() { - - fact(RouteBroken) - fact(RouteNotBackward) - fact(RouteNotForward) - fact(RouteNotContinious) - - startNode(1) - endNode(10) - - forward(1, 2) - backward(10, 9, 7, 8) - - structure("forward=(01-None [broken] via +<01- 10>)") - structure("backward=(02-None [broken] via -<-02 12>+<11(7-8)>)") - - // TODO analysis.forwardBreakPoint should equal(Some(10 -> 2)) - // TODO analysis.backwardBreakPoint should equal(Some(10 -> 2)) - }.analyze(d) - } - - test("17 broken after roundabout") { - - val d = new RouteTestData("01-02") { - - node(1, "01") - node(10, "02") - - memberWay(10, "", 1, 2, 4) - memberWay(11, roundAboutTags, "", 3, 4, 5, 6, 7, 8) - memberWay(12, "", 9, 10) - } - - new RouteAnalysisInspector() { - - fact(RouteBroken) - fact(RouteNotBackward) - fact(RouteNotForward) - fact(RouteNotContinious) - - startNode(1) - endNode(10) - - forward(1, 2, 4, 5, 6, 7, 8) - backward(10, 9) - - // TODO analysis.forwardBreakPoint should equal(Some(12 -> 9)) - // TODO analysis.backwardBreakPoint should equal(Some(12 -> 9)) - - structure("forward=(01-None [broken] via +<01- 10>+<11(4-5-6-7-8)>)") - structure("backward=(02-None [broken] via -<-02 12>)") - }.analyze(d) - } - - test("18 oneway route -> oneway=yes") { - val d = new RouteTestData("01-02", ScopedNetworkType.rcn, Tags.from("oneway" -> "yes")) { - - node(1, "01") - node(3, "02") - - memberWay(10, Tags.from("highway" -> "road", "oneway" -> "yes"), "", 1, 2, 3) - } - - new RouteAnalysisInspector() { - - fact(RouteOneWay) - - startNode(1) - endNode(3) - - forward(1, 2, 3) - backward() - - structure("forward=(01-02 via +<01-02 10>)") - }.analyze(d) - } - - test("19 oneway route -> comment indicates oneway") { - val d = new RouteTestData("01-02", ScopedNetworkType.rcn, Tags.from("comment" -> "to be used in one direction")) { - - node(1, "01") - node(3, "02") - - memberWay(10, Tags.from("highway" -> "road", "oneway" -> "yes"), "", 1, 2, 3) - } - - new RouteAnalysisInspector() { - - fact(RouteOneWay) - - startNode(1) - endNode(3) - - forward(1, 2, 3) - backward() - - structure("forward=(01-02 via +<01-02 10>)") - }.analyze(d) - } - - test("20 oneway route -> direction=forward") { - val d = new RouteTestData("01-02", ScopedNetworkType.rcn, Tags.from("direction" -> "forward")) { - - node(1, "01") - node(3, "02") - - memberWay(10, Tags.from("highway" -> "road", "oneway" -> "yes"), "", 1, 2, 3) - } - - new RouteAnalysisInspector() { - - fact(RouteOneWay) - - startNode(1) - endNode(3) - - forward(1, 2, 3) - backward() - - structure("forward=(01-02 via +<01-02 10>)") - }.analyze(d) - } - - test("21 oneway route -> direction=backward") { - val d = new RouteTestData("01-02", ScopedNetworkType.rcn, Tags.from("direction" -> "backward")) { - - node(1, "01") - node(3, "02") - - memberWay(10, Tags.from("highway" -> "road", "oneway" -> "yes"), "", 3, 2, 1) - } - - new RouteAnalysisInspector() { - - fact(RouteOneWay) - - startNode(1) - endNode(3) - - forward() - backward(3, 2, 1) - - structure("backward=(02-01 via +<02-01 10>)") - }.analyze(d) - } - - test("22 not a oneway route if both directions ok") { - val d = new RouteTestData("01-02", ScopedNetworkType.rcn, Tags.from("oneway" -> "yes")) { - - node(1, "01") - node(2, "02") - - memberWay(10, "", 1, 2) - } - - new RouteAnalysisInspector() { - - fact(RouteNotOneWay) - - startNode(1) - endNode(2) - - forward(1, 2) - backward(2, 1) - - structure("forward=(01-02 via +<01-02 10>)") - structure("backward=(02-01 via -<01-02 10>)") - }.analyze(d) - } - - test("23 route with direction=forward, but forward not ok") { - val d = new RouteTestData("01-02", ScopedNetworkType.rcn, Tags.from("direction" -> "forward")) { - - node(1, "01") - node(3, "02") - - memberWay(10, Tags.from("highway" -> "road", "oneway" -> "yes"), "", 3, 2, 1) - } - - new RouteAnalysisInspector() { - - fact(RouteNotForward) - fact(RouteNotContinious) - fact(RouteBroken) - - startNode(1) - endNode(3) - - forward() - backward(3, 2, 1) - - structure("backward=(02-01 via +<02-01 10>)") - }.analyze(d) - } - - test("24 route with direction=backward, but backward not ok") { - val d = new RouteTestData("01-02", ScopedNetworkType.rcn, Tags.from("direction" -> "backward")) { - - node(1, "01") - node(3, "02") - - memberWay(10, Tags.from("highway" -> "road", "oneway" -> "yes"), "", 1, 2, 3) - } - - new RouteAnalysisInspector() { - - fact(RouteNotBackward) - fact(RouteNotContinious) - fact(RouteBroken) - - startNode(1) - endNode(3) - - forward(1, 2, 3) - backward() - - structure("forward=(01-02 via +<01-02 10>)") - }.analyze(d) - } - - ignore("25 route without nodes, but with state=connection") { - - val d = new RouteTestData("01-02", routeTags = Tags.from("state" -> "connection")) { - memberWay(10, "", 1, 2) - memberWay(11, "", 2, 3) - memberWay(12, "", 3, 4) - } - - new RouteAnalysisInspector() { - }.analyze(d) - } - - ignore("26 route without nodes, but with state=connection, with wrong sorting order") { - - val d = new RouteTestData("01-02", routeTags = Tags.from("state" -> "connection")) { - memberWay(10, "", 1, 2) - memberWay(12, "", 3, 4) - memberWay(11, "", 2, 3) - } - - new RouteAnalysisInspector() { - }.analyze(d) - } - - test("27 derive routename from start- and end-nodes") { - val d = new RouteTestData("") { - - node(1, "01") - node(3, "02") - - memberWay(10, "", 1, 2, 3) - } - - new RouteAnalysisInspector() { - - startNode(1) - endNode(3) - forward(1, 2, 3) - backward(3, 2, 1) - - structure("forward=(01-02 via +<01-02 10>)") - structure("backward=(02-01 via -<01-02 10>)") - }.analyze(d) - } - - private def roundAboutTags = Tags.from("highway" -> "road", "junction" -> "roundabout") -} diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/RouteAnalyzerRouteWithoutWaysTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/RouteAnalyzerRouteWithoutWaysTest.scala index 6a972bb59..84d62f8fe 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/RouteAnalyzerRouteWithoutWaysTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/RouteAnalyzerRouteWithoutWaysTest.scala @@ -38,6 +38,6 @@ class RouteAnalyzerRouteWithoutWaysTest extends UnitTest with MockFactory { routeTileAnalyzer ) val context = routeAnalyzer.analyze(relation, None).get - context.facts.shouldMatchTo(Seq(RouteWithoutWays, RouteBroken)) + context.facts.toSet.shouldMatchTo(Set(RouteWithoutWays, RouteBroken)) } } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/ExpectedNameRouteAnalyzerTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/ExpectedNameRouteAnalyzerTest.scala index 68b05453c..39b292d18 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/ExpectedNameRouteAnalyzerTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/ExpectedNameRouteAnalyzerTest.scala @@ -27,13 +27,13 @@ class ExpectedNameRouteAnalyzerTest extends UnitTest with SharedTestObjects { test("unexpected route name - start node does not match") { val newContext = doTest(Some("04-05"), Some("04"), Some("06")) newContext.expectedName should equal(Some("04-06")) - newContext.facts.shouldMatchTo(Seq(Fact.RouteNodeNameMismatch)) + newContext.facts.toSet.shouldMatchTo(Set(Fact.RouteNodeNameMismatch)) } test("unexpected route name - end node does not match") { val newContext = doTest(Some("04-05"), Some("04"), Some("07")) newContext.expectedName should equal(Some("04-07")) - newContext.facts.shouldMatchTo(Seq(Fact.RouteNodeNameMismatch)) + newContext.facts.toSet.shouldMatchTo(Set(Fact.RouteNodeNameMismatch)) } test("no fact when route name unknown") { @@ -63,7 +63,7 @@ class ExpectedNameRouteAnalyzerTest extends UnitTest with SharedTestObjects { test("do not make check when no separator dash") { val newContext = doTest(Some("bla"), Some("01"), Some("02")) newContext.expectedName should equal(Some("01-02")) - newContext.facts.shouldMatchTo(Seq(Fact.RouteNodeNameMismatch)) + newContext.facts.toSet.shouldMatchTo(Set(Fact.RouteNodeNameMismatch)) } private def doTest(routeName: Option[String], startNodeName: Option[String], endNodeName: Option[String]): RouteDetailAnalysisContext = { diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/IncompleteRouteAnalyzerTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/IncompleteRouteAnalyzerTest.scala index c454a914a..f187a9ca6 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/IncompleteRouteAnalyzerTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/IncompleteRouteAnalyzerTest.scala @@ -17,7 +17,7 @@ class IncompleteRouteAnalyzerTest extends UnitTest { test("route relation with fixme=incomplete tag") { val d = new RouteTestData("01-02", routeTags = Tags.from("fixme" -> "incomplete")) val context = analyze(d) - context.facts.shouldMatchTo(Seq(RouteIncomplete)) + context.facts.toSet.shouldMatchTo(Set(RouteIncomplete)) } private def analyze(routeTestData: RouteTestData): RouteDetailAnalysisContext = { diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/RouteNameAnalyzerTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/RouteNameAnalyzerTest.scala index 70a7cad56..6a9715d50 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/RouteNameAnalyzerTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/RouteNameAnalyzerTest.scala @@ -237,7 +237,7 @@ class RouteNameAnalyzerTest extends UnitTest with SharedTestObjects { test("route name missing") { val context = analyze(Seq.empty) context._routeNameAnalysis should equal(Some(RouteNameAnalysis())) - context.facts.shouldMatchTo(Seq(RouteNameMissing)) + context.facts.toSet.shouldMatchTo(Set(RouteNameMissing)) } test("route name based on 'note' tag if route name from 'name' tag is 'non-standard'") { diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/UnexpectedNodeRouteAnalyzerTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/UnexpectedNodeRouteAnalyzerTest.scala index 00b6322f5..01629a182 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/UnexpectedNodeRouteAnalyzerTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/analyzers/UnexpectedNodeRouteAnalyzerTest.scala @@ -1,6 +1,6 @@ package kpn.server.analyzer.engine.analysis.route.analyzers -import kpn.api.custom.Fact +import kpn.api.custom.Fact.RouteUnexpectedNode import kpn.api.custom.Tags import kpn.core.util.UnitTest import kpn.server.analyzer.engine.analysis.route.RouteTestData @@ -32,7 +32,7 @@ class UnexpectedNodeRouteAnalyzerTest extends UnitTest { val context = analyze(d) - context.facts.shouldMatchTo(Seq(Fact.RouteUnexpectedNode)) + context.facts.shouldMatchTo(Seq(RouteUnexpectedNode)) context.unexpectedNodeIds.shouldMatchTo(Some(Seq(1003))) } @@ -47,7 +47,7 @@ class UnexpectedNodeRouteAnalyzerTest extends UnitTest { val context = analyze(d) - context.facts.shouldMatchTo(Seq(Fact.RouteUnexpectedNode)) + context.facts.shouldMatchTo(Seq(RouteUnexpectedNode)) context.unexpectedNodeIds.shouldMatchTo(Some(Seq(1003))) } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/RouteDetailAnalysisTestContext.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/RouteDetailAnalysisTestContext.scala index cf94c1877..d4454b25c 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/RouteDetailAnalysisTestContext.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/RouteDetailAnalysisTestContext.scala @@ -1,6 +1,7 @@ package kpn.server.analyzer.engine.analysis.route.structure import kpn.api.custom.Fact +import kpn.server.analyzer.engine.analysis.route.RouteNodeData import kpn.server.analyzer.engine.analysis.route.domain.RouteDetailAnalysisContext case class RouteDetailAnalysisTestContext(context: RouteDetailAnalysisContext) { @@ -10,6 +11,17 @@ case class RouteDetailAnalysisTestContext(context: RouteDetailAnalysisContext) { } } + def nodes: Seq[String] = { + Seq( + networkNodeStrings("start", context.routeNodeAnalysis.startNode.toSeq), + networkNodeStrings("end", context.routeNodeAnalysis.endNode.toSeq), + networkNodeStrings("start-tentacle", context.routeNodeAnalysis.startTentacleFromNodes), + networkNodeStrings("end-tentacle", context.routeNodeAnalysis.endTentacleToNodes), + networkNodeStrings("free", context.routeNodeAnalysis.freeNodes), + networkNodeStrings("redundant", context.routeNodeAnalysis.redundantNodes) + ).flatten + } + def paths: Seq[String] = { context.paths.map { path => val id = s"path-${path.id}" @@ -25,14 +37,14 @@ case class RouteDetailAnalysisTestContext(context: RouteDetailAnalysisContext) { } } - def facts: Seq[Fact] = context.facts + def facts: Set[Fact] = context.facts.toSet def pathDetails: Seq[String] = { Seq( context.newStructure.forwardPath.map(path => "forward=" + pathToString(path)).toSeq, context.newStructure.backwardPath.map(path => "backward=" + pathToString(path)).toSeq, - context.newStructure.startTentaclePaths.map(path => "startTentacle=" + pathToString(path)).toSeq, - context.newStructure.endTentaclePaths.map(path => "endTentacle=" + pathToString(path)).toSeq, + context.newStructure.startTentaclePaths.map(path => "start-tentacle=" + pathToString(path)).toSeq, + context.newStructure.endTentaclePaths.map(path => "end-tentacle=" + pathToString(path)).toSeq, context.newStructure.otherPaths.map(path => "other=" + pathToString(path)), ).flatten } @@ -52,8 +64,8 @@ case class RouteDetailAnalysisTestContext(context: RouteDetailAnalysisContext) { private def elementToString(element: NewRouteSegmentElement): String = { val direction = element.direction.entryName.toLowerCase - val from = element.fromNetworkNode.map(n => s" ${n.name}(${n.node.id})").getOrElse("") - val to = element.toNetworkNode.map(n => s" ${n.name}(${n.node.id})").getOrElse("") + val from = element.fromNetworkNode.map(n => s" ${n.node.id}(${n.name})").getOrElse("") + val to = element.toNetworkNode.map(n => s" ${n.node.id}(${n.name})").getOrElse("") s""" element-${element.id} $direction ${element.fromNodeId}>${element.toNodeId}$from$to""" } @@ -65,4 +77,8 @@ case class RouteDetailAnalysisTestContext(context: RouteDetailAnalysisContext) { val nodeString = path.nodeIds.mkString(", ") s"${path.startNodeId}>${path.endNodeId} nodes=$nodeString" } + + private def networkNodeStrings(nodeType: String, routeNodeDatas: Seq[RouteNodeData]): Seq[String] = { + routeNodeDatas.map(routeNodeData => s"$nodeType=${routeNodeData.node.id}(${routeNodeData.name})") + } } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/StructureTestSetupBuilder.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/StructureTestSetupBuilder.scala index ad6fd339b..771ac60cd 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/StructureTestSetupBuilder.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/StructureTestSetupBuilder.scala @@ -5,6 +5,7 @@ import kpn.api.common.data.raw.RawData import kpn.api.common.data.raw.RawMember import kpn.api.common.data.raw.RawNode import kpn.api.common.data.raw.RawWay +import kpn.api.custom.ScopedNetworkType import kpn.api.custom.Tag import kpn.api.custom.Tags import kpn.core.data.DataBuilder @@ -70,6 +71,8 @@ class StructureTestSetupBuilder extends SharedTestObjects { member("node", nodeId, role) } + def roundAboutTags = Tags.from("highway" -> "road", "junction" -> "roundabout") + private def member(memberType: String, ref: Long, role: String = ""): RawMember = { val m = RawMember(memberType, ref, if (role.nonEmpty) Some(role) else None) memberBuffer += m @@ -97,7 +100,12 @@ class StructureTestSetupBuilder extends SharedTestObjects { new StructureTestSetup(new DataBuilder(rawData).data) } - def build(from: String, to: String): StructureTestSetup = { + def build( + from: String, + to: String, + scopedNetworkType: ScopedNetworkType = ScopedNetworkType.rwn, + routeTags: Seq[Tag] = Seq.empty + ): StructureTestSetup = { val relation = newRawRelation( 1, members = memberBuffer.toSeq, @@ -107,8 +115,8 @@ class StructureTestSetupBuilder extends SharedTestObjects { "type" -> "route", "route" -> "hiking", "network:type" -> "node_network", - "network" -> "rwn" - ) + "network" -> scopedNetworkType.key + ) ++ routeTags ) val rawData = RawData(None, nodeBuffer.toSeq, wayBuffer.toSeq, Seq(relation)) new StructureTestSetup(new DataBuilder(rawData).data) diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_01_SingleWayBidirectionalTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_01_SingleWayBidirectionalTest.scala index b158a90df..fb9a3b399 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_01_SingleWayBidirectionalTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_01_SingleWayBidirectionalTest.scala @@ -10,7 +10,7 @@ class Structure_01_SingleWayBidirectionalTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n loop fp bp head tail d unconnected", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_02_SingleWayForwardTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_02_SingleWayForwardTest.scala index a8ce03c25..eb5ae0fa3 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_02_SingleWayForwardTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_02_SingleWayForwardTest.scala @@ -13,7 +13,7 @@ class Structure_02_SingleWayForwardTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq(RouteNotBackward, RouteNotContinious, RouteBroken)) + context.facts.shouldMatchTo(Set(RouteNotBackward, RouteNotContinious, RouteBroken)) context.links.shouldMatchTo( Seq( "1 p n loop fp ■ bp head ■ tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_03_SingleWayBackwardTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_03_SingleWayBackwardTest.scala index 3d3ba763e..70c07afa9 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_03_SingleWayBackwardTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_03_SingleWayBackwardTest.scala @@ -13,7 +13,7 @@ class Structure_03_SingleWayBackwardTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq(RouteNotBackward, RouteNotContinious, RouteBroken)) + context.facts.shouldMatchTo(Set(RouteNotBackward, RouteNotContinious, RouteBroken)) context.links.shouldMatchTo( Seq( "1 p n loop fp ■ bp head ■ tail d backward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_04_SingleWayRoundaboutLoopTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_04_SingleWayRoundaboutLoopTest.scala index f25d53271..3275a8494 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_04_SingleWayRoundaboutLoopTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_04_SingleWayRoundaboutLoopTest.scala @@ -10,7 +10,7 @@ class Structure_04_SingleWayRoundaboutLoopTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n loop fp bp head tail d roundaboutright", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_05_SingleWayRoundaboutNotALoopTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_05_SingleWayRoundaboutNotALoopTest.scala index bf1ff9be6..c7ceb9e44 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_05_SingleWayRoundaboutNotALoopTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_05_SingleWayRoundaboutNotALoopTest.scala @@ -10,7 +10,7 @@ class Structure_05_SingleWayRoundaboutNotALoopTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n loop fp bp head tail d unconnected", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_11_DerivedDirectionTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_11_DerivedDirectionTest.scala index 758a49cc1..cc08cddfb 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_11_DerivedDirectionTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_11_DerivedDirectionTest.scala @@ -12,7 +12,7 @@ class Structure_11_DerivedDirectionTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_12_DerivedDirectionReverseTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_12_DerivedDirectionReverseTest.scala index 6d36b222d..b5288cc9b 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_12_DerivedDirectionReverseTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_12_DerivedDirectionReverseTest.scala @@ -12,7 +12,7 @@ class Structure_12_DerivedDirectionReverseTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d backward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_13_DerivedDirectionForwardTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_13_DerivedDirectionForwardTest.scala index 21b0ce717..a177a336c 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_13_DerivedDirectionForwardTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_13_DerivedDirectionForwardTest.scala @@ -12,7 +12,7 @@ class Structure_13_DerivedDirectionForwardTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d backward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_14_DerivedDirectionBackwardTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_14_DerivedDirectionBackwardTest.scala index 58171d19f..feeab239a 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_14_DerivedDirectionBackwardTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_14_DerivedDirectionBackwardTest.scala @@ -12,7 +12,7 @@ class Structure_14_DerivedDirectionBackwardTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_15_DerivedDirectionBackwardBackwardTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_15_DerivedDirectionBackwardBackwardTest.scala index 469341d7e..7ba128129 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_15_DerivedDirectionBackwardBackwardTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_15_DerivedDirectionBackwardBackwardTest.scala @@ -12,7 +12,7 @@ class Structure_15_DerivedDirectionBackwardBackwardTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d backward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_21_ContinuousTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_21_ContinuousTest.scala index e82f2db62..3d3f1e035 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_21_ContinuousTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_21_ContinuousTest.scala @@ -12,7 +12,7 @@ class Structure_21_ContinuousTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_22_ContinuousFirstWayReversedTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_22_ContinuousFirstWayReversedTest.scala index 67a6fafc3..4f2d5572b 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_22_ContinuousFirstWayReversedTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_22_ContinuousFirstWayReversedTest.scala @@ -12,7 +12,7 @@ class Structure_22_ContinuousFirstWayReversedTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d backward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_22_ContinuousSecondAndThirdWayReversedTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_22_ContinuousSecondAndThirdWayReversedTest.scala index d57413035..a57a85c44 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_22_ContinuousSecondAndThirdWayReversedTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_22_ContinuousSecondAndThirdWayReversedTest.scala @@ -12,7 +12,7 @@ class Structure_22_ContinuousSecondAndThirdWayReversedTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_31_GapSecondWayBackwardTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_31_GapSecondWayBackwardTest.scala index 108d11ea6..b40129b67 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_31_GapSecondWayBackwardTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_31_GapSecondWayBackwardTest.scala @@ -16,7 +16,7 @@ class Structure_31_GapSecondWayBackwardTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken)) + context.facts.shouldMatchTo(Set(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken)) context.links.shouldMatchTo( Seq( "1 p n loop fp bp head tail d unconnected", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_32_GapTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_32_GapTest.scala index 6aead3a4f..086cfd021 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_32_GapTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_32_GapTest.scala @@ -17,7 +17,7 @@ class Structure_32_GapTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken)) + context.facts.shouldMatchTo(Set(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken)) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_33_GapTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_33_GapTest.scala index a28a5a6c7..5869b28eb 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_33_GapTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_33_GapTest.scala @@ -20,7 +20,7 @@ class Structure_33_GapTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken)) + context.facts.shouldMatchTo(Set(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken)) context.links.shouldMatchTo( Seq( "1 p n loop fp bp head tail d unconnected", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_34_GapTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_34_GapTest.scala index 013a7afc4..891af0b71 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_34_GapTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_34_GapTest.scala @@ -20,7 +20,7 @@ class Structure_34_GapTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken)) + context.facts.shouldMatchTo(Set(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken)) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_41_ForwardNoBackwardPathTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_41_ForwardNoBackwardPathTest.scala index 84ae31279..025d2ba52 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_41_ForwardNoBackwardPathTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_41_ForwardNoBackwardPathTest.scala @@ -11,7 +11,7 @@ class Structure_41_ForwardNoBackwardPathTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp ■ bp head ■ tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_42_ForwardGapTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_42_ForwardGapTest.scala index fde0e3c7f..6674eb55c 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_42_ForwardGapTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_42_ForwardGapTest.scala @@ -15,7 +15,7 @@ class Structure_42_ForwardGapTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken)) + context.facts.shouldMatchTo(Set(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken)) context.links.shouldMatchTo( Seq( "1 p n loop fp ■ bp head ■ tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_43_ForwardBackwardTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_43_ForwardBackwardTest.scala index 1f52c968e..e182221bc 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_43_ForwardBackwardTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_43_ForwardBackwardTest.scala @@ -15,7 +15,7 @@ class Structure_43_ForwardBackwardTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_44_ForwardBackwardTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_44_ForwardBackwardTest.scala index 3a46960b1..be9e629f4 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_44_ForwardBackwardTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_44_ForwardBackwardTest.scala @@ -15,7 +15,7 @@ class Structure_44_ForwardBackwardTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_45_ForwardForwardTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_45_ForwardForwardTest.scala index 3fd4d333c..63bee378a 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_45_ForwardForwardTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_45_ForwardForwardTest.scala @@ -15,7 +15,7 @@ class Structure_45_ForwardForwardTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_46_ForwardForwardGapTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_46_ForwardForwardGapTest.scala index a3a47a186..3b2292b55 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_46_ForwardForwardGapTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_46_ForwardForwardGapTest.scala @@ -23,7 +23,7 @@ class Structure_46_ForwardForwardGapTest extends UnitTest { test("analyze") { val context = setup.analyze() context.facts.shouldMatchTo( - Seq(RouteNotForward, + Set(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_51_RoundaboutTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_51_RoundaboutTest.scala index b7b23c2f5..6b82dbc89 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_51_RoundaboutTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_51_RoundaboutTest.scala @@ -10,7 +10,7 @@ class Structure_51_RoundaboutTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n loop fp bp head tail d roundaboutright", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_52_RoundaboutRoundaboutTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_52_RoundaboutRoundaboutTest.scala index 8576e18fd..45b370a67 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_52_RoundaboutRoundaboutTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_52_RoundaboutRoundaboutTest.scala @@ -11,7 +11,7 @@ class Structure_52_RoundaboutRoundaboutTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop ■ fp bp head tail d roundaboutright", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_53_WayRoundaboutTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_53_WayRoundaboutTest.scala index c3762ff18..f46ce90bb 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_53_WayRoundaboutTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_53_WayRoundaboutTest.scala @@ -11,7 +11,7 @@ class Structure_53_WayRoundaboutTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_54_WayRoundaboutWayTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_54_WayRoundaboutWayTest.scala index 2d79843f4..87a832f9b 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_54_WayRoundaboutWayTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_54_WayRoundaboutWayTest.scala @@ -12,7 +12,7 @@ class Structure_54_WayRoundaboutWayTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_55_DoubleRoundaboutTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_55_DoubleRoundaboutTest.scala index 0f0ef8fee..9908027a4 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_55_DoubleRoundaboutTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_55_DoubleRoundaboutTest.scala @@ -13,7 +13,7 @@ class Structure_55_DoubleRoundaboutTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_61_NonCircularRoundaboutTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_61_NonCircularRoundaboutTest.scala index 8711be624..7bfc858e6 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_61_NonCircularRoundaboutTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_61_NonCircularRoundaboutTest.scala @@ -12,7 +12,7 @@ class Structure_61_NonCircularRoundaboutTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_62_NonCircularRoundaboutTest.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_62_NonCircularRoundaboutTest.scala index e3c5b3744..0ded3b07d 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_62_NonCircularRoundaboutTest.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_62_NonCircularRoundaboutTest.scala @@ -13,7 +13,7 @@ class Structure_62_NonCircularRoundaboutTest extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_71_5444896_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_71_5444896_Test.scala index 34008ffb3..59906ee03 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_71_5444896_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_71_5444896_Test.scala @@ -22,7 +22,7 @@ class Structure_71_5444896_Test extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d backward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_72_SplitRoundabout_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_72_SplitRoundabout_Test.scala index 55779ed7a..2ebe7b6eb 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_72_SplitRoundabout_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_72_SplitRoundabout_Test.scala @@ -27,7 +27,7 @@ class Structure_72_SplitRoundabout_Test extends UnitTest { test("analyze") { val context = setup.analyze() - // context.facts.shouldMatchTo(Seq.empty) + // context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_73_Split_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_73_Split_Test.scala index 45ed0cf3d..9cedfed87 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_73_Split_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_73_Split_Test.scala @@ -14,7 +14,7 @@ class Structure_73_Split_Test extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp ■ bp head ■ tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_75_Split_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_75_Split_Test.scala index e9b3c6514..81baea81a 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_75_Split_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_75_Split_Test.scala @@ -17,7 +17,7 @@ class Structure_75_Split_Test extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp ■ bp head ■ tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_76_Split_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_76_Split_Test.scala index 04ee673ff..b01774ac4 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_76_Split_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_76_Split_Test.scala @@ -14,7 +14,7 @@ class Structure_76_Split_Test extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp ■ bp head ■ tail d backward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_77_Split_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_77_Split_Test.scala index 8a70d6d27..8e90c4e77 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_77_Split_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_77_Split_Test.scala @@ -15,7 +15,7 @@ class Structure_77_Split_Test extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N01_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N01_Test.scala index 6b1b8eed2..f74ac179f 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N01_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N01_Test.scala @@ -6,7 +6,6 @@ import kpn.core.util.UnitTest class Structure_N01_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - // val d = new RouteTestData("", routeTags = Tags.from("from" -> "01", "to" -> "02")) { node(1, "01") node(4, "02") memberWay(10, "", 1, 2, 3, 4) @@ -15,25 +14,24 @@ class Structure_N01_Test extends UnitTest { test("analyze") { val context = setup.analyze() - - context.facts.foreach(a => println(s""""$a",""")) - context.links.foreach(a => println(s""""$a",""")) - context.segments.foreach(a => println(s""""$a",""")) - context.paths.foreach(a => println(s""""$a",""")) - context.pathNodes.foreach(a => println(s"""$a,""")) - context.pathDetails.foreach(a => println(s""""$a",""")) - - // context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n loop fp bp head tail d unconnected", ) ) + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=4(02)", + ) + ) + context.segments.shouldMatchTo( Seq( "segment-1 1>4", - " element-1 bidirectional 1>4 01(1) 02(4)", + " element-1 bidirectional 1>4 1(01) 4(02)", " way-10 p n loop fp bp head tail d unconnected paths=1", ) ) diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N02_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N02_Test.scala index d4fdf2f3e..a7a1e775d 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N02_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N02_Test.scala @@ -16,7 +16,7 @@ class Structure_N02_Test extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 ", @@ -25,10 +25,17 @@ class Structure_N02_Test extends UnitTest { ) ) + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=4(02)", + ) + ) + context.segments.shouldMatchTo( Seq( "segment-1 1>4", - " element-1 bidirectional 1>4 01(1) 02(4)", + " element-1 bidirectional 1>4 1(01) 4(02)", " way-10 p n loop fp bp head tail d unconnected paths=1", ) ) diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N03_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N03_Test.scala index b2136629d..90a9a20bb 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N03_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N03_Test.scala @@ -18,7 +18,7 @@ class Structure_N03_Test extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 ", @@ -29,10 +29,17 @@ class Structure_N03_Test extends UnitTest { ) ) + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=6(02)", + ) + ) + context.segments.shouldMatchTo( Seq( "segment-1 1>6", - " element-1 bidirectional 1>6 01(1) 02(6)", + " element-1 bidirectional 1>6 1(01) 6(02)", " way-10 p n ■ loop fp bp head tail d forward paths=1", " way-11 p ■ n ■ loop fp bp head tail d forward paths=1", " way-12 p ■ n loop fp bp head tail d forward paths=1", diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N04_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N04_Test.scala index d762c38a1..8d06a6b98 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N04_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N04_Test.scala @@ -17,7 +17,7 @@ class Structure_N04_Test extends UnitTest { test("analyze") { val context = setup.analyze() - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", @@ -26,12 +26,20 @@ class Structure_N04_Test extends UnitTest { ) ) + context.nodes.shouldMatchTo( + Seq( + "start=4(01)", + "end=6(02)", + "start-tentacle=1(01)", + ) + ) + context.segments.shouldMatchTo( Seq( "segment-1 1>6", - " element-1 bidirectional 1>4 01(1) 01(4)", + " element-1 bidirectional 1>4 1(01) 4(01)", " way-10 p n ■ loop fp bp head tail d forward paths=1", - " element-2 bidirectional 4>6 01(4) 02(6)", + " element-2 bidirectional 4>6 4(01) 6(02)", " way-11 p ■ n ■ loop fp bp head tail d forward paths=2", " way-12 p ■ n loop fp bp head tail d forward paths=2", ) @@ -55,7 +63,7 @@ class Structure_N04_Test extends UnitTest { Seq( "forward=4>6 nodes=4, 5, 6", "backward=4>6 nodes=6, 5, 4", - "startTentacle=1>4 nodes=1, 2, 3, 4", + "start-tentacle=1>4 nodes=1, 2, 3, 4", ) ) } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N05_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N05_Test.scala index 3c3c16c56..e1fd2fa94 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N05_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N05_Test.scala @@ -19,15 +19,7 @@ class Structure_N05_Test extends UnitTest { test("analyze") { val context = setup.analyze() - - context.facts.foreach(a => println(s""""$a",""")) - context.links.foreach(a => println(s""""$a",""")) - context.segments.foreach(a => println(s""""$a",""")) - context.paths.foreach(a => println(s""""$a",""")) - context.pathNodes.foreach(a => println(s"""$a,""")) - context.pathDetails.foreach(a => println(s""""$a",""")) - - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( "1 p n ■ loop fp bp head tail d forward", @@ -37,13 +29,21 @@ class Structure_N05_Test extends UnitTest { ) ) + context.nodes.shouldMatchTo( + Seq( + "start=4(01)", + "end=6(02)", + "start-tentacle=1(01)", + ) + ) + context.segments.shouldMatchTo( Seq( "segment-1 1>6", - " element-1 bidirectional 1>4 01(1) 01(4)", + " element-1 bidirectional 1>4 1(01) 4(01)", " way-10 p n ■ loop fp bp head tail d forward paths=1", " way-11 p ■ n ■ loop fp bp head tail d forward paths=1", - " element-2 bidirectional 4>6 01(4) 02(6)", + " element-2 bidirectional 4>6 4(01) 6(02)", " way-12 p ■ n ■ loop fp bp head tail d forward paths=2", " way-13 p ■ n loop fp bp head tail d forward paths=2", ) @@ -67,7 +67,7 @@ class Structure_N05_Test extends UnitTest { Seq( "forward=4>6 nodes=4, 5, 6", "backward=4>6 nodes=6, 5, 4", - "startTentacle=1>4 nodes=1, 2, 3, 4", + "start-tentacle=1>4 nodes=1, 2, 3, 4", ) ) } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N06_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N06_Test.scala index a3b4b21e8..a1c05af16 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N06_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N06_Test.scala @@ -2,47 +2,78 @@ package kpn.server.analyzer.engine.analysis.route.structure import kpn.core.util.UnitTest -// +// tentacle at end class Structure_N06_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(5, "02") + node(7, "02") + + memberWay(10, "", 1, 2) // 01 + memberWay(11, "", 2, 3) + memberWay(12, "", 3, 4) + memberWay(13, "", 4, 5) // first 02 + memberWay(14, "", 5, 6) + memberWay(15, "", 6, 7) // second 02 + }.build("01", "02") test("analyze") { val context = setup.analyze() - - context.facts.foreach(a => println(s""""$a",""")) - context.links.foreach(a => println(s""""$a",""")) - context.segments.foreach(a => println(s""""$a",""")) - context.paths.foreach(a => println(s""""$a",""")) - context.pathNodes.foreach(a => println(s"""$a,""")) - context.pathDetails.foreach(a => println(s""""$a",""")) - - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( + "1 p n ■ loop fp bp head tail d forward", + "2 p ■ n ■ loop fp bp head tail d forward", + "3 p ■ n ■ loop fp bp head tail d forward", + "4 p ■ n ■ loop fp bp head tail d forward", + "5 p ■ n ■ loop fp bp head tail d forward", + "6 p ■ n loop fp bp head tail d forward", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=5(02)", + "end-tentacle=7(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>7", + " element-1 bidirectional 1>5 1(01) 5(02)", + " way-10 p n ■ loop fp bp head tail d forward paths=1", + " way-11 p ■ n ■ loop fp bp head tail d forward paths=1", + " way-12 p ■ n ■ loop fp bp head tail d forward paths=1", + " way-13 p ■ n ■ loop fp bp head tail d forward paths=1", + " element-2 bidirectional 5>7 5(02) 7(02)", + " way-14 p ■ n ■ loop fp bp head tail d forward paths=2", + " way-15 p ■ n loop fp bp head tail d forward paths=2", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", + "path-2, bidirectional, elements=2", ) ) context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2, 3, 4, 5)), + TestPathNodes(2, Vector(5, 6, 7)), ) ) context.pathDetails.shouldMatchTo( Seq( + "forward=1>5 nodes=1, 2, 3, 4, 5", + "backward=1>5 nodes=5, 4, 3, 2, 1", + "end-tentacle=5>7 nodes=5, 6, 7", ) ) } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N07_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N07_Test.scala index f6587b962..094138270 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N07_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N07_Test.scala @@ -2,47 +2,90 @@ package kpn.server.analyzer.engine.analysis.route.structure import kpn.core.util.UnitTest -// +// multiple tentacles stacked at end class Structure_N07_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(5, "02") + node(7, "02") + node(9, "02") + + memberWay(10, "", 1, 2) // 01 + memberWay(11, "", 2, 3) + memberWay(12, "", 3, 4) + memberWay(13, "", 4, 5) // first 02 + memberWay(14, "", 5, 6) + memberWay(15, "", 6, 7) // second 02 + memberWay(16, "", 7, 8) + memberWay(17, "", 8, 9) // third 02 + }.build("01", "02") test("analyze") { val context = setup.analyze() - - context.facts.foreach(a => println(s""""$a",""")) - context.links.foreach(a => println(s""""$a",""")) - context.segments.foreach(a => println(s""""$a",""")) - context.paths.foreach(a => println(s""""$a",""")) - context.pathNodes.foreach(a => println(s"""$a,""")) - context.pathDetails.foreach(a => println(s""""$a",""")) - - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( + "1 p n ■ loop fp bp head tail d forward", + "2 p ■ n ■ loop fp bp head tail d forward", + "3 p ■ n ■ loop fp bp head tail d forward", + "4 p ■ n ■ loop fp bp head tail d forward", + "5 p ■ n ■ loop fp bp head tail d forward", + "6 p ■ n ■ loop fp bp head tail d forward", + "7 p ■ n ■ loop fp bp head tail d forward", + "8 p ■ n loop fp bp head tail d forward", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=5(02)", + "end-tentacle=7(02)", + "end-tentacle=9(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>9", + " element-1 bidirectional 1>5 1(01) 5(02)", + " way-10 p n ■ loop fp bp head tail d forward paths=1", + " way-11 p ■ n ■ loop fp bp head tail d forward paths=1", + " way-12 p ■ n ■ loop fp bp head tail d forward paths=1", + " way-13 p ■ n ■ loop fp bp head tail d forward paths=1", + " element-2 bidirectional 5>7 5(02) 7(02)", + " way-14 p ■ n ■ loop fp bp head tail d forward paths=2", + " way-15 p ■ n ■ loop fp bp head tail d forward paths=2", + " element-3 bidirectional 7>9 7(02) 9(02)", + " way-16 p ■ n ■ loop fp bp head tail d forward paths=3", + " way-17 p ■ n loop fp bp head tail d forward paths=3", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", + "path-2, bidirectional, elements=2", + "path-3, bidirectional, elements=3", ) ) context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2, 3, 4, 5)), + TestPathNodes(2, Vector(5, 6, 7)), + TestPathNodes(3, Vector(7, 8, 9)), ) ) context.pathDetails.shouldMatchTo( Seq( + "forward=1>5 nodes=1, 2, 3, 4, 5", + "backward=1>5 nodes=5, 4, 3, 2, 1", + "end-tentacle=5>7 nodes=5, 6, 7", + "end-tentacle=7>9 nodes=7, 8, 9", ) ) } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N08_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N08_Test.scala index beca1c380..5556633f3 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N08_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N08_Test.scala @@ -2,47 +2,90 @@ package kpn.server.analyzer.engine.analysis.route.structure import kpn.core.util.UnitTest -// +// multiple forked tentacles at end class Structure_N08_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(5, "02") + node(7, "02") + node(9, "02") + + memberWay(10, "", 1, 2) // 01 + memberWay(11, "", 2, 3) + memberWay(12, "", 3, 4) + memberWay(13, "", 4, 5) // first 02 + memberWay(14, "forward", 5, 6) + memberWay(15, "forward", 6, 7) // second 02 + memberWay(16, "backward", 5, 8) + memberWay(17, "backward", 8, 9) // third 02 + }.build("01", "02") test("analyze") { val context = setup.analyze() - - context.facts.foreach(a => println(s""""$a",""")) - context.links.foreach(a => println(s""""$a",""")) - context.segments.foreach(a => println(s""""$a",""")) - context.paths.foreach(a => println(s""""$a",""")) - context.pathNodes.foreach(a => println(s"""$a,""")) - context.pathDetails.foreach(a => println(s""""$a",""")) - - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( + "1 p n ■ loop fp bp head tail d forward", + "2 p ■ n ■ loop fp bp head tail d forward", + "3 p ■ n ■ loop fp bp head tail d forward", + "4 p ■ n ■ loop fp bp head tail d forward", + "5 p ■ n ■ loop fp ■ bp head ■ tail d forward", + "6 p ■ n ■ loop fp ■ bp head tail d forward", + "7 p ■ n ■ loop fp bp ■ head tail d forward", + "8 p ■ n loop fp bp ■ head tail d forward", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=5(02)", + "end-tentacle=7(02)", + "end-tentacle=9(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>9", + " element-1 bidirectional 1>5 1(01) 5(02)", + " way-10 p n ■ loop fp bp head tail d forward paths=1", + " way-11 p ■ n ■ loop fp bp head tail d forward paths=1", + " way-12 p ■ n ■ loop fp bp head tail d forward paths=1", + " way-13 p ■ n ■ loop fp bp head tail d forward paths=1", + " element-2 forward 5>7 5(02) 7(02)", + " way-14 p ■ n ■ loop fp ■ bp head ■ tail d forward paths=2", + " way-15 p ■ n ■ loop fp ■ bp head tail d forward paths=2", + " element-3 backward 5>9 5(02) 9(02)", + " way-16 p ■ n ■ loop fp bp ■ head tail d forward paths=3", + " way-17 p ■ n loop fp bp ■ head tail d forward paths=3", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", + "path-2, forward, elements=2", + "path-3, backward, elements=3", ) ) context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2, 3, 4, 5)), + TestPathNodes(2, Vector(5, 6, 7)), + TestPathNodes(3, Vector(5, 8, 9)), ) ) context.pathDetails.shouldMatchTo( Seq( + "forward=1>5 nodes=1, 2, 3, 4, 5", + "backward=1>5 nodes=5, 4, 3, 2, 1", + "end-tentacle=5>7 nodes=5, 6, 7", + "end-tentacle=9>5 nodes=5, 8, 9", ) ) } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N09_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N09_Test.scala index 782c30f57..d617f1a07 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N09_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N09_Test.scala @@ -2,12 +2,24 @@ package kpn.server.analyzer.engine.analysis.route.structure import kpn.core.util.UnitTest -// +// split way with forward and backward roles class Structure_N09_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(10, "02") + + memberWay(101, "", 1, 2) + memberWay(102, "", 2, 3) + memberWay(103, "forward", 3, 4) + memberWay(104, "forward", 4, 5) + memberWay(105, "forward", 5, 6) + memberWay(106, "backward", 3, 7) + memberWay(107, "backward", 7, 8) + memberWay(108, "backward", 8, 6) + memberWay(109, "", 6, 9) + memberWay(110, "", 9, 10) + }.build("01", "02") test("analyze") { @@ -15,35 +27,87 @@ class Structure_N09_Test extends UnitTest { context.facts.foreach(a => println(s""""$a",""")) context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) context.segments.foreach(a => println(s""""$a",""")) context.paths.foreach(a => println(s""""$a",""")) context.pathNodes.foreach(a => println(s"""$a,""")) context.pathDetails.foreach(a => println(s""""$a",""")) - context.facts.shouldMatchTo(Seq.empty) + // TODO context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( + "1 p n ■ loop fp bp head tail d forward", + "2 p ■ n ■ loop fp bp head tail d forward", + "3 p ■ n ■ loop fp ■ bp head ■ tail d forward", + "4 p ■ n ■ loop fp ■ bp head tail d forward", + "5 p ■ n ■ loop fp ■ bp head tail d forward", + "6 p ■ n ■ loop fp bp ■ head tail d forward", + "7 p ■ n ■ loop fp bp ■ head tail d forward", + "8 p ■ n ■ loop fp bp ■ head tail ■ d forward", + "9 p ■ n ■ loop fp bp head tail d forward", + "10 p ■ n loop fp bp head tail d forward", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=10(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>10", + " element-1 bidirectional 1>3 1(01)", + " way-101 p n ■ loop fp bp head tail d forward paths=1", + " way-102 p ■ n ■ loop fp bp head tail d forward paths=1", + " element-2 forward 3>6", + " way-103 p ■ n ■ loop fp ■ bp head ■ tail d forward paths=2", + " way-104 p ■ n ■ loop fp ■ bp head tail d forward paths=2", + " way-105 p ■ n ■ loop fp ■ bp head tail d forward paths=2", + " element-3 backward 3>6", + " way-106 p ■ n ■ loop fp bp ■ head tail d forward paths=3", + " way-107 p ■ n ■ loop fp bp ■ head tail d forward paths=3", + " way-108 p ■ n ■ loop fp bp ■ head tail ■ d forward paths=3", + " element-4 bidirectional 6>10 10(02)", + " way-109 p ■ n ■ loop fp bp head tail d forward paths=4", + " way-110 p ■ n loop fp bp head tail d forward paths=4", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", + "path-2, forward, elements=2", + "path-3, backward, elements=3", + "path-4, bidirectional, elements=4", ) ) - context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2, 3)), + TestPathNodes(2, Vector(3, 4, 5, 6)), + TestPathNodes(3, Vector(3, 7, 8, 6)), + TestPathNodes(4, Vector(6, 9, 10)), ) ) + /* + startNode(1) + endNode(10) + + forward(1, 2, 3, 4, 5, 6, 9, 10) + backward(10, 9, 6, 8, 7, 3, 2, 1) + */ context.pathDetails.shouldMatchTo( Seq( + "forward=1>10 nodes=1, 2, 3", // TODO nok + "backward=1>10 nodes=10, 9, 6", + "other=3>6 nodes=3, 4, 5, 6", + "other=6>3 nodes=3, 7, 8, 6", ) ) + pending } } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N10_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N10_Test.scala index daba7355c..0d46afe79 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N10_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N10_Test.scala @@ -2,12 +2,24 @@ package kpn.server.analyzer.engine.analysis.route.structure import kpn.core.util.UnitTest -// +// split way with forward and forward roles class Structure_N10_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(10, "02") + + memberWay(101, "", 1, 2) + memberWay(102, "", 2, 3) + memberWay(103, "forward", 3, 4) + memberWay(104, "forward", 4, 5) + memberWay(105, "forward", 5, 6) + memberWay(106, "forward", 7, 3) + memberWay(107, "forward", 8, 7) + memberWay(108, "forward", 6, 8) + memberWay(109, "", 6, 9) + memberWay(110, "", 9, 10) + }.build("01", "02") test("analyze") { @@ -15,35 +27,81 @@ class Structure_N10_Test extends UnitTest { context.facts.foreach(a => println(s""""$a",""")) context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) context.segments.foreach(a => println(s""""$a",""")) context.paths.foreach(a => println(s""""$a",""")) context.pathNodes.foreach(a => println(s"""$a,""")) context.pathDetails.foreach(a => println(s""""$a",""")) - context.facts.shouldMatchTo(Seq.empty) + // TODO context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( + "1 p n ■ loop fp bp head tail d forward", + "2 p ■ n ■ loop fp bp head tail d forward", + "3 p ■ n ■ loop fp ■ bp head ■ tail d forward", + "4 p ■ n ■ loop fp ■ bp head tail d forward", + "5 p ■ n ■ loop fp ■ bp head tail d forward", + "6 p ■ n ■ loop fp bp ■ head tail d backward", + "7 p ■ n ■ loop fp bp ■ head tail d backward", + "8 p ■ n ■ loop fp bp ■ head tail ■ d backward", + "9 p ■ n ■ loop fp bp head tail d forward", + "10 p ■ n loop fp bp head tail d forward", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=10(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>10", + " element-1 bidirectional 1>3 1(01)", + " way-101 p n ■ loop fp bp head tail d forward paths=1", + " way-102 p ■ n ■ loop fp bp head tail d forward paths=1", + " element-2 forward 3>6", + " way-103 p ■ n ■ loop fp ■ bp head ■ tail d forward paths=2", + " way-104 p ■ n ■ loop fp ■ bp head tail d forward paths=2", + " way-105 p ■ n ■ loop fp ■ bp head tail d forward paths=2", + " element-3 backward 3>6", + " way-106 p ■ n ■ loop fp bp ■ head tail d backward paths=3", + " way-107 p ■ n ■ loop fp bp ■ head tail d backward paths=3", + " way-108 p ■ n ■ loop fp bp ■ head tail ■ d backward paths=3", + " element-4 bidirectional 6>10 10(02)", + " way-109 p ■ n ■ loop fp bp head tail d forward paths=4", + " way-110 p ■ n loop fp bp head tail d forward paths=4", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", + "path-2, forward, elements=2", + "path-3, backward, elements=3", + "path-4, bidirectional, elements=4", ) ) context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2, 3)), + TestPathNodes(2, Vector(3, 4, 5, 6)), + TestPathNodes(3, Vector(3, 7, 8, 6)), + TestPathNodes(4, Vector(6, 9, 10)), ) ) context.pathDetails.shouldMatchTo( Seq( + "forward=1>10 nodes=1, 2, 3", // TODO forward(1, 2, 3, 4, 5, 6, 9, 10) + "backward=1>10 nodes=10, 9, 6", // TODO backward(10, 9, 6, 8, 7, 3, 2, 1) + "other=3>6 nodes=3, 4, 5, 6", + "other=6>3 nodes=3, 7, 8, 6", ) ) + pending } } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N11_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N11_Test.scala index 957b2b793..9162f7876 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N11_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N11_Test.scala @@ -2,12 +2,16 @@ package kpn.server.analyzer.engine.analysis.route.structure import kpn.core.util.UnitTest -// +// roundabout class Structure_N11_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(10, "02") + memberWay(10, "", 1, 2, 4) + memberWayWithTags(11, "", roundAboutTags, 3, 4, 5, 6, 7, 8, 3) + memberWay(12, "", 7, 9, 10) + }.build("01", "02") test("analyze") { @@ -15,35 +19,68 @@ class Structure_N11_Test extends UnitTest { context.facts.foreach(a => println(s""""$a",""")) context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) context.segments.foreach(a => println(s""""$a",""")) context.paths.foreach(a => println(s""""$a",""")) context.pathNodes.foreach(a => println(s"""$a,""")) context.pathDetails.foreach(a => println(s""""$a",""")) - context.facts.shouldMatchTo(Seq.empty) + // TODO context.facts.shouldMatchTo(Set.empty) context.links.shouldMatchTo( Seq( + "1 p n ■ loop fp bp head tail d forward", + "2 p ■ n ■ loop fp bp head tail d roundaboutright", + "3 p ■ n loop fp bp head tail d forward", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=10(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>10", + " element-1 bidirectional 1>4 1(01)", + " way-10 p n ■ loop fp bp head tail d forward paths=1", + " element-2 forward 4>7", + " way-11 p ■ n ■ loop fp bp head tail d roundaboutright paths=2", + " element-3 backward 4>7", + " way-11 p ■ n ■ loop fp bp head tail d roundaboutright paths=3", + " element-4 bidirectional 7>10 10(02)", + " way-12 p ■ n loop fp bp head tail d forward paths=4", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", + "path-2, forward, elements=2", + "path-3, backward, elements=3", + "path-4, bidirectional, elements=4", ) ) context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2, 4)), + TestPathNodes(2, Vector(4, 5, 6, 7)), + TestPathNodes(3, Vector(4, 3, 8, 7)), + TestPathNodes(4, Vector(7, 9, 10)), ) ) context.pathDetails.shouldMatchTo( Seq( + "forward=1>10 nodes=1, 2, 4", // TODO forward(1, 2, 4, 5, 6, 7, 9, 10) + "backward=1>10 nodes=10, 9, 7", // TODO backward(10, 9, 7, 8, 3, 4, 2, 1) + "other=4>7 nodes=4, 5, 6, 7", + "other=7>4 nodes=4, 3, 8, 7", ) ) + pending } } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N12_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N12_Test.scala index f5570dcb9..9a3ec32af 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N12_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N12_Test.scala @@ -1,13 +1,23 @@ package kpn.server.analyzer.engine.analysis.route.structure +import kpn.api.custom.Fact.RouteBroken +import kpn.api.custom.Fact.RouteNotBackward +import kpn.api.custom.Fact.RouteNotContinious +import kpn.api.custom.Fact.RouteNotForward import kpn.core.util.UnitTest -// +// broken in simple route class Structure_N12_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(6, "02") + memberNode(1) + memberWay(10, "", 1, 2, 3) // broken + memberWay(11, "", 4, 5) + memberWay(12, "", 5, 6) + memberNode(6) + }.build("01", "02") test("analyze") { @@ -15,35 +25,62 @@ class Structure_N12_Test extends UnitTest { context.facts.foreach(a => println(s""""$a",""")) context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) context.segments.foreach(a => println(s""""$a",""")) context.paths.foreach(a => println(s""""$a",""")) context.pathNodes.foreach(a => println(s"""$a,""")) context.pathDetails.foreach(a => println(s""""$a",""")) - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken)) context.links.shouldMatchTo( Seq( + "1 ", + "2 p n loop fp bp head tail d unconnected", + "3 p n ■ loop fp bp head tail d forward", + "4 p ■ n loop fp bp head tail d forward", + "5 ", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=6(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>3", + " element-1 bidirectional 1>3 1(01)", + " way-10 p n loop fp bp head tail d unconnected paths=1", + "segment-2 4>6", + " element-2 bidirectional 4>6 6(02)", + " way-11 p n ■ loop fp bp head tail d forward paths=2", + " way-12 p ■ n loop fp bp head tail d forward paths=2", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", + "path-2, bidirectional, elements=2", ) ) context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2, 3)), + TestPathNodes(2, Vector(4, 5, 6)), ) ) context.pathDetails.shouldMatchTo( Seq( + // TODO forward(1, 2, 3) + // TODO backward(6, 5, 4) ) ) + pending } } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N13_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N13_Test.scala index 4d1816f9a..6789bca67 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N13_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N13_Test.scala @@ -2,12 +2,16 @@ package kpn.server.analyzer.engine.analysis.route.structure import kpn.core.util.UnitTest -// +// broken in way that 'overshoots' class Structure_N13_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(6, "02") + memberWay(10, "", 1, 2) + memberWay(11, "", 2, 3, 4, 5) // overshoot + memberWay(12, "", 3, 6) + }.build("01", "02") test("analyze") { @@ -15,35 +19,61 @@ class Structure_N13_Test extends UnitTest { context.facts.foreach(a => println(s""""$a",""")) context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) context.segments.foreach(a => println(s""""$a",""")) context.paths.foreach(a => println(s""""$a",""")) context.pathNodes.foreach(a => println(s"""$a,""")) context.pathDetails.foreach(a => println(s""""$a",""")) - context.facts.shouldMatchTo(Seq.empty) + // TODO context.facts.shouldMatchTo(Set(RouteBroken, RouteUnusedSegments)) context.links.shouldMatchTo( Seq( + "1 p n ■ loop fp bp head tail d forward", + "2 p ■ n loop fp bp head tail d forward", + "3 p n loop fp bp head tail d unconnected", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=6(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>5", + " element-1 bidirectional 1>5 1(01)", + " way-10 p n ■ loop fp bp head tail d forward paths=1", + " way-11 p ■ n loop fp bp head tail d forward paths=1", + "segment-2 3>6", + " element-2 bidirectional 3>6 6(02)", + " way-12 p n loop fp bp head tail d unconnected paths=2", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", + "path-2, bidirectional, elements=2", ) ) context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2, 3, 4, 5)), + TestPathNodes(2, Vector(3, 6)), ) ) context.pathDetails.shouldMatchTo( Seq( + // TODO forward(1, 2, 3, 6) + // TODO backward(6, 3, 2, 1) + // TODO structure("unused=(+<11(3-4-5)>)") ) ) + pending } } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N14_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N14_Test.scala index db9f0bf5e..2490007d4 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N14_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N14_Test.scala @@ -2,12 +2,23 @@ package kpn.server.analyzer.engine.analysis.route.structure import kpn.core.util.UnitTest -// +// broken in split way forward segment class Structure_N14_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(10, "02") + memberWay(101, "", 1, 2) + memberWay(102, "", 2, 3) + memberWay(103, "forward", 3, 4) + memberWay(104, "forward", 4, 11) // broken + memberWay(105, "forward", 5, 6) + memberWay(106, "backward", 3, 7) + memberWay(107, "backward", 7, 8) + memberWay(108, "backward", 8, 6) + memberWay(109, "", 6, 9) + memberWay(110, "", 9, 10) + }.build("01", "02") test("analyze") { @@ -15,35 +26,86 @@ class Structure_N14_Test extends UnitTest { context.facts.foreach(a => println(s""""$a",""")) context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) context.segments.foreach(a => println(s""""$a",""")) context.paths.foreach(a => println(s""""$a",""")) context.pathNodes.foreach(a => println(s"""$a,""")) context.pathDetails.foreach(a => println(s""""$a",""")) - context.facts.shouldMatchTo(Seq.empty) + // TODO context.facts.shouldMatchTo(Set(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken) context.links.shouldMatchTo( Seq( + "1 p n ■ loop fp bp head tail d forward", + "2 p ■ n ■ loop fp bp head tail d forward", + "3 p ■ n ■ loop fp ■ bp head ■ tail d forward", + "4 p ■ n loop fp ■ bp head tail d forward", + "5 p n ■ loop fp ■ bp head tail d forward", + "6 p ■ n ■ loop fp bp ■ head tail d forward", + "7 p ■ n ■ loop fp bp ■ head tail d forward", + "8 p ■ n ■ loop fp bp ■ head tail ■ d forward", + "9 p ■ n ■ loop fp bp head tail d forward", + "10 p ■ n loop fp bp head tail d forward", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=10(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>11", + " element-1 bidirectional 1>3 1(01)", + " way-101 p n ■ loop fp bp head tail d forward paths=1", + " way-102 p ■ n ■ loop fp bp head tail d forward paths=1", + " element-2 forward 3>11", + " way-103 p ■ n ■ loop fp ■ bp head ■ tail d forward paths=2", + " way-104 p ■ n loop fp ■ bp head tail d forward paths=2", + "segment-2 5>10", + " element-3 forward 5>6", + " way-105 p n ■ loop fp ■ bp head tail d forward paths=3", + " element-4 backward 3>6", + " way-106 p ■ n ■ loop fp bp ■ head tail d forward paths=4", + " way-107 p ■ n ■ loop fp bp ■ head tail d forward paths=4", + " way-108 p ■ n ■ loop fp bp ■ head tail ■ d forward paths=4", + " element-5 bidirectional 6>10 10(02)", + " way-109 p ■ n ■ loop fp bp head tail d forward paths=5", + " way-110 p ■ n loop fp bp head tail d forward paths=5", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", + "path-2, forward, elements=2", + "path-3, forward, elements=3", + "path-4, backward, elements=4", + "path-5, bidirectional, elements=5", ) ) context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2, 3)), + TestPathNodes(2, Vector(3, 4, 11)), + TestPathNodes(3, Vector(5, 6)), + TestPathNodes(4, Vector(3, 7, 8, 6)), + TestPathNodes(5, Vector(6, 9, 10)), ) ) context.pathDetails.shouldMatchTo( Seq( + // TODO forward(1, 2, 3, 4, 11) + // TODO backward(10, 9, 6, 8, 7, 3, 2, 1) + // structure("forward=(01-None [broken] via +<01- 101>+<102>+>103>+>104>)") + // structure("backward=(02-01 via -<-02 110>-<109>-<108<-<107<-<106<-<102>-<01- 101>)") + // structure("unused=(+>105>)") ) ) + pending } } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N15_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N15_Test.scala index b66f0db96..31a0fcf73 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N15_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N15_Test.scala @@ -2,12 +2,23 @@ package kpn.server.analyzer.engine.analysis.route.structure import kpn.core.util.UnitTest -// +// broken in split way backward segment class Structure_N15_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(10, "02") + memberWay(101, "", 1, 2) + memberWay(102, "", 2, 3) + memberWay(103, "forward", 3, 4) + memberWay(104, "forward", 4, 5) + memberWay(105, "forward", 5, 6) + memberWay(106, "backward", 3, 7) + memberWay(107, "backward", 7, 11) // broken + memberWay(108, "backward", 8, 6) + memberWay(109, "", 6, 9) + memberWay(110, "", 9, 10) + }.build("01", "02") test("analyze") { @@ -15,35 +26,86 @@ class Structure_N15_Test extends UnitTest { context.facts.foreach(a => println(s""""$a",""")) context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) context.segments.foreach(a => println(s""""$a",""")) context.paths.foreach(a => println(s""""$a",""")) context.pathNodes.foreach(a => println(s"""$a,""")) context.pathDetails.foreach(a => println(s""""$a",""")) - context.facts.shouldMatchTo(Seq.empty) + // TODO context.facts.shouldMatchTo(Set(RouteNotBackward, RouteNotContinious, RouteBroken)) context.links.shouldMatchTo( Seq( + "1 p n ■ loop fp bp head tail d forward", + "2 p ■ n ■ loop fp bp head tail d forward", + "3 p ■ n ■ loop fp ■ bp head ■ tail d forward", + "4 p ■ n ■ loop fp ■ bp head tail d forward", + "5 p ■ n ■ loop fp ■ bp head tail d forward", + "6 p ■ n ■ loop fp bp ■ head tail d forward", + "7 p ■ n ■ loop fp bp ■ head tail d forward", + "8 p ■ n loop fp ■ bp head tail d backward", + "9 p n ■ loop fp bp head tail d forward", + "10 p ■ n loop fp bp head tail d forward", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=10(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>8", + " element-1 bidirectional 1>3 1(01)", + " way-101 p n ■ loop fp bp head tail d forward paths=1", + " way-102 p ■ n ■ loop fp bp head tail d forward paths=1", + " element-2 forward 3>6", + " way-103 p ■ n ■ loop fp ■ bp head ■ tail d forward paths=2", + " way-104 p ■ n ■ loop fp ■ bp head tail d forward paths=2", + " way-105 p ■ n ■ loop fp ■ bp head tail d forward paths=2", + " element-3 backward 3>11", + " way-106 p ■ n ■ loop fp bp ■ head tail d forward paths=3", + " way-107 p ■ n ■ loop fp bp ■ head tail d forward paths=3", + " element-4 forward 6>8", + " way-108 p ■ n loop fp ■ bp head tail d backward paths=4", + "segment-2 6>10", + " element-5 bidirectional 6>10 10(02)", + " way-109 p n ■ loop fp bp head tail d forward paths=5", + " way-110 p ■ n loop fp bp head tail d forward paths=5", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", + "path-2, forward, elements=2", + "path-3, backward, elements=3", + "path-4, forward, elements=4", + "path-5, bidirectional, elements=5", ) ) context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2, 3)), + TestPathNodes(2, Vector(3, 4, 5, 6)), + TestPathNodes(3, Vector(3, 7, 11)), + TestPathNodes(4, Vector(6, 8)), + TestPathNodes(5, Vector(6, 9, 10)), ) ) context.pathDetails.shouldMatchTo( Seq( + // TODO forward(1, 2, 3, 4, 5, 6, 9, 10) + // TODO backward(10, 9, 6, 8) + // structure("forward=(01-02 via +<01- 101>+<102>+>103>+>104>+>105>+<109>+<-02 110>)") + // structure("backward=(02-None [broken] via -<-02 110>-<109>-<108<)") + // structure("unused=(+<106<+<107<)") ) ) + pending } } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N16_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N16_Test.scala index 3a0d03736..9a3edcd56 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N16_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N16_Test.scala @@ -1,13 +1,21 @@ package kpn.server.analyzer.engine.analysis.route.structure +import kpn.api.custom.Fact.RouteBroken +import kpn.api.custom.Fact.RouteNotBackward +import kpn.api.custom.Fact.RouteNotContinious +import kpn.api.custom.Fact.RouteNotForward import kpn.core.util.UnitTest -// +// broken at roundabout class Structure_N16_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(10, "02") + memberWay(10, "", 1, 2) + memberWayWithTags(11, "", roundAboutTags, 3, 4, 5, 6, 7, 8) + memberWay(12, "", 7, 9, 10) + }.build("01", "02") test("analyze") { @@ -15,35 +23,67 @@ class Structure_N16_Test extends UnitTest { context.facts.foreach(a => println(s""""$a",""")) context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) context.segments.foreach(a => println(s""""$a",""")) context.paths.foreach(a => println(s""""$a",""")) context.pathNodes.foreach(a => println(s"""$a,""")) context.pathDetails.foreach(a => println(s""""$a",""")) - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken)) context.links.shouldMatchTo( Seq( + "1 p n loop fp bp head tail d unconnected", + "2 p n loop fp bp head tail d unconnected", + "3 p n loop fp bp head tail d unconnected", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=10(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>2", + " element-1 bidirectional 1>2 1(01)", + " way-10 p n loop fp bp head tail d unconnected paths=1", + "segment-2 3>8", + " element-2 bidirectional 3>8", + " way-11 p n loop fp bp head tail d unconnected paths=2", + "segment-3 7>10", + " element-3 bidirectional 7>10 10(02)", + " way-12 p n loop fp bp head tail d unconnected paths=3", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", + "path-2, bidirectional, elements=2", + "path-3, bidirectional, elements=3", ) ) context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2)), + TestPathNodes(2, Vector(3, 4, 5, 6, 7, 8)), + TestPathNodes(3, Vector(7, 9, 10)), ) ) context.pathDetails.shouldMatchTo( Seq( + // TODO forward(1, 2) + // TODO backward(10, 9, 7, 8) + // structure("forward=(01-None [broken] via +<01- 10>)") + // structure("backward=(02-None [broken] via -<-02 12>+<11(7-8)>)") ) ) + + pending } } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N17_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N17_Test.scala index 9d169021b..23db0ad64 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N17_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N17_Test.scala @@ -1,13 +1,21 @@ package kpn.server.analyzer.engine.analysis.route.structure +import kpn.api.custom.Fact.RouteBroken +import kpn.api.custom.Fact.RouteNotBackward +import kpn.api.custom.Fact.RouteNotContinious +import kpn.api.custom.Fact.RouteNotForward import kpn.core.util.UnitTest -// +// broken after roundabout class Structure_N17_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(10, "02") + memberWay(10, "", 1, 2, 4) + memberWayWithTags(11, "", roundAboutTags, 3, 4, 5, 6, 7, 8) + memberWay(12, "", 9, 10) + }.build("01", "02") test("analyze") { @@ -15,35 +23,66 @@ class Structure_N17_Test extends UnitTest { context.facts.foreach(a => println(s""""$a",""")) context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) context.segments.foreach(a => println(s""""$a",""")) context.paths.foreach(a => println(s""""$a",""")) context.pathNodes.foreach(a => println(s"""$a,""")) context.pathDetails.foreach(a => println(s""""$a",""")) - context.facts.shouldMatchTo(Seq.empty) + context.facts.shouldMatchTo(Set(RouteNotForward, RouteNotBackward, RouteNotContinious, RouteBroken)) context.links.shouldMatchTo( Seq( + "1 p n loop fp bp head tail d unconnected", + "2 p n loop fp bp head tail d unconnected", + "3 p n loop fp bp head tail d unconnected", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=10(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>4", + " element-1 bidirectional 1>4 1(01)", + " way-10 p n loop fp bp head tail d unconnected paths=1", + "segment-2 3>8", + " element-2 bidirectional 3>8", + " way-11 p n loop fp bp head tail d unconnected paths=2", + "segment-3 9>10", + " element-3 bidirectional 9>10 10(02)", + " way-12 p n loop fp bp head tail d unconnected paths=3", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", + "path-2, bidirectional, elements=2", + "path-3, bidirectional, elements=3", ) ) context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2, 4)), + TestPathNodes(2, Vector(3, 4, 5, 6, 7, 8)), + TestPathNodes(3, Vector(9, 10)), ) ) context.pathDetails.shouldMatchTo( Seq( + // TODO forward(1, 2, 4, 5, 6, 7, 8) + // TODO backward(10, 9) + //structure("forward=(01-None [broken] via +<01- 10>+<11(4-5-6-7-8)>)") + //structure("backward=(02-None [broken] via -<-02 12>)") ) ) + pending } } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N18_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N18_Test.scala index d0da3a832..3a0d92eb4 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N18_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N18_Test.scala @@ -1,13 +1,17 @@ package kpn.server.analyzer.engine.analysis.route.structure +import kpn.api.custom.ScopedNetworkType +import kpn.api.custom.Tags import kpn.core.util.UnitTest -// +// oneway route -> oneway=yes class Structure_N18_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(3, "02") + memberWayWithTags(10, "", Tags.from("highway" -> "road", "oneway" -> "yes"), 1, 2, 3) + }.build("01", "02", ScopedNetworkType.rcn, Tags.from("oneway" -> "yes")) test("analyze") { @@ -15,35 +19,52 @@ class Structure_N18_Test extends UnitTest { context.facts.foreach(a => println(s""""$a",""")) context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) context.segments.foreach(a => println(s""""$a",""")) context.paths.foreach(a => println(s""""$a",""")) context.pathNodes.foreach(a => println(s"""$a,""")) context.pathDetails.foreach(a => println(s""""$a",""")) - context.facts.shouldMatchTo(Seq.empty) + // TODO context.facts.shouldMatchTo(Set(RouteOneWay)) context.links.shouldMatchTo( Seq( + "1 p n loop fp bp head tail d unconnected", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=3(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>3", + " element-1 bidirectional 1>3 1(01) 3(02)", + " way-10 p n loop fp bp head tail d unconnected paths=1", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", ) ) context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2, 3)), ) ) context.pathDetails.shouldMatchTo( Seq( + "forward=1>3 nodes=1, 2, 3", + "backward=1>3 nodes=3, 2, 1", // TODO there should be no backward path ) ) + pending } } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N19_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N19_Test.scala index 662bb1b69..75f2198f3 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N19_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N19_Test.scala @@ -1,13 +1,17 @@ package kpn.server.analyzer.engine.analysis.route.structure +import kpn.api.custom.ScopedNetworkType +import kpn.api.custom.Tags import kpn.core.util.UnitTest -// +// oneway route -> comment indicates oneway class Structure_N19_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(3, "02") + memberWayWithTags(10, "", Tags.from("highway" -> "road", "oneway" -> "yes"), 1, 2, 3) + }.build("01", "02", ScopedNetworkType.rcn, Tags.from("comment" -> "to be used in one direction")) test("analyze") { @@ -15,35 +19,52 @@ class Structure_N19_Test extends UnitTest { context.facts.foreach(a => println(s""""$a",""")) context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) context.segments.foreach(a => println(s""""$a",""")) context.paths.foreach(a => println(s""""$a",""")) context.pathNodes.foreach(a => println(s"""$a,""")) context.pathDetails.foreach(a => println(s""""$a",""")) - context.facts.shouldMatchTo(Seq.empty) + // TODO context.facts.shouldMatchTo(Set(RouteOneWay)) context.links.shouldMatchTo( Seq( + "1 p n loop fp bp head tail d unconnected", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=3(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>3", + " element-1 bidirectional 1>3 1(01) 3(02)", + " way-10 p n loop fp bp head tail d unconnected paths=1", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", ) ) context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2, 3)), ) ) context.pathDetails.shouldMatchTo( Seq( + "forward=1>3 nodes=1, 2, 3", + "backward=1>3 nodes=3, 2, 1", // TODO there should be no backward path ) ) + pending } } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N20_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N20_Test.scala index 398d0a506..c23861c1c 100644 --- a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N20_Test.scala +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N20_Test.scala @@ -1,13 +1,17 @@ package kpn.server.analyzer.engine.analysis.route.structure +import kpn.api.custom.ScopedNetworkType +import kpn.api.custom.Tags import kpn.core.util.UnitTest -// +// oneway route -> direction=forward class Structure_N20_Test extends UnitTest { private def setup = new StructureTestSetupBuilder() { - memberWay(11, "", 1, 2, 3) - }.build + node(1, "01") + node(3, "02") + memberWayWithTags(10, "", Tags.from("highway" -> "road", "oneway" -> "yes"), 1, 2, 3) + }.build("01", "02", ScopedNetworkType.rcn, Tags.from("direction" -> "forward")) test("analyze") { @@ -15,34 +19,50 @@ class Structure_N20_Test extends UnitTest { context.facts.foreach(a => println(s""""$a",""")) context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) context.segments.foreach(a => println(s""""$a",""")) context.paths.foreach(a => println(s""""$a",""")) context.pathNodes.foreach(a => println(s"""$a,""")) context.pathDetails.foreach(a => println(s""""$a",""")) - context.facts.shouldMatchTo(Seq.empty) + // TODO context.facts.shouldMatchTo(Set(RouteOneWay)) context.links.shouldMatchTo( Seq( + "1 p n loop fp bp head tail d unconnected", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=3(02)", ) ) context.segments.shouldMatchTo( Seq( + "segment-1 1>3", + " element-1 bidirectional 1>3 1(01) 3(02)", + " way-10 p n loop fp bp head tail d unconnected paths=1", ) ) context.paths.shouldMatchTo( Seq( + "path-1, bidirectional, elements=1", ) ) context.pathNodes.shouldMatchTo( Seq( + TestPathNodes(1, Vector(1, 2, 3)), ) ) context.pathDetails.shouldMatchTo( Seq( + "forward=1>3 nodes=1, 2, 3", + "backward=1>3 nodes=3, 2, 1", // TODO there should be no backward path ) ) } diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N21_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N21_Test.scala new file mode 100644 index 000000000..5957529c9 --- /dev/null +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N21_Test.scala @@ -0,0 +1,69 @@ +package kpn.server.analyzer.engine.analysis.route.structure + +import kpn.api.custom.Tags +import kpn.core.util.UnitTest + +// oneway route -> direction=backward +class Structure_N21_Test extends UnitTest { + + private def setup = new StructureTestSetupBuilder() { + node(1, "01") + node(3, "02") + memberWayWithTags(10, "", Tags.from("highway" -> "road", "oneway" -> "yes"), 3, 2, 1) + }.build("01", "02") + + test("analyze") { + + val context = setup.analyze() + + context.facts.foreach(a => println(s""""$a",""")) + context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) + context.segments.foreach(a => println(s""""$a",""")) + context.paths.foreach(a => println(s""""$a",""")) + context.pathNodes.foreach(a => println(s"""$a,""")) + context.pathDetails.foreach(a => println(s""""$a",""")) + + // TODO context.facts.shouldMatchTo(Set(RouteOneWay)) + context.links.shouldMatchTo( + Seq( + "1 p n loop fp bp head tail d unconnected", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=3(02)", + "end=1(01)", + ) + ) + + context.segments.shouldMatchTo( + Seq( + "segment-1 3>1", + " element-1 bidirectional 3>1 3(02) 1(01)", + " way-10 p n loop fp bp head tail d unconnected paths=1", + ) + ) + + context.paths.shouldMatchTo( + Seq( + "path-1, bidirectional, elements=1", + ) + ) + + context.pathNodes.shouldMatchTo( + Seq( + TestPathNodes(1, Vector(3, 2, 1)), + ) + ) + + context.pathDetails.shouldMatchTo( + Seq( + "forward=3>1 nodes=3, 2, 1", // TODO there should be no forward (or backward?) path + "backward=3>1 nodes=1, 2, 3", + ) + ) + pending + } +} diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N22_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N22_Test.scala new file mode 100644 index 000000000..967d5763f --- /dev/null +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N22_Test.scala @@ -0,0 +1,70 @@ +package kpn.server.analyzer.engine.analysis.route.structure + +import kpn.api.custom.ScopedNetworkType +import kpn.api.custom.Tags +import kpn.core.util.UnitTest + +// not a oneway route if both directions ok +class Structure_N22_Test extends UnitTest { + + private def setup = new StructureTestSetupBuilder() { + node(1, "01") + node(2, "02") + memberWay(10, "", 1, 2) + }.build("01", "02", ScopedNetworkType.rcn, Tags.from("oneway" -> "yes")) + + test("analyze") { + + val context = setup.analyze() + + context.facts.foreach(a => println(s""""$a",""")) + context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) + context.segments.foreach(a => println(s""""$a",""")) + context.paths.foreach(a => println(s""""$a",""")) + context.pathNodes.foreach(a => println(s"""$a,""")) + context.pathDetails.foreach(a => println(s""""$a",""")) + + // TODO context.facts.shouldMatchTo(Set(RouteNotOneWay)) + context.links.shouldMatchTo( + Seq( + "1 p n loop fp bp head tail d unconnected", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=2(02)", + ) + ) + + context.segments.shouldMatchTo( + Seq( + "segment-1 1>2", + " element-1 bidirectional 1>2 1(01) 2(02)", + " way-10 p n loop fp bp head tail d unconnected paths=1", + ) + ) + + context.paths.shouldMatchTo( + Seq( + "path-1, bidirectional, elements=1", + ) + ) + + context.pathNodes.shouldMatchTo( + Seq( + TestPathNodes(1, Vector(1, 2)), + ) + ) + + context.pathDetails.shouldMatchTo( + Seq( + "forward=1>2 nodes=1, 2", + "backward=1>2 nodes=2, 1", + ) + ) + pending + } +} diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N23_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N23_Test.scala new file mode 100644 index 000000000..9805de92a --- /dev/null +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N23_Test.scala @@ -0,0 +1,70 @@ +package kpn.server.analyzer.engine.analysis.route.structure + +import kpn.api.custom.ScopedNetworkType +import kpn.api.custom.Tags +import kpn.core.util.UnitTest + +// route with direction=forward, but forward not ok +class Structure_N23_Test extends UnitTest { + + private def setup = new StructureTestSetupBuilder() { + node(1, "01") + node(3, "02") + memberWayWithTags(10, "", Tags.from("highway" -> "road", "oneway" -> "yes"), 3, 2, 1) + }.build("01", "02", ScopedNetworkType.rcn, Tags.from("direction" -> "forward")) + + test("analyze") { + + val context = setup.analyze() + + context.facts.foreach(a => println(s""""$a",""")) + context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) + context.segments.foreach(a => println(s""""$a",""")) + context.paths.foreach(a => println(s""""$a",""")) + context.pathNodes.foreach(a => println(s"""$a,""")) + context.pathDetails.foreach(a => println(s""""$a",""")) + + // TODO context.facts.shouldMatchTo(Set(RouteNotForward, RouteNotContinious, RouteBroken)) + context.links.shouldMatchTo( + Seq( + "1 p n loop fp bp head tail d unconnected", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=3(02)", + "end=1(01)", + ) + ) + + context.segments.shouldMatchTo( + Seq( + "segment-1 3>1", + " element-1 bidirectional 3>1 3(02) 1(01)", + " way-10 p n loop fp bp head tail d unconnected paths=1", + ) + ) + + context.paths.shouldMatchTo( + Seq( + "path-1, bidirectional, elements=1", + ) + ) + + context.pathNodes.shouldMatchTo( + Seq( + TestPathNodes(1, Vector(3, 2, 1)), + ) + ) + + context.pathDetails.shouldMatchTo( + Seq( + "forward=3>1 nodes=3, 2, 1", + "backward=3>1 nodes=1, 2, 3", // TODO there should be only forward or backward + ) + ) + pending + } +} diff --git a/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N24_Test.scala b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N24_Test.scala new file mode 100644 index 000000000..06459aa63 --- /dev/null +++ b/server/src/test/scala/kpn/server/analyzer/engine/analysis/route/structure/Structure_N24_Test.scala @@ -0,0 +1,70 @@ +package kpn.server.analyzer.engine.analysis.route.structure + +import kpn.api.custom.ScopedNetworkType +import kpn.api.custom.Tags +import kpn.core.util.UnitTest + +// route with direction=backward, but backward not ok +class Structure_N24_Test extends UnitTest { + + private def setup = new StructureTestSetupBuilder() { + node(1, "01") + node(3, "02") + memberWayWithTags(10, "", Tags.from("highway" -> "road", "oneway" -> "yes"), 1, 2, 3) + }.build("01", "02", ScopedNetworkType.rcn, Tags.from("direction" -> "backward")) + + test("analyze") { + + val context = setup.analyze() + + context.facts.foreach(a => println(s""""$a",""")) + context.links.foreach(a => println(s""""$a",""")) + context.nodes.foreach(a => println(s""""$a",""")) + context.segments.foreach(a => println(s""""$a",""")) + context.paths.foreach(a => println(s""""$a",""")) + context.pathNodes.foreach(a => println(s"""$a,""")) + context.pathDetails.foreach(a => println(s""""$a",""")) + + // TODO context.facts.shouldMatchTo(Set(RouteNotBackward, RouteNotContinious, RouteBroken)) + context.links.shouldMatchTo( + Seq( + "1 p n loop fp bp head tail d unconnected", + ) + ) + + context.nodes.shouldMatchTo( + Seq( + "start=1(01)", + "end=3(02)", + ) + ) + + context.segments.shouldMatchTo( + Seq( + "segment-1 1>3", + " element-1 bidirectional 1>3 1(01) 3(02)", + " way-10 p n loop fp bp head tail d unconnected paths=1", + ) + ) + + context.paths.shouldMatchTo( + Seq( + "path-1, bidirectional, elements=1", + ) + ) + + context.pathNodes.shouldMatchTo( + Seq( + TestPathNodes(1, Vector(1, 2, 3)), + ) + ) + + context.pathDetails.shouldMatchTo( + Seq( + "forward=1>3 nodes=1, 2, 3", + "backward=1>3 nodes=3, 2, 1", // TODO there should be no backward path + ) + ) + pending + } +}
nameisInWay
reversed: ${routeNodeAnalysis.reversed}