Skip to content

Commit

Permalink
#368 move monitor structure analysis to route analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarc committed Jun 21, 2024
1 parent 96d3b80 commit a2306f5
Show file tree
Hide file tree
Showing 81 changed files with 100 additions and 101 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

case class StructurePathElement(
element: StructureElement,
Expand Down Expand Up @@ -31,4 +31,4 @@ case class StructurePathElement(
element.nodeIds.last
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure.reference;
package kpn.server.analyzer.engine.analysis.route.structure.reference;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure.reference;
package kpn.server.analyzer.engine.analysis.route.structure.reference;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure.reference;
package kpn.server.analyzer.engine.analysis.route.structure.reference;

import java.util.HashMap;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure.reference;
package kpn.server.analyzer.engine.analysis.route.structure.reference;

import java.util.HashMap;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package kpn.server.analyzer.engine.monitor.structure.reference;
package kpn.server.analyzer.engine.analysis.route.structure.reference;

import kpn.server.analyzer.engine.monitor.structure.reference.WayInfo.Direction;
import kpn.server.analyzer.engine.analysis.route.structure.reference.WayInfo.Direction;

import static kpn.server.analyzer.engine.monitor.structure.reference.WayInfo.Direction.NONE;
import static kpn.server.analyzer.engine.monitor.structure.reference.WayInfo.Direction.ROUNDABOUT_RIGHT;
import static kpn.server.analyzer.engine.analysis.route.structure.reference.WayInfo.Direction.NONE;
import static kpn.server.analyzer.engine.analysis.route.structure.reference.WayInfo.Direction.ROUNDABOUT_RIGHT;

public class Utils {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure.reference;
package kpn.server.analyzer.engine.analysis.route.structure.reference;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -67,4 +67,4 @@ public String toString() {
String nodeIds = nodes.stream().map(node -> node.getId().toString()).collect(Collectors.joining(", ", "(", ")"));
return String.format("Way(id=%d, nodeIds=%s)", id, nodeIds);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure.reference;
package kpn.server.analyzer.engine.analysis.route.structure.reference;

public class WayInfo {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package kpn.server.analyzer.engine.monitor.structure.reference;
package kpn.server.analyzer.engine.analysis.route.structure.reference;

import kpn.server.analyzer.engine.monitor.structure.reference.WayInfo.Direction;
import kpn.server.analyzer.engine.analysis.route.structure.reference.WayInfo.Direction;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import static java.util.stream.Collectors.joining;
import static kpn.server.analyzer.engine.monitor.structure.reference.WayInfo.Direction.*;
import static kpn.server.analyzer.engine.analysis.route.structure.reference.WayInfo.Direction.*;

public class WayInfoAnalyzer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import kpn.core.util.Haversine
import kpn.core.util.Log
import kpn.server.analyzer.engine.monitor.domain.MonitorRouteOsmSegmentAnalysis
import kpn.server.analyzer.engine.monitor.domain.MonitorRouteSegmentData
import kpn.server.analyzer.engine.monitor.structure.ElementDirection
import kpn.server.analyzer.engine.monitor.structure.StructureElementAnalyzer
import kpn.server.analyzer.engine.analysis.route.structure.ElementDirection
import kpn.server.analyzer.engine.analysis.route.structure.StructureElementAnalyzer
import org.locationtech.jts.geom.Coordinate
import org.locationtech.jts.geom.GeometryFactory
import org.springframework.stereotype.Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import kpn.core.loadOld.Parser
import kpn.core.overpass.OverpassQueryExecutorRemoteImpl
import kpn.core.overpass.QueryRelation
import kpn.core.tools.config.Dirs
import kpn.server.analyzer.engine.monitor.structure.StructureElementAnalyzer
import kpn.server.analyzer.engine.analysis.route.structure.StructureElementAnalyzer
import org.apache.commons.io.FileUtils

import java.io.File
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kpn.server.analyzer.engine.analysis.route

import kpn.server.analyzer.engine.monitor.structure.Structure
import kpn.server.analyzer.engine.analysis.route.structure.Structure

case class RouteSegmentAnalysis(
osmDistance: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import kpn.server.analyzer.engine.analysis.route.RouteSegmentAnalysis
import kpn.server.analyzer.engine.analysis.route.RouteSegmentData
import kpn.server.analyzer.engine.analysis.route.domain.RouteAnalysisContext
import kpn.server.analyzer.engine.monitor.MonitorRouteAnalysisSupport
import kpn.server.analyzer.engine.monitor.structure.ElementDirection
import kpn.server.analyzer.engine.monitor.structure.StructureAnalyzer
import kpn.server.analyzer.engine.monitor.structure.StructureElementAnalyzer
import kpn.server.analyzer.engine.analysis.route.structure.ElementDirection
import kpn.server.analyzer.engine.analysis.route.structure.StructureAnalyzer
import kpn.server.analyzer.engine.analysis.route.structure.StructureElementAnalyzer
import org.locationtech.jts.geom.Coordinate
import org.locationtech.jts.geom.GeometryFactory

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

object Direction extends Enumeration {
val Forward, Backward, RoundaboutLeft, RoundaboutRight = Value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

object ElementDirection extends Enumeration {
val Forward, Backward = Value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

case class Structure(
forwardPath: Option[StructurePath],
backwardPath: Option[StructurePath],
otherPaths: Seq[StructurePath]
)
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.api.custom.Relation

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

object StructureElement {
def from(fragments: Seq[StructureFragment], direction: Option[ElementDirection.Value]): StructureElement = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.api.common.data.Member
import kpn.api.common.data.WayMember
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

case class StructureElementGroup(
elements: Seq[StructureElement]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.api.common.data.Way

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.api.common.data.Member
import kpn.api.custom.Relation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.api.common.data.Member

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

case class StructurePath(
startNodeId: Long,
Expand All @@ -11,4 +11,4 @@ case class StructurePath(
case None => Seq.empty
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

object StructureUtil {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.api.common.data.WayMember

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.api.common.data.Member
import kpn.api.common.data.WayMember
import kpn.api.custom.Relation
import kpn.server.analyzer.engine.monitor.structure.reference.WayInfo
import kpn.server.analyzer.engine.monitor.structure.reference.WayInfoAnalyzer
import kpn.server.analyzer.engine.analysis.route.structure.reference.WayInfo
import kpn.server.analyzer.engine.analysis.route.structure.reference.WayInfoAnalyzer

import java.util.Collections
import java.util.stream.Collectors.toUnmodifiableList
Expand All @@ -20,23 +20,23 @@ class ReferenceStructureAnalyzer(traceEnabled: Boolean = false) {
analyzer.analyze().asScala.toSeq.zipWithIndex.map { case (wayInfo, index) => s"${index + 1} ${wayInfoString(wayInfo)}" }
}

private def buildReferenceRelation(relation: Relation): kpn.server.analyzer.engine.monitor.structure.reference.Relation = {
val nodeMap = mutable.Map[Long, kpn.server.analyzer.engine.monitor.structure.reference.Node]()
private def buildReferenceRelation(relation: Relation): kpn.server.analyzer.engine.analysis.route.structure.reference.Relation = {
val nodeMap = mutable.Map[Long, kpn.server.analyzer.engine.analysis.route.structure.reference.Node]()
val referenceRelationMembers = relation.members.map {
case wayMember: WayMember =>
val referenceRole = buildReferenceRole(wayMember)
val referenceNodes = buildReferenceNodes(nodeMap, wayMember)
val referenceTags = buildReferenceTags(wayMember)
val referenceWay = new kpn.server.analyzer.engine.monitor.structure.reference.Way(
val referenceWay = new kpn.server.analyzer.engine.analysis.route.structure.reference.Way(
wayMember.way.id,
referenceTags,
referenceNodes
)
new kpn.server.analyzer.engine.monitor.structure.reference.Member(referenceRole, referenceWay)
new kpn.server.analyzer.engine.analysis.route.structure.reference.Member(referenceRole, referenceWay)

case _ => throw new IllegalStateException("non way member types not implemented yet")
}.asJavaCollection.stream.collect(toUnmodifiableList())
new kpn.server.analyzer.engine.monitor.structure.reference.Relation(referenceRelationMembers)
new kpn.server.analyzer.engine.analysis.route.structure.reference.Relation(referenceRelationMembers)
}

private def buildReferenceRole(member: Member): String = {
Expand All @@ -46,9 +46,9 @@ class ReferenceStructureAnalyzer(traceEnabled: Boolean = false) {
}
}

private def buildReferenceNodes(nodeMap: mutable.Map[Long, kpn.server.analyzer.engine.monitor.structure.reference.Node], wayMember: WayMember): java.util.List[kpn.server.analyzer.engine.monitor.structure.reference.Node] = {
private def buildReferenceNodes(nodeMap: mutable.Map[Long, kpn.server.analyzer.engine.analysis.route.structure.reference.Node], wayMember: WayMember): java.util.List[kpn.server.analyzer.engine.analysis.route.structure.reference.Node] = {
wayMember.way.nodes.map { node =>
nodeMap.getOrElseUpdate(node.id, new kpn.server.analyzer.engine.monitor.structure.reference.Node(node.id))
nodeMap.getOrElseUpdate(node.id, new kpn.server.analyzer.engine.analysis.route.structure.reference.Node(node.id))
}.asJavaCollection.stream.collect(toUnmodifiableList())
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

case class StructureAnalysisResult(
reference: Seq[String],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest
import kpn.server.analyzer.engine.analysis.caseStudies.CaseStudy
Expand All @@ -23,13 +23,13 @@ class StructureAnalyzerTest extends UnitTest {
test("case study 3") {
val relation = CaseStudy.load("/case-studies/monitor/16786092.xml")
val elementGroups = StructureElementAnalyzer.analyze(relation.members)
elementGroups.size should equal(1)
elementGroups.size should equal(4)
}

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

test("case study 5") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.api.custom.Relation
import kpn.core.data.Data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.api.common.SharedTestObjects
import kpn.api.common.data.raw.RawData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kpn.server.analyzer.engine.monitor.structure
package kpn.server.analyzer.engine.analysis.route.structure

import kpn.core.util.UnitTest

Expand Down
Loading

0 comments on commit a2306f5

Please sign in to comment.