diff --git a/app/src/main/java/de/westnordost/streetcomplete/data/download/tiles/TilesRect.kt b/app/src/main/java/de/westnordost/streetcomplete/data/download/tiles/TilesRect.kt index dfd41d148a..edaf42c569 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/data/download/tiles/TilesRect.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/data/download/tiles/TilesRect.kt @@ -7,6 +7,8 @@ import kotlinx.serialization.Serializable import kotlin.math.PI import kotlin.math.asinh import kotlin.math.atan +import kotlin.math.nextDown +import kotlin.math.nextUp import kotlin.math.sinh import kotlin.math.tan @@ -114,12 +116,12 @@ private fun tile2lon(x: Int, zoom: Int): Double = 360.0 * x / numTiles(zoom).toDouble() - 180.0 private fun tile2lat(y: Int, zoom: Int): Double = - 180.0 * atan(sinh(PI * (1.0 - 2.0 * y / numTiles(zoom)))) / PI + (180.0 / PI * atan(sinh(PI * (1.0 - 2.0 * y / numTiles(zoom))))).nextDown() private fun lon2tile(lon: Double, zoom: Int): Int = (numTiles(zoom) * (lon + 180.0) / 360.0).toInt() private fun lat2tile(lat: Double, zoom: Int): Int = - (numTiles(zoom) * (1.0 - asinh(tan(PI * lat / 180.0)) / PI) / 2.0).toInt() + (numTiles(zoom) * (1.0 - asinh(tan(PI * lat / 180.0)) / PI) / 2.0).nextUp().toInt() private fun numTiles(zoom: Int): Int = 1 shl zoom