1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
use crate::def::grib2::template::param_set;
impl param_set::ScanningMode {
/// Returns `true` if points of the first row or column scan in the `+i`
/// (`+x`) direction.
///
/// # Examples
///
/// ```
/// assert_eq!(
/// grib::def::grib2::template::param_set::ScanningMode(0b00000000).scans_positively_for_i(),
/// true
/// );
/// ```
pub fn scans_positively_for_i(&self) -> bool {
self.0 & 0b10000000 == 0
}
/// Returns `true` if points of the first row or column scan in the `+j`
/// (`+y`) direction.
///
/// # Examples
///
/// ```
/// assert_eq!(
/// grib::def::grib2::template::param_set::ScanningMode(0b00000000).scans_positively_for_j(),
/// false
/// );
/// ```
pub fn scans_positively_for_j(&self) -> bool {
self.0 & 0b01000000 != 0
}
/// Returns `true` if adjacent points in `i` (`x`) direction are
/// consecutive.
///
/// # Examples
///
/// ```
/// assert_eq!(
/// grib::def::grib2::template::param_set::ScanningMode(0b00000000).is_consecutive_for_i(),
/// true
/// );
/// ```
pub fn is_consecutive_for_i(&self) -> bool {
self.0 & 0b00100000 == 0
}
/// Returns `true` if adjacent rows scans in the opposite direction.
///
/// # Examples
///
/// ```
/// assert_eq!(
/// grib::def::grib2::template::param_set::ScanningMode(0b00000000).scans_alternating_rows(),
/// false
/// );
/// ```
pub fn scans_alternating_rows(&self) -> bool {
self.0 & 0b00010000 != 0
}
pub(crate) fn has_unsupported_flags(&self) -> bool {
self.0 & 0b00001111 != 0
}
}
impl param_set::ProjectionCentreFlag {
/// Returns `true` if North Pole is on the projection plane. Otherwise (i.e.
/// if South Pole is on), returns `false`.
///
/// # Examples
///
/// ```
/// assert_eq!(
/// grib::def::grib2::template::param_set::ProjectionCentreFlag(0b00000000)
/// .contains_north_pole_on_projection_plane(),
/// true
/// );
/// ```
pub fn contains_north_pole_on_projection_plane(&self) -> bool {
self.0 & 0b10000000 == 0
}
/// Returns `true` if projection is bipolar and symmetric. Otherwise (i.e.
/// if only one projection centre is used), returns `false`.
///
/// # Examples
///
/// ```
/// assert_eq!(
/// grib::def::grib2::template::param_set::ProjectionCentreFlag(0b00000000).is_bipolar(),
/// false
/// );
/// ```
pub fn is_bipolar(&self) -> bool {
self.0 & 0b01000000 != 0
}
#[allow(dead_code)]
pub(crate) fn has_unsupported_flags(&self) -> bool {
self.0 & 0b00111111 != 0
}
}