diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-16 02:31:26 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-16 02:31:26 -0600 |
commit | 18bc70d4fa7453c1191fc446327d1e24d5defe6d (patch) | |
tree | a6c977cae455374bbbc705c06d5c980286767f9a /shared/src/commonMain | |
parent | 73a7543dbd286a4ff3b6bd4d3155823491102095 (diff) | |
download | etbsa-trackermap-mobile-18bc70d4fa7453c1191fc446327d1e24d5defe6d.tar.gz etbsa-trackermap-mobile-18bc70d4fa7453c1191fc446327d1e24d5defe6d.tar.bz2 etbsa-trackermap-mobile-18bc70d4fa7453c1191fc446327d1e24d5defe6d.zip |
Set zoom limits of mapControl by converting zoom levels to Mapnik scale denominators
Diffstat (limited to 'shared/src/commonMain')
-rw-r--r-- | shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt | 31 |
1 files changed, 31 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 new file mode 100644 index 0000000..8c58179 --- /dev/null +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt @@ -0,0 +1,31 @@ +package mx.trackermap.TrackerMap.utils + +class MapCalculus { + companion object { + // 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 -> 1000.0 // made up + 20 -> 500.0 // made up + else -> null + } + } +}
\ No newline at end of file |