gistools/readers/grib2/sections/_6/
tables.rs

1#![cfg_attr(feature = "nightly", coverage(off))]
2
3/// # GRIB2 - TABLE 6.0 - BIT MAP INDICATOR
4///
5/// **Details**:
6/// - **Section**: 6
7/// - **Octet**: 6
8/// - **Revised**: 05/17/2005
9///
10/// **Value Ranges**:
11/// - `1-253`: A bit map pre-determined by the originating/generating center applies to this product and is not specified in this section.
12///
13/// **Special Value**:
14/// - `255`: A bit map does not apply to this product.
15///
16/// ## Description
17/// This table defines the bit map indicators used in GRIB2 files,
18/// specifying how bit maps apply to products based on various definitions.
19///
20/// ## Notes
21/// - Revised 05/17/2005
22#[repr(u8)]
23#[allow(missing_docs)]
24#[derive(Debug, Clone, Copy, PartialEq, Eq)]
25pub enum Grib2Table6_0 {
26    BitmapSpecifiedInThisSection = 0,
27    BitmapPredeterminedByCenter(u8), // For values 1-253
28    BitmapPreviouslyDefined = 254,
29    BitmapDoesNotApply = 255,
30}
31impl From<u8> for Grib2Table6_0 {
32    fn from(val: u8) -> Self {
33        match val {
34            0 => Self::BitmapSpecifiedInThisSection,
35            1..=253 => Self::BitmapPredeterminedByCenter(val),
36            254 => Self::BitmapPreviouslyDefined,
37            255 => Self::BitmapDoesNotApply,
38        }
39    }
40}
41impl core::fmt::Display for Grib2Table6_0 {
42    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
43        let desc = match self {
44            Self::BitmapSpecifiedInThisSection => {
45                "A bit map applies to this product and is specified in this section."
46            }
47            Self::BitmapPredeterminedByCenter(v) => {
48                return write!(
49                    f,
50                    "A bit map pre-determined by the originating/generating center applies to \
51                     this product and is not specified in this section. (Value: {v})"
52                );
53            }
54            Self::BitmapPreviouslyDefined => {
55                "A bit map previously defined in the same GRIB2 message applies to this product."
56            }
57            Self::BitmapDoesNotApply => "A bit map does not apply to this product.",
58        };
59        f.write_str(desc)
60    }
61}