aws.osml.gdal.nitf_des_accessor module

class aws.osml.gdal.nitf_des_accessor.NITFDESAccessor(gdal_xml_des_metadata: List[str])[source]

Bases: object

This class is a facade that makes it easier to work with the XML formatted Data Extension Segments parsed by GDAL.

get_segments_by_name(des_name: str) List[Element][source]

This method searches through the GDAL xml:DES metadata and returns the XML structure for any segments matching the provided name. This is equivalent to retrieving all segments that have a matching DESID.

Parameters:

des_name – the DESID (e.g. XML_DATA_CONTENT)

Returns:

the list of segments, multiple items in the list will occur if the NITF has multiple matching segments

static extract_des_header(des_element: Element) str[source]

This function encodes the existing values from the Data Extension Segment header into a fields appropriately sized for including in a NITF image. The DESDATA field is not copied because the assumption is that the data itself will be updated. The DE and DESID fields are not included either because GDAL adds them itself when writing the segment.

Parameters:

des_element – the Data Extension Segment containing current segment

Returns:

the encoded DESVER through DESSHF fields.

static extract_desdata_xml(des_element: Element) str | None[source]

This function attempts to extract a block of XML from the field element named DESDATA. Versions of GDAL before 3.9 returned the XML data base64 encoded as a value attribute. Versions >=3.9 are automatically expanding the xml into the text area of an <xml_content> element.

Parameters:

des_element – the root xml:DES metadata element

Returns:

the xml content if it is found and can be extracted

static parse_field_value(des_element: Element, field_name: str, type_conversion: Callable[[str], T]) T[source]

This is method will find a named “field” element in the children of a TRE Element and return the “value” attribute of that named field. A type conversion function can be provided to convert the attribute value to a specific Python type (e.g. int, float, or str)

Parameters:
  • des_element – the root element to find the named field in

  • field_name – the name of the field element

  • type_conversion – the desired type of the output, must support construction from a string

Returns:

the value converted to the requested type