pub enum Flags {
TwoByte(u8, u8),
ThreeByte(u8, u8, u8),
}
Expand description
These flags hold information about point classification, return number, and more.
In point formats zero through five, two bytes are used to hold all of the information. Point formats six through ten use an extra byte, to enable more return numbers, more classifications, and more.
This structure captures those alternatives and provides an API to convert between the two types. Two-byte flags can always be transformed to three-byte flags, but going from three-bytes to two-bytes can fail if information would be lost.
use las::raw::point::Flags;
let two_byte = Flags::TwoByte(0b00001001, 1);
assert_eq!(Flags::ThreeByte(0b00010001, 0, 1), two_byte.into());
// Two-byte flags can't handle this large of return numbers.
let three_byte = Flags::ThreeByte(0b10001000, 0, 1);
assert!(three_byte.to_two_bytes().is_err());
Variants§
TwoByte(u8, u8)
Two byte flags, used for point formats zero through five.
ThreeByte(u8, u8, u8)
Three byte flags, used for point formats six through ten.
Implementations§
source§impl Flags
impl Flags
sourcepub fn return_number(&self) -> u8
pub fn return_number(&self) -> u8
Returns the return number.
§Examples
use las::raw::point::Flags;
assert_eq!(1, Flags::TwoByte(1, 0).return_number());
assert_eq!(1, Flags::ThreeByte(1, 0, 0).return_number());
sourcepub fn number_of_returns(&self) -> u8
pub fn number_of_returns(&self) -> u8
Returns the number of returns.
§Examples
use las::raw::point::Flags;
assert_eq!(1, Flags::TwoByte(8, 0).number_of_returns());
assert_eq!(1, Flags::ThreeByte(16, 0, 0).number_of_returns());
sourcepub fn scan_direction(&self) -> ScanDirection
pub fn scan_direction(&self) -> ScanDirection
Returns the scan direction from these flags.
§Examples
use las::raw::point::Flags;
use las::point::ScanDirection;
assert_eq!(ScanDirection::LeftToRight, Flags::TwoByte(0b01000000, 0).scan_direction());
assert_eq!(ScanDirection::LeftToRight, Flags::ThreeByte(0, 0b01000000, 0).scan_direction());
sourcepub fn is_synthetic(&self) -> bool
pub fn is_synthetic(&self) -> bool
Returns whether this point is synthetic.
§Examples
use las::raw::point::Flags;
assert!(Flags::TwoByte(0, 0b00100000).is_synthetic());
assert!(Flags::ThreeByte(0, 1, 0).is_synthetic());
sourcepub fn is_key_point(&self) -> bool
pub fn is_key_point(&self) -> bool
Returns whether this point is a key point.
§Examples
use las::raw::point::Flags;
assert!(Flags::TwoByte(0, 0b01000000).is_key_point());
assert!(Flags::ThreeByte(0, 2, 0).is_key_point());
sourcepub fn is_withheld(&self) -> bool
pub fn is_withheld(&self) -> bool
Returns whether this point is withheld.
§Examples
use las::raw::point::Flags;
assert!(Flags::TwoByte(0, 0b10000000).is_withheld());
assert!(Flags::ThreeByte(0, 4, 0).is_withheld());
sourcepub fn is_overlap(&self) -> bool
pub fn is_overlap(&self) -> bool
Returns whether this point is overlap.
§Examples
use las::raw::point::Flags;
assert!(Flags::TwoByte(0, 12).is_overlap());
assert!(Flags::ThreeByte(0, 8, 0).is_overlap());
sourcepub fn scanner_channel(&self) -> u8
pub fn scanner_channel(&self) -> u8
Returns the scanner channel.
§Examples
use las::raw::point::Flags;
assert_eq!(0, Flags::TwoByte(0, 0).scanner_channel());
assert_eq!(3, Flags::ThreeByte(0, 0b00110000, 0).scanner_channel());
sourcepub fn is_edge_of_flight_line(&self) -> bool
pub fn is_edge_of_flight_line(&self) -> bool
Is this point the edge of a flight line?
§Examples
use las::raw::point::Flags;
assert!(Flags::TwoByte(128, 0).is_edge_of_flight_line());
assert!(Flags::ThreeByte(0, 128, 0).is_edge_of_flight_line());
sourcepub fn to_two_bytes(&self) -> Result<(u8, u8)>
pub fn to_two_bytes(&self) -> Result<(u8, u8)>
Converts these flags into two bytes.
If these are two byte flags, no problem. However, if these are three byte flags, information could be lost — in that case, we error.
§Example
use las::raw::point::Flags;
assert_eq!((1, 2), Flags::TwoByte(1, 2).to_two_bytes().unwrap());
assert!(Flags::ThreeByte(0b00001000, 0, 0).to_two_bytes().is_err());
sourcepub fn to_classification(&self) -> Result<Classification>
pub fn to_classification(&self) -> Result<Classification>
Converts these flags to a classification.
Throws an error of the classifiction is 12 (overlap points), because we don’t have an
overlap points class in this library. See the las::point::Classification
documentation
for more information.
§Examples
use las::raw::point::Flags;
use las::point::Classification;
assert_eq!(Classification::Ground, Flags::TwoByte(0, 2).to_classification().unwrap());
assert_eq!(Classification::Ground, Flags::ThreeByte(0, 0, 2).to_classification().unwrap());
assert!(Flags::TwoByte(0, 12).to_classification().is_err());
assert!(Flags::ThreeByte(0, 0, 12).to_classification().is_err());
sourcepub fn clear_overlap_class(&mut self)
pub fn clear_overlap_class(&mut self)
Clears any overlap classes in these flags.
§Examples
use las::raw::point::Flags;
let mut flags = Flags::TwoByte(0, 12);
flags.clear_overlap_class();
assert_eq!(Flags::TwoByte(0, 1), flags);
let mut flags = Flags::ThreeByte(0, 0, 12);
flags.clear_overlap_class();
assert_eq!(Flags::ThreeByte(0, 8, 1), flags);