Skip to content

Commit

Permalink
#368 improve old/new edge comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarc committed Jul 20, 2024
1 parent 795a625 commit 7d04562
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class RouteAnalysisCompareTool(config: AnalysisStartConfiguration) {

def analyze(): Unit = {
log.info("Collecting routeIds")
val routeIds = config.oldDatabase.oldRoutes.ids()
// val routeIds = readRouteIds("logs/mismatch-ids-5.txt")
// val routeIds = Seq(17613906L)
// val routeIds = config.oldDatabase.oldRoutes.ids()
// val routeIds = readRouteIds("logs/mismatch-ids-7.txt")
val routeIds = Seq(17402807L)
log.info(s"Comparing ${routeIds.size} routes")
routeIds.zipWithIndex.foreach { case (routeId, index) =>
if (index % 50 == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class RouteAnalysisTool(config: AnalysisStartConfiguration) {
// analyzeRoutes(essenOkRouteIds)
// analyzeRoutes(law9)
// analyzeRoutes(Seq(13844575L))
analyzeRoutes(Seq(17613906L)) // exception during structure analysis
analyzeRoutes(Seq(17402807L)) // exception during structure analysis
// analyzeRoutes(Seq(3952592)) // broken route
// analyzeRoutes(Seq(3963819)) // route with roundabout
buildTiles()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class CompareEdges(oldRouteDoc: OldRouteDoc, newRouteDoc: RouteDetailDoc, log: L
// cannot compare edges
return
}
if (oldRouteDoc.edges.isEmpty && newRouteDoc.edges.nonEmpty) {
// new analysis found edges: assume new edges better than old
return
}

val oldEdges = oldCompareEdges()
val newEdges = newCompareEdges()
Expand Down Expand Up @@ -74,9 +78,10 @@ class CompareEdges(oldRouteDoc: OldRouteDoc, newRouteDoc: RouteDetailDoc, log: L

private def edgesEqual(oldEdges: Seq[CompareEdge], newEdges: Seq[CompareEdge]): Boolean = {
if (oldEdges.size == newEdges.size) {
oldEdges.zip(newEdges).forall { case (oldEdge, newEdge) =>
edgeEqual(oldEdge, newEdge)
val mismatches = oldEdges.filter { oldEdge =>
!newEdges.exists(newEdge => edgeEqual(oldEdge, newEdge))
}
mismatches.isEmpty
}
else {
false
Expand Down

0 comments on commit 7d04562

Please sign in to comment.