gistools/readers/grib2/sections/_5/
mod.rs

1mod tables;
2mod templates;
3
4use crate::parsers::Reader;
5pub use tables::*;
6pub use templates::*;
7
8// import { getGrib2Template5 } from './templates.js';
9// import { grib2LookupTable50 } from './tables.js';
10
11// import type { Reader } from '../../../index.js';
12
13// export * from './templates.js';
14
15// /** The output of `parseGrib2Section5` */
16// export type Grib2DataRepresentationSection = ReturnType<typeof parseGrib2Section5>;
17
18///  Data Representation Section
19///
20/// [Read more...](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect5.shtml)
21#[derive(Debug, Clone, PartialEq)]
22pub struct Grib2DataRepresentationSection {
23    /// Number of GRIB section
24    pub section_number: u8,
25    /// Length of GRIB section
26    pub length: u32,
27    /// Number of data points where one or more values are specified in Section 7 when a bit map is present, total number of data points when a bit map is absent.
28    pub number_of_data_points: u32,
29    /// Data representation template number (See [Table 5.0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-0.shtml))
30    pub data_representation_template: Grib2Table5_0,
31    /// Data representation built using a template
32    pub data_representation: Grib2Template5,
33}
34impl Grib2DataRepresentationSection {
35    /// Create a new instance of Grib2DataRepresentationSection
36    ///
37    /// ## Parameters
38    /// - `section`: The raw section data to parse
39    ///
40    /// ## Returns
41    /// Parsed Data Representation Information
42    pub fn new<T: Reader>(section: &T) -> Self {
43        Grib2DataRepresentationSection {
44            section_number: section.uint8(Some(4)),
45            length: section.uint32_be(Some(0)),
46            number_of_data_points: section.uint32_be(Some(5)),
47            data_representation_template: (section.uint16_be(Some(9))).into(),
48            data_representation: Grib2Template5::new(section, section.uint16_be(Some(9)) as u8),
49        }
50    }
51}