diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-17 21:39:33 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-17 21:39:33 -0600 |
commit | c3c57a26e62857434830c9b22bb4757edda2b202 (patch) | |
tree | 20b1cb3fed2353705b9a937568e3e231c57b83fa /shared/src/commonMain/kotlin | |
parent | 07d184c408aba980f331ecaa3e4baef80b6ce82c (diff) | |
download | etbsa-trackermap-mobile-c3c57a26e62857434830c9b22bb4757edda2b202.tar.gz etbsa-trackermap-mobile-c3c57a26e62857434830c9b22bb4757edda2b202.tar.bz2 etbsa-trackermap-mobile-c3c57a26e62857434830c9b22bb4757edda2b202.zip |
Refactored map fragment into wrapper with an overlay that contains zoom buttons
Diffstat (limited to 'shared/src/commonMain/kotlin')
-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 |