-
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.
#369 monitor vector tiles - proof-of-concept wip
- Loading branch information
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
server/src/main/scala/kpn/core/tools/monitor/support/MonitorTileReportTool.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,48 @@ | ||
package kpn.core.tools.monitor.support | ||
|
||
import kpn.core.util.Log | ||
import kpn.database.util.Mongo | ||
import kpn.server.monitor.repository.MonitorRelationRepository | ||
import kpn.server.monitor.repository.MonitorRelationRepositoryImpl | ||
import kpn.server.monitor.repository.MonitorRouteRepository | ||
import kpn.server.monitor.repository.MonitorRouteRepositoryImpl | ||
|
||
object MonitorTileReportTool { | ||
def main(args: Array[String]): Unit = { | ||
Mongo.executeIn("kpn-monitor") { database => | ||
val routeRepository = new MonitorRouteRepositoryImpl(database) | ||
val relationRepository = new MonitorRelationRepositoryImpl(database) | ||
val tool = new MonitorTileReportTool( | ||
routeRepository, | ||
relationRepository | ||
) | ||
tool.report() | ||
} | ||
} | ||
} | ||
|
||
class MonitorTileReportTool( | ||
routeRepository: MonitorRouteRepository, | ||
relationRepository: MonitorRelationRepository | ||
) { | ||
private val log = Log(classOf[MonitorTileReportTool]) | ||
|
||
def report(): Unit = { | ||
val tileNames = readTileNames() | ||
println("|level|tile count|") | ||
println("|---|---|") | ||
(1 to 14).foreach { level => | ||
val tileCount = tileNames.filter(_.startsWith(s"$level-")).size | ||
println(s"|$level|$tileCount|") | ||
} | ||
val totalTileCount = tileNames.size | ||
println(s"|total|$totalTileCount|") | ||
} | ||
|
||
private def readTileNames(): Seq[String] = { | ||
log.infoElapsed { | ||
val tileNames = relationRepository.allTiles().map(_.name) | ||
(s"read ${tileNames.size} tile names", tileNames) | ||
} | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
server/src/main/scala/kpn/server/monitor/repository/MonitorTileData.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,6 @@ | ||
package kpn.server.monitor.repository | ||
|
||
case class MonitorTileData( | ||
name: String, | ||
relationIds: Seq[Long] | ||
) |