Companion

object Companion

Properties

Link copied to clipboard
const val ACC_OFFSET: Int
Link copied to clipboard
const val ACC_SIZE: Int = 2700
Link copied to clipboard
const val DATA_OFFSET: Int
Link copied to clipboard
const val DSI_OFFSET: Int
Link copied to clipboard
const val DSI_SIZE: Int = 648
Link copied to clipboard
const val INVALID_POST: Int

Sentinel returned by decodePost for a NODATA / out-of-range elevation post.

Link copied to clipboard
const val MAX_VALUE: Int = 9000
Link copied to clipboard
const val MIN_VALUE: Int
Link copied to clipboard
const val NODATA_VALUE: Int
Link copied to clipboard
const val REC_CHKSUM_SIZE: Int = 4
Link copied to clipboard
const val REC_HEADER_SIZE: Int = 8
Link copied to clipboard
const val UHL_OFFSET: Int = 0
Link copied to clipboard
const val UHL_SIZE: Int = 80

Functions

Link copied to clipboard
fun decodePost(hi: Int, lo: Int): Int

Decode a big-endian post from bytes hi/lo. DTED elevations are sign-magnitude (bit 15 = sign), not two's complement; returns metres, or INVALID_POST for NODATA / out-of-range.

Link copied to clipboard
operator fun invoke(bytes: ByteArray): DTED

Convenience: lets callers write DTED(bytes) instead of DTED.parse(bytes).

Link copied to clipboard
fun parse(bytes: ByteArray): DTED

Decode a complete DTED file held in memory.

Link copied to clipboard
fun DTED.Companion.read(path: String): DTED

Streaming DTED reader. Reads the header, then walks the per-column records one at a time via NSFileHandle — peak memory is the header (~3.4 KB) plus a single per-column record (~7 KB on .dt2) plus the output grid, instead of the entire file (~26 MB on .dt2). iOS analogue of the JVM read overload.

fun DTED.Companion.read(file: File): DTED

Streaming reader: walks column records one at a time, so peak memory is ~7 KB (one record) not ~26 MB.

fun DTED.Companion.read(file: File, targetWidth: Int, targetHeight: Int): ShortArray

Full-cell convenience: resample the entire native grid to targetWidth × targetHeight.

fun DTED.Companion.read(file: File, colFrac0: Double, colFrac1: Double, rowFrac0: Double, rowFrac1: Double, targetWidth: Int, targetHeight: Int): ShortArray

Windowed streaming reader: bilinear-resamples a cell-relative sub-rectangle (colFrac/rowFrac in [0,1]) to targetWidth × targetHeight, reading only the two columns and post span the window touches. Bilinear so coarse levels upsample smoothly (dt2 at 1:1 is exact); a sample with any invalid corner → Short.MIN_VALUE. For render-path speed it skips the per-record checksum (DTED.parse validates).

Link copied to clipboard

Parse only the UHL/DSI/ACC headers (~3.4 KB); bytes may be the full file or just the header.

Link copied to clipboard
fun DTED.Companion.readMetadata(path: String): DTED.Metadata

Read only the UHL/DSI/ACC headers from a DTED file on disk. Reads the first 3428 bytes and closes the handle — useful when indexing a library of tiles without loading the elevation grid (~26 MB for .dt2). iOS analogue of the JVM readMetadata overload.

fun DTED.Companion.readMetadata(file: File): DTED.Metadata

Read the full UHL/DSI/ACC headers (first 3428 bytes) — when the DTED level/classification are needed.

Link copied to clipboard

Coarse n×n overview (north-up, row-major): nearest-samples n evenly-spaced columns in one pass each. Cheap path for zoomed-out grids — ~n column reads vs the window's ~2·n, no rebuffering/interpolation. Invalid posts → Short.MIN_VALUE; like the windowed read it skips per-record checksums.

Link copied to clipboard
fun recordSize(height: Int): Int

Per-column record size in bytes for a given latitude post count.