Skip to content

Commit

Permalink
#368 migrate structure tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarc committed Jul 13, 2024
1 parent ba18e3f commit a51ecb6
Show file tree
Hide file tree
Showing 71 changed files with 472 additions and 2,320 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import kpn.server.analyzer.engine.analysis.route.analyzers.UnexpectedRelationRou
import kpn.server.analyzer.engine.analysis.route.analyzers.WithoutWaysRouteAnalyzer
import kpn.server.analyzer.engine.analysis.route.domain.RouteDetailAnalysisContext
import kpn.server.analyzer.engine.analysis.route.structure.RouteLinkAnalyzer
import kpn.server.analyzer.engine.analysis.route.structure.RoutePathAnalyzer
import kpn.server.analyzer.engine.analysis.route.structure.RouteSegmentAnalyzer
import org.springframework.stereotype.Component

Expand Down Expand Up @@ -92,7 +91,6 @@ class RouteDetailMainAnalyzerImpl(
RouteNodeAnalyzer,
RouteLinkAnalyzer,
RouteSegmentAnalyzer,
RoutePathAnalyzer,

OldRouteSegmentAnalyzer,
RouteStructureAnalyzer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import kpn.server.analyzer.engine.analysis.route.analyzers.RouteAnalysisBuilder
import kpn.server.analyzer.engine.analysis.route.segment.FragmentMap
import kpn.server.analyzer.engine.analysis.route.structure.NewRouteSegment
import kpn.server.analyzer.engine.analysis.route.structure.RouteLinks
import kpn.server.analyzer.engine.analysis.route.structure.RoutePath
import kpn.server.analyzer.engine.analysis.route.structure.Structure
import kpn.server.analyzer.engine.context.ElementIds
import kpn.server.analyzer.engine.context.PreconditionMissingException
Expand All @@ -44,7 +43,6 @@ case class RouteDetailAnalysisContext(
country: Option[Country] = None,
_links: Option[RouteLinks] = None,
_segments: Option[Seq[NewRouteSegment]] = None,
_paths: Option[Seq[RoutePath]] = None,
_segmentAnalysis: Option[RouteSegmentAnalysis] = None,
routeNodeInfos: Map[Long, RouteNodeInfo] = Map.empty,
facts: Seq[Fact] = Seq.empty,
Expand Down Expand Up @@ -173,8 +171,6 @@ case class RouteDetailAnalysisContext(

def segments: Seq[NewRouteSegment] = _segments.getOrElse(throw new PreconditionMissingException)

def paths: Seq[RoutePath] = _paths.getOrElse(throw new PreconditionMissingException)

def segmentAnalysis: RouteSegmentAnalysis = _segmentAnalysis.getOrElse(throw new PreconditionMissingException)

def routeNameAnalysis: RouteNameAnalysis = _routeNameAnalysis.getOrElse(throw new PreconditionMissingException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ class RoutePathReport(context: RouteDetailAnalysisContext) {
}

private def paths(): String = {
context.paths.map { path =>
val fromNode = path.elements.head.fromNetworkNode
val toNode = path.elements.last.toNetworkNode
context.segments.flatMap(_.elements).map { element =>
val fromNode = element.fromNetworkNode
val toNode = element.toNetworkNode
val from = fromNode.map(n => s"${ReportUtil.osmNodeLink(n.node.id)}(${n.name})").getOrElse("")
val to = toNode.map(n => s"${ReportUtil.osmNodeLink(n.node.id)}(${n.name})").getOrElse("")
val elementIds = path.elements.map(element => element.id).mkString(", ")
val elementIds = "" + element.id

s"""<tr>
| <td>
| Path ${path.id}
| Path ${element.id}
| </td>
| <td>
| ${path.direction.toString.toLowerCase}
| ${element.direction.toString.toLowerCase}
| </td>
| <td>
| $from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class RouteSegmentReport(context: RouteDetailAnalysisContext) {
| <td>from</td>
| <td>to</td>
| <td>network nodes</td>
| <td>paths</td>
| </tr>
|${segments()}
|</table>
Expand All @@ -46,8 +45,6 @@ class RouteSegmentReport(context: RouteDetailAnalysisContext) {
| </td>
| <td>
| </td>
| <td>
| </td>
|</tr>
|${segmentElements(segment)}
|""".stripMargin
Expand All @@ -70,8 +67,6 @@ class RouteSegmentReport(context: RouteDetailAnalysisContext) {
| </td>
| <td>
| </td>
| <td>
| </td>
|</tr>
|${elementFragments(element)}
|""".stripMargin
Expand Down Expand Up @@ -115,9 +110,6 @@ class RouteSegmentReport(context: RouteDetailAnalysisContext) {
| $to
| </td>
| <td>${networkNodeString(fragment.nodeIds)}</td>
| <td>
| ${fragment.pathIds.mkString(", ")}
| </td>
|</tr>
|""".stripMargin
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ case class NewRouteSegmentElementFragment(
wayId: Long,
link: Link,
role: Option[String],
nodeIds: Seq[Long],
pathIds: Seq[Long]
nodeIds: Seq[Long]
) {
def fromNodeId: Long = nodeIds.head

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ class RouteSegmentAnalyzer(context: RouteDetailAnalysisContext) {
routeLinkWay.way.id,
routeLinkWay.link,
routeLinkWay.role,
nodeIds,
Seq.empty // filled in later during path analysis
nodeIds
)

val fromNetworkNode = context.routeNodeAnalysis.nodes.find(_.node.id == fragment.fromNodeId)
Expand All @@ -255,8 +254,7 @@ class RouteSegmentAnalyzer(context: RouteDetailAnalysisContext) {
routeLinkWay.way.id,
routeLinkWay.link,
routeLinkWay.role,
nodeIds,
Seq.empty // filled in later during path analysis
nodeIds
)
}

Expand Down
Loading

0 comments on commit a51ecb6

Please sign in to comment.