little refactoring
This commit is contained in:
parent
8a530d9d48
commit
3f2b3eec45
3 changed files with 12 additions and 7 deletions
4
.idea/deploymentTargetSelector.xml
generated
4
.idea/deploymentTargetSelector.xml
generated
|
|
@ -4,10 +4,10 @@
|
|||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2025-08-21T11:17:37.943341883Z">
|
||||
<DropdownSelection timestamp="2025-08-25T12:35:44.992136184Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=96DX21GPR" />
|
||||
<DeviceId pluginId="LocalEmulator" identifier="path=/home/secondbeam/.config/.android/avd/Virtual_Pixel_3.avd" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
|
|
|
|||
|
|
@ -91,7 +91,8 @@ fun MapCanvas(
|
|||
val tileY = tileOffsetY + cellY
|
||||
val localOffsetY = TILE_SIZE * (cellY - 1)
|
||||
|
||||
val bitmap = tiles.find { it.x == tileX && it.y == tileY && it.level == level }?.toBitmap()
|
||||
val tile = tiles.find { it.x == tileX && it.y == tileY && it.level == level }!!
|
||||
val bitmap = tile.toBitmap()
|
||||
val totalOffset = Offset(localOffsetX, localOffsetY) - offset
|
||||
|
||||
bitmap?.let {
|
||||
|
|
@ -114,10 +115,8 @@ fun MapCanvas(
|
|||
text = buildAnnotatedString {
|
||||
withStyle(ParagraphStyle(textAlign = TextAlign.Center)) {
|
||||
withStyle(SpanStyle(color = gridColor)) {
|
||||
val mapSize = (1 shl (level - 1)).toDouble()
|
||||
val mappedY = (tileY.toDouble() - (mapSize / 2.0))
|
||||
val mercX = SphereMercator.sx2lon((tileX * TILE_SIZE).toDouble(), level) - 180.0
|
||||
val mercY = -SphereMercator.sy2lat(mappedY * TILE_SIZE, level - 1)
|
||||
val mercX = tile.mercateX()
|
||||
val mercY = tile.mercateY()
|
||||
append("%.6f, %.6f,\n%d, %d".format(mercX, mercY, tileX, tileY))
|
||||
}
|
||||
}
|
||||
|
|
@ -125,6 +124,8 @@ fun MapCanvas(
|
|||
topLeft = totalOffset,
|
||||
size = Size(TILE_SIZE, TILE_SIZE)
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,4 +46,8 @@ class Tile {
|
|||
bitmap = BitmapFactory.decodeByteArray(ba, 0, ba.size)
|
||||
return bitmap
|
||||
}
|
||||
|
||||
fun mercateX(): Double = SphereMercator.sx2lon((x * TILE_SIZE).toDouble(), level) - 180.0
|
||||
|
||||
fun mercateY(): Double = -SphereMercator.sy2lat((y.toDouble() - ((1 shl (level - 1)).toDouble() / 2.0)) * TILE_SIZE, level - 1)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue