-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#368 setup route analysis tool for development
- Loading branch information
Showing
7 changed files
with
118 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
server/src/main/scala/kpn/core/tools/next/support/RouteAnalysisTool.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package kpn.core.tools.next.support | ||
|
||
import kpn.api.common.tiles.ZoomLevel | ||
import kpn.api.custom.NetworkType | ||
import kpn.api.custom.Relation | ||
import kpn.core.tools.analysis.AnalysisStartConfiguration | ||
import kpn.core.tools.analysis.AnalysisStartToolOptions | ||
import kpn.core.util.Log | ||
|
||
object RouteAnalysisTool { | ||
def main(args: Array[String]): Unit = { | ||
val configuration = new AnalysisStartConfiguration(AnalysisStartToolOptions("kpn-next")) | ||
new RouteAnalysisTool(configuration).analyze() | ||
} | ||
} | ||
|
||
class RouteAnalysisTool(config: AnalysisStartConfiguration) { | ||
private val log = Log(classOf[RouteAnalysisTool]) | ||
|
||
def analyze(): Unit = { | ||
log.info("Start") | ||
analyzeRoutes(Seq(13844575L)) | ||
buildTiles() | ||
log.info(s"Done") | ||
} | ||
|
||
private def analyzeRoutes(routeIds: Seq[Long]): Unit = { | ||
val relations = config.overpassRepository.fullRelations(config.timestamp, routeIds) | ||
relations.foreach { relation => | ||
analyzeRoute(relation) | ||
} | ||
} | ||
|
||
private def analyzeRoute(relation: Relation): Unit = { | ||
Log.context(s"route=${relation.id}") { | ||
try { | ||
config.masterRouteAnalyzer.analyze(relation) match { | ||
case None => | ||
case Some(routeAnalysis) => | ||
config.routeRepository.save(routeAnalysis.route) | ||
// TODO saveRouteChange(routeAnalysis) | ||
} | ||
} catch { | ||
case e: Exception => | ||
log.error(s"Error processing route ${relation.id}", e) | ||
throw e | ||
} | ||
} | ||
} | ||
|
||
private def buildTiles(): Unit = { | ||
/* NetworkType.all */ Seq(NetworkType.hiking).foreach { networkType => | ||
Log.context(networkType.name) { | ||
log.info("Start tile analysis") | ||
val tileAnalysis = config.tileAnalyzer.analysis(networkType) | ||
(ZoomLevel.minZoom to ZoomLevel.vectorTileMaxZoom).foreach { z => | ||
Log.context(s"$z") { | ||
config.tilesBuilder.build(z, tileAnalysis) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters