diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-16 04:16:53 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-16 04:16:53 -0600 |
commit | 4a796e47bede0cbe5512868001c22b6889e9f72e (patch) | |
tree | 48aa1dfed3dcae88f0453c1c9c4788d04173f9e0 /shared/src/commonMain | |
parent | 51d42034f00cc640ff94c06333e2354c8e440a3f (diff) | |
parent | a2ba612c515a53cb6e7f283858a518d60188651b (diff) | |
download | etbsa-trackermap-mobile-4a796e47bede0cbe5512868001c22b6889e9f72e.tar.gz etbsa-trackermap-mobile-4a796e47bede0cbe5512868001c22b6889e9f72e.tar.bz2 etbsa-trackermap-mobile-4a796e47bede0cbe5512868001c22b6889e9f72e.zip |
Merge branch 'main' of https://git.sr.ht/~avalos/trackermap-mobile
Diffstat (limited to 'shared/src/commonMain')
-rw-r--r-- | shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/MapLayer.kt | 8 | ||||
-rw-r--r-- | shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt | 37 |
2 files changed, 45 insertions, 0 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/MapLayer.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/MapLayer.kt new file mode 100644 index 0000000..64381d9 --- /dev/null +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/MapLayer.kt @@ -0,0 +1,8 @@ +package mx.trackermap.TrackerMap.client.models + +data class MapLayer( + val url: String, + val minZoom: Int, + val maxZoom: Int, + val attribution: String +)
\ No newline at end of file diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt new file mode 100644 index 0000000..118c117 --- /dev/null +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt @@ -0,0 +1,37 @@ +package mx.trackermap.TrackerMap.utils + +class MapCalculus { + companion object { + /** + * WhirlyGlobe library uses height rather than zoom levels, but it supports converting + * Mapnik denominator scales to height, so we can first convert zoom levels to Mapnik + * denominator scales, and then convert them to height using WhirlyGlobe. + * Source: https://github.com/openstreetmap/mapnik-stylesheets/blob/master/zoom-to-scale.txt + */ + fun zoomLevelToScale(zoom: Int): Double? = + when (zoom) { + 1 -> 279541132.014 + 2 -> 139770566.007 + 3 -> 69885283.0036 + 4 -> 34942641.5018 + 5 -> 17471320.7509 + 6 -> 8735660.37545 + 7 -> 4367830.18772 + 8 -> 2183915.09386 + 9 -> 1091957.54693 + 10 -> 545978.773466 + 11 -> 272989.386733 + 12 -> 136494.693366 + 13 -> 68247.3466832 + 14 -> 34123.6733416 + 15 -> 17061.8366708 + 16 -> 8530.9183354 + 17 -> 4265.4591677 + 18 -> 2132.72958385 + 19 -> 1066.36479193 + 20 -> 533.182395965 + 21 -> 266.5911979825 + else -> null + } + } +}
\ No newline at end of file |