diff options
Diffstat (limited to 'shared/src/commonMain')
-rw-r--r-- | shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt index d4d69fa..1a0d27b 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt @@ -1,5 +1,7 @@ package mx.trackermap.TrackerMap.utils +import kotlin.math.roundToLong + class MapCalculus { companion object { /** @@ -36,5 +38,36 @@ class MapCalculus { 24 -> 33.3238997478125 else -> null } + + fun scaleToZoomLevel(scale: Double): Int { + fun z(d: Int) = zoomLevelToScale(d)!! + return when { + scale > z(1) -> 1 + scale in z(2)..z(1) -> 2 + scale in z(3)..z(2) -> 3 + scale in z(4)..z(3) -> 4 + scale in z(5)..z(4) -> 5 + scale in z(6)..z(5) -> 6 + scale in z(7)..z(6) -> 7 + scale in z(8)..z(7) -> 8 + scale in z(9)..z(8) -> 9 + scale in z(10)..z(9) -> 10 + scale in z(11)..z(10) -> 11 + scale in z(12)..z(11) -> 12 + scale in z(13)..z(12) -> 13 + scale in z(14)..z(13) -> 14 + scale in z(15)..z(14) -> 15 + scale in z(16)..z(15) -> 16 + scale in z(17)..z(16) -> 17 + scale in z(18)..z(17) -> 18 + scale in z(19)..z(18) -> 19 + scale in z(20)..z(19) -> 20 + scale in z(21)..z(20) -> 21 + scale in z(22)..z(21) -> 22 + scale in z(23)..z(22) -> 23 + scale in z(24)..z(23) -> 24 + else -> 24 + } + } } }
\ No newline at end of file |