s2-tools
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
66 lines • 4.44 kB
TypeScript
import type { Grib2Sections } from '..';
import type { Reader } from '../../..';
/**
* # Data Template 7.2 - Grid Point Data - Complex Packing
*
* ## Contents
* - **6-xx**: NG group reference values (X1 in the decoding formula), each of which is encoded using
* the number of bits specified in octet 20 of data representation template 5.0. Bits set to zero shall
* be appended as necessary to ensure this sequence of numbers ends on an octet boundary
* - **[xx+1]-yy**: NG group widths, each of which is encoded using the number of bits specified in
* octet 37 of data representation template 5.2. Bits set to zero shall be appended as necessary to
* ensure this sequence of numbers ends on an octet boundary
* - **[yy+1]-zz**: NG scaled group lengths, each of which is encoded using the number of bits
* specified in octet 47 of data representation template 5.2. Bits set to zero shall be appended as
* necessary to ensure this sequence of numbers ends on an octet boundary (see Note 5)
* - **[zz+1]-nn**: Packed vaules (X2 in the decoding formula), where each value is a deviation from
* its respective group reference value
*
* ## Notes
* - (1) Group descriptors mentioned above may not be physically present; if associated field width is 0.
* - (2) Group lengths have no meaning for row by row packing; for consistency, associated field width
* should then be encoded as 0. So no specific test for row case is mandatory at decoding software level
* to handle endcoding/decoding of group descriptors.
* - (3) Scaled group lengths, if present, are encoded for each group. But the true last group length
* (unscaled) should be taken from data representation template.
* - (4) For groups with a constant value, associated field width is 0, and no incremental data are
* physically present.
* - (5) The essence of the complex packing method is to subdivide a field of values into NG groups,
* where the values in each group have similar sizes. In this procedure, it is necessary to retain
* enough information to recover the group lengths upon decoding. The NG group lengths for any given
* field can be described by Ln = ref + Kn x len_inc, n = 1, NG, where ref is given by octets 38 - 41
* and len_inc by octet 42. The NG values of K (the scaled group lengths) are stored in the data section,
* each with the number of bits specified by octet 47. Since the last group is a special case which
* may not be able to be specified by this relationship, the length of the last group is stored in
* octets 43-46.
*
* # Data Template 7.3 - Grid Point Data - Complex Packing and Spatial Differencing
*
* ## Contents
* - **6-ww**: First value(s) of original (undifferenced) scale values, followed by the overall
* minimum of the differences. The number of values stored is 1 greater than the oerder of
* differentiation, and the field width is described at octet 49 of data representation template
* 5.3 (see Note 1)
* - **[ww+1]-xx**: NG group difference values, (X1 in the decoding formula), each of which is
* encoded using the number of bits specified in octet 20 of data representation template 5.0. Bits
* set to zero shall be appended where necessary to ensure this sequence of numbers ends on an octet
* boundary
* - **[xx+1]-nn**: Packed vaules (X2 in the decoding formula), where each value is a deviation from
* its respective group reference value
*
* ## Notes
* - (1) Referring to the notation in Note 1 of data representation template 5.3, at order 1, the
* values stored in octet 6-ww are g1 and gmin. At order 2, the values stored are h1, h2 and hmin.
* - (2) Extra descriptors related to spatial differencing are added before the splitting descriptors,
* to refect the separation between the two approaches. It enables to share software parts between cases
* with and without spatial differencing.
* - (3) The position of overall minimum after initial data values is a choice that enables less
* software management.
* - (4) Overall minimum will be negative in most cases. First bit should indicate the sign:0 if
* positive, 1 if negative.
* @param reader - Binary data reader positioned at the start of the data section.
* @param sections - A collection of all sections in the GRIB file.
* @returns An array of decoded values.
*/
export declare function complexUnpacking(reader: Reader, sections: Grib2Sections): number[];
//# sourceMappingURL=complexUnpacking.d.ts.map