Skip to content

Commit

Permalink
#278 monitor route analysis - wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarc committed Feb 7, 2024
1 parent 94a5ec2 commit 0c15938
Show file tree
Hide file tree
Showing 10 changed files with 17,071 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import java.nio.charset.Charset
object DownloadRelationTool {

private val routes = Seq(
"route" -> 5444896,
"route1" -> 16786092,
"route2" -> 16827727,
"route3" -> 16842517,
)

def main(args: Array[String]): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ class MonitorRouteOsmSegmentAnalyzerImpl() extends MonitorRouteOsmSegmentAnalyze

val nodes = wayMembers.flatMap(_.way.nodes).distinct
val nodeMap = nodes.map(node => node.id -> new Coordinate(node.lon, node.lat)).toMap
val elementGroups = StructureElementAnalyzer.analyze(wayMembers, traceEnabled = true)

val elementGroups = try {
StructureElementAnalyzer.analyze(wayMembers)
}
catch {
case e: Exception =>
log.error("Could not analyze structure", e)
Seq.empty
}

val routeSegments = elementGroups.zipWithIndex.map { case (elementGroup, index) =>
val lineStrings = elementGroup.elements.map { element =>
Expand Down
4,595 changes: 4,595 additions & 0 deletions server/src/test/resources/case-studies/monitor/16786092.xml

Large diffs are not rendered by default.

8,257 changes: 8,257 additions & 0 deletions server/src/test/resources/case-studies/monitor/16827727.xml

Large diffs are not rendered by default.

4,120 changes: 4,120 additions & 0 deletions server/src/test/resources/case-studies/monitor/16842517.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import scala.xml.XML

object CaseStudyCleanTool {
def main(args: Array[String]): Unit = {
new CaseStudyCleanTool().clean("monitor/5444896")
new CaseStudyCleanTool().clean("monitor/16786092")
new CaseStudyCleanTool().clean("monitor/16827727")
new CaseStudyCleanTool().clean("monitor/16842517")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,24 @@ class StructureAnalyzerTest extends UnitTest {

test("case study 2") {
val relation = CaseStudy.load("/case-studies/monitor/5444896.xml")
// val wayInfos = new ReferenceStructureAnalyzer().analyze(relation)
// wayInfos.foreach(println)
// new StructureAnalyzer().analyze(relation)
val elementGroups = StructureElementAnalyzer.analyze(relation.members)
elementGroups.size should equal(1)
}

test("case study 3") {
val relation = CaseStudy.load("/case-studies/monitor/16786092.xml")
val elementGroups = StructureElementAnalyzer.analyze(relation.members, traceEnabled = true)
elementGroups.size should equal(1)
}

test("case study 4") {
val relation = CaseStudy.load("/case-studies/monitor/16827727.xml")
val elementGroups = StructureElementAnalyzer.analyze(relation.members)
elementGroups.size should equal(1)
}

test("case study 5") {
val relation = CaseStudy.load("/case-studies/monitor/16842517.xml")
val elementGroups = StructureElementAnalyzer.analyze(relation.members)
elementGroups.size should equal(1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import kpn.api.custom.Tags
import kpn.core.util.UnitTest

// reproduces situation in route 5444896 (EV1 Roscoff — Morlaix)
class Structure_72_RoundaboutParts_Test extends UnitTest {
class Structure_72_SplitRoundabout_Test extends UnitTest {

private def setup = new StructureTestSetupBuilder() {
// before split:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package kpn.server.analyzer.engine.monitor.structure

import kpn.core.util.UnitTest

// reproduces situation in route 16786092 (EV1 Morlaix — Carhaix-Plouguer)
class Structure_73_Split_Test extends UnitTest {

private def setup = new StructureTestSetupBuilder() {
memberWay(11, "forward", 1, 2)
memberWay(12, "forward", 2, 3)
memberWay(13, "forward", 3, 4)
memberWay(14, "backward", 1, 5)
memberWay(15, "backward", 5, 6)
memberWay(16, "backward", 6, 4)
memberWay(17, "", 4, 7)
}.build

test("reference") {
setup.reference(traceEnabled = true).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",
)
)
}

test("elements") {
setup.elementGroups(traceEnabled = true).shouldMatchTo(
Seq(
Seq(
"1>4 (Down)",
"4>1 (Up)",
"4>7",
),
)
)
}

test("structure") {
val structure = setup.structure()
structure.shouldMatchTo(
TestStructure(
forwardPath = Some(
TestStructurePath(
startNodeId = 1,
endNodeId = 7,
nodeIds = Seq(1, 2, 3, 4, 7)
)
),
backwardPath = Some(
TestStructurePath(
startNodeId = 7,
endNodeId = 1,
nodeIds = Seq(7, 4, 6, 5, 1)
)
)
)
)
}
}

0 comments on commit 0c15938

Please sign in to comment.