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

1mod tables;
2mod tables2;
3mod tables3;
4mod templates;
5
6use crate::{parsers::Reader, readers::Grib2Sections};
7pub use tables::*;
8pub use tables2::*;
9pub use tables3::*;
10pub use templates::*;
11
12///  Product Definition Section
13///
14/// [Read more...](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect4.shtml)
15#[derive(Debug, Clone, PartialEq)]
16pub struct Grib2ProductDefinitionSection {
17    /// Number of GRIB section
18    pub section_number: u8,
19    /// Length of GRIB section
20    pub length: u32,
21    /// Number of coordinate values after template
22    pub coordinate_values: u16,
23    /// Product definition template number [Table 4.0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-0.shtml)
24    pub product_definition_template: Grib2Table4_0,
25    /// Product definition
26    pub values: Grib2ProductDefinition,
27}
28impl Grib2ProductDefinitionSection {
29    /// Create a new instance of Grib2ProductDefinitionSection
30    ///
31    /// ## Parameters
32    /// - `reader`: The section to parse
33    /// - `sections`: The other sections that have been parsed (1-3)
34    ///
35    /// ## Returns
36    /// Parsed Product Definition Information
37    pub fn new<T: Reader>(reader: &T, sections: &Grib2Sections) -> Self {
38        let product_definition_template = reader.uint16_be(Some(7));
39
40        Self {
41            section_number: reader.uint8(Some(4)),
42            length: reader.uint32_be(Some(0)),
43            coordinate_values: reader.uint16_be(Some(5)),
44            product_definition_template: product_definition_template.into(),
45            values: Grib2ProductDefinition::new(product_definition_template, reader, sections),
46        }
47    }
48}