Fixed map loading

This commit is contained in:
Alexey 2025-11-27 13:56:56 +03:00
commit 3a05a71f7f
2 changed files with 8 additions and 8 deletions

View file

@ -175,7 +175,7 @@ fun MapCanvas(
}
val crossRadius = 24F
drawCursor(halvedX, halvedY, crossRadius, KhmParser.getHeight(lon, lat, ctx), textMeasurer)
drawCursor(halvedX, halvedY, crossRadius, height, textMeasurer)
val additionalSize = if (debug) 96F else 0F
val infoBoxSize = Size(216F, 96F + additionalSize)

View file

@ -23,15 +23,15 @@ class KhmParser {
fun load(filePath: String, ctx: Context) {
if (fileExists(ctx)) {
return
clear(ctx)
}
val inp = FileInputStream(filePath)
if (checkHeader(inp))
ctx.openFileOutput(HEIGHT_FILE, Context.MODE_PRIVATE).use {
it.write(inp.readBytes())
}
ctx.openFileOutput(HEIGHT_FILE, Context.MODE_PRIVATE).use {
it.write(inp.readBytes())
}
inp.close()
}
@ -93,7 +93,7 @@ class KhmParser {
fun getHeight(lon: Float, lat: Float, ctx: Context): UShort {
if (!fileExists(ctx))
return 0u.toUShort()
return 0u
val dis = DataInputStream(ctx.openFileInput(HEIGHT_FILE))
dis.use {
val header = readHeader(dis)
@ -164,4 +164,4 @@ class KhmParser {
return header?.latPerValue ?: 0F
}
}
}
}