JBP Utilities
Adapter classes for parsing and formatting NITF metadata field values. These
utilities convert between raw NITF string representations and structured Python
objects.
Note
These adapters work with the values accessible from
MetadataProvider (via dict-style access or entries()). They
do not read files directly — use IO to open a dataset
first, then pass metadata values to the appropriate adapter.
DateTimeAdapter
-
class aws.osml.io.jbp.utils.DateTimeAdapter
Bases: object
Converts between 14-character NITF FDT strings and Python datetime objects.
-
static parse(fdt)
Parse a 14-char FDT string into datetime or NitfDateTime.
Returns datetime.datetime when all components are known,
NitfDateTime when any component is “–“.
Raises ValueError for invalid length or out-of-range components.
- Return type:
Union[datetime, NitfDateTime]
-
static format(dt)
Format a datetime or NitfDateTime into a 14-char FDT string.
NitfDateTime with None components produces “–” in those positions.
Always returns exactly 14 characters.
- Return type:
str
NitfDateTime
-
class aws.osml.io.jbp.utils.NitfDateTime(year, month=None, day=None, hour=None, minute=None, second=None)
Bases: object
Parsed NITF datetime with optional components for unknown values.
-
year: int
-
month: int | None = None
-
day: int | None = None
-
hour: int | None = None
-
minute: int | None = None
-
second: int | None = None
IGEOLOAdapter
-
class aws.osml.io.jbp.utils.IGEOLOAdapter
Bases: object
Converts between 60-character NITF IGEOLO strings and structured coordinates.
-
static parse(igeolo, icords)
Parse a 60-char IGEOLO string based on ICORDS value.
ICORDS=”G”: Returns List[Tuple[float, float]] — 4 (lat, lon) in decimal degrees
ICORDS=”D”: Returns List[Tuple[float, float]] — 4 (lat, lon) in decimal degrees
ICORDS=”N”/”S”: Returns List[UTMCoordinate] — 4 UTM coordinates
ICORDS=”U”: Returns List[str] — 4 MGRS coordinate strings
Raises ValueError for invalid IGEOLO length, bad hemisphere indicators,
or non-numeric characters where digits are expected.
- Return type:
list
-
static format(coords, icords)
Format coordinates into a 60-char IGEOLO string.
ICORDS=”G”: coords is List[Tuple[float, float]] (lat, lon) in decimal degrees
ICORDS=”D”: coords is List[Tuple[float, float]] (lat, lon) in decimal degrees
ICORDS=”N”/”S”: coords is List[UTMCoordinate]
ICORDS=”U”: coords is List[str] (MGRS strings, padded to 15 chars)
Always returns exactly 60 characters.
- Return type:
str
UTMCoordinate
-
class aws.osml.io.jbp.utils.UTMCoordinate(zone, easting, northing)
Bases: object
UTM coordinate with zone, easting, and northing.
-
zone: int
-
easting: int
-
northing: int
SecurityClassificationAdapter
-
class aws.osml.io.jbp.utils.SecurityClassificationAdapter
Bases: object
Converts between prefixed NITF security metadata dicts and SecurityClassification.
Extract security fields from a metadata dict using the given prefix.
Supports prefixes: “FS”, “IS”, “TS”, “SS”, “DES”.
Missing fields use NITF defaults (“U” for CLAS, “” for others).
- Return type:
SecurityClassification
-
static to_dict(sec, prefix)
Convert a SecurityClassification to a prefixed metadata dict.
Returns a dict suitable for setting on BufferedMetadataProvider.
- Return type:
dict
SecurityClassification
-
class aws.osml.io.jbp.utils.SecurityClassification(clas='U', clsy='', code='', ctlh='', rel='', dctp='', dcdt='', dcxm='', dg='', dgdt='', cltx='', catp='', caut='', crsn='', srdt='', ctln='')
Bases: object
Prefix-agnostic NITF security classification block.
-
clas: str = 'U'
-
clsy: str = ''
-
code: str = ''
-
ctlh: str = ''
-
rel: str = ''
-
dctp: str = ''
-
dcdt: str = ''
-
dcxm: str = ''
-
dg: str = ''
-
dgdt: str = ''
-
cltx: str = ''
-
catp: str = ''
-
caut: str = ''
-
crsn: str = ''
-
srdt: str = ''
-
ctln: str = ''
TGTIDAdapter
-
class aws.osml.io.jbp.utils.TGTIDAdapter
Bases: object
Converts between 17-character NITF TGTID strings and structured TGTID objects.
-
static parse(tgtid)
Parse a 17-char TGTID string into components.
Raises ValueError if length is not 17.
- Return type:
TGTID
-
static format(tgtid)
Format a TGTID into a 17-char string.
Concatenates be_number (10), osuffix (5), country (2).
- Return type:
str
TGTID
-
class aws.osml.io.jbp.utils.TGTID(be_number, osuffix, country)
Bases: object
Parsed NITF target identifier.
-
be_number: str
-
osuffix: str
-
country: str
LocationAdapter
-
class aws.osml.io.jbp.utils.LocationAdapter
Bases: object
Converts between 10-character NITF RRRRRCCCCC location strings and (row, col) tuples.
-
static parse(loc)
Parse a 10-char RRRRRCCCCC string into (row, column).
Raises ValueError if length is not 10 or contains non-numeric chars.
- Return type:
Tuple[int, int]
-
static format(row, col)
Format (row, column) into a 10-char RRRRRCCCCC string.
Zero-pads both values to 5 digits.
- Return type:
str