diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-17 23:46:13 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-17 23:46:13 -0600 |
commit | 675eb2739105e53a8f5f0f602b3c2b2206d28623 (patch) | |
tree | 183b82c471e611d6de0390270e690e238265b149 /shared/src/commonMain/kotlin/mx | |
parent | 9ff880b37f3e44aa3edbd402c8c01aed5467e26a (diff) | |
parent | 9325b6e0de41e8446bb6ce66915fb0c9fe0de4f3 (diff) | |
download | etbsa-trackermap-mobile-675eb2739105e53a8f5f0f602b3c2b2206d28623.tar.gz etbsa-trackermap-mobile-675eb2739105e53a8f5f0f602b3c2b2206d28623.tar.bz2 etbsa-trackermap-mobile-675eb2739105e53a8f5f0f602b3c2b2206d28623.zip |
Merge branch 'main' of https://git.sr.ht/~avalos/trackermap-mobile
Conflicts:
androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt
Diffstat (limited to 'shared/src/commonMain/kotlin/mx')
-rw-r--r-- | shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt | 3 | ||||
-rw-r--r-- | shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt | 33 |
2 files changed, 36 insertions, 0 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt index 4bda0ae..7d01282 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt @@ -40,6 +40,9 @@ open class ApiClient(val baseUrl: String) { logger = Logger.DEFAULT level = LogLevel.ALL } + engine { + requestTimeout = 10_000 + } } val defaultHeaders: Map<String, String> = 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 |