Packing 3: Grid-point data second-order packing

Octets Key Type Content
12-13 N1 octet number at which first-order packed data begin
14 Extended flags (see Code table 11)
15-16 N2 octet number at which second-order packed data begin
17-18 P1 number of first-order packed values
19-20 P2 number of second-order packed values
21 Reserved
22-(xx-1) Width(s) in bits of second-order packed values; each width is contained in 1 octet
xx-(N1-1) Secondary bit-map, at least P2 bits long, padded to a whole number of octets with binary 0
N1-(N2-1) P1 first-order packed values, padded to a whole number of octets with binary 0
N2-... P2 second-order packed values
Notes:

( 1) The binary data shall consist of P1 first-order packed values, of width given by the contents of octet 11, followed by P2 second-order packed values; there shall be one second-order packed value for each point of the defined grid, as modified by application of the bit-map in Section 3 Bit-map section, if present.

( 2) The width of the second-order packed values shall be indicated by the values of W2j:
     (a) If bit 8 of the extended flags (Code table 11) is 0, all second-order packed values will have the same width, indicated by a single value W21;
     (b) If bit 8 of the extended flags (Code table 11) is 1, P1 values of the widths of second-order packed values (W2j, j = 1..P1) will be given.

( 3) The secondary bit-map, starting at octet xx, shall define with corresponding 1 bits the location where the use of the first-order packed values begins with reference to the defined grid (as modified by the bitmap, Section 3, if present); the first point of the grid, as modified by the bit-map in Section 3 if present, will always be present, and a corresponding 1 shall be set in the first bit of the secondary bit-map.

( 6) If the number of bits W2j, for the appropriate subset, is zero, no values for that subset are represented; i.e. the actual value for that subset is a constant given by R + (Xi × 2E). This is a form of run-length encoding in which a string of identical values is represented by one value; the replication count for that value is, implicitly, in the secondary bit-map.

( 5) The original represented data at any point shall be obtained by scanning the points in the order defined by the grid description, as modified by the (optional) bit-map section; each first-order packed value shall remain defined until the point at which the use of a subsequent first-order packed value begins, as defined by the secondary bit-map; the unpacked value shall be obtained by applying the reference value, the binary and the decimal scales to the sum of the first- and second-order values for each point, by the following formula:

Y x 10D = R + (Xi + Xj) × 2E

where Xi is the appropriate first-order packed value;
Xj is the appropriate second-order packed value.

( 4) Where bit 7 of the extended flags (Code table 11) is 0, the secondary bit-map shall be omitted; and implied secondary bit-map shall be inferred such that a 1 bit is set for the first point of each row (or column) of the defined grid (row by row packing).