NitfCoordinates

Decode the 60-byte IGEOLO field into a list of four corner locations.

The layout depends on ICORDS (MIL-STD-2500C §5.4.3.7):

  • ' ' : IGEOLO field absent.

  • 'G' : 15-byte BCS-A string per corner — ddmmssXdddmmssY.

  • 'D' : 15-byte BCS-A string per corner — ±dd.ddd±ddd.ddd.

  • 'N'/'S' : 15-byte BCS-A string per corner — zzeeeeeennnnnnnn (UTM zone + easting + northing, MGRS hemisphere implied by N/S).

  • 'U' : 15-byte MGRS string per corner. Not yet implemented — we surface null here so callers can choose to fall back to a side-channel.

Corners are given in clockwise order starting from the upper-left (per §5.4.3.7), so 0=NW, 1=NE, 2=SE, 3=SW. We surface the four corners verbatim and a derived axis-aligned Sector for the common "show on globe" use case.

Types

Link copied to clipboard
data class Decoded(val corners: List<Location>, val sector: Sector)

Result of decoding IGEOLO. corners is in spec order NW/NE/SE/SW.

Functions

Link copied to clipboard
fun decode(coordinateSystem: NitfCoordinateSystem, igeolo: String): NitfCoordinates.Decoded?
Link copied to clipboard
fun utmToLatLon(zone: Int, easting: Double, northing: Double, northHemisphere: Boolean): Location

Convert UTM (WGS-84) easting/northing to geographic latitude/longitude. Implements Karney's series expansion (USGS Snyder §8.39–8.50 with higher-order terms folded in) — accurate to <1 mm within the UTM grid's normal usage zone (±84° lat). Good enough for georeferencing a NITF image footprint.