maps-kt/src/commonMain/kotlin/centre/sciprog/maps/compose/MapTileProvider.kt

29 lines
580 B
Kotlin
Raw Normal View History

2022-07-10 22:37:07 +03:00
package centre.sciprog.maps.compose
import androidx.compose.ui.graphics.ImageBitmap
import kotlin.math.floor
data class TileId(
val zoom: Int,
val i: Int,
val j: Int,
)
data class MapTile(
val id: TileId,
val image: ImageBitmap,
)
interface MapTileProvider {
suspend fun loadTile(id: TileId): MapTile
2022-07-11 20:29:07 +03:00
val tileSize: Int get() = DEFAULT_TILE_SIZE
fun toIndex(d: Double): Int = floor(d / tileSize).toInt()
fun toCoordinate(i: Int): Double = (i * tileSize).toDouble()
companion object {
2022-07-10 22:37:07 +03:00
const val DEFAULT_TILE_SIZE = 256
}
}