Enum las::raw::point::Flags

source ·
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

source

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());
source

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());
source

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());
source

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());
source

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());
source

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());
source

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());
source

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());
source

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());
source

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());
source

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());
source

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);

Trait Implementations§

source§

impl Clone for Flags

source§

fn clone(&self) -> Flags

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Flags

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Flags

source§

fn default() -> Flags

Returns the “default value” for a type. Read more
source§

impl From<Flags> for (u8, u8, u8)

source§

fn from(flags: Flags) -> (u8, u8, u8)

Converts to this type from the input type.
source§

impl PartialEq for Flags

source§

fn eq(&self, other: &Flags) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Flags

Auto Trait Implementations§

§

impl Freeze for Flags

§

impl RefUnwindSafe for Flags

§

impl Send for Flags

§

impl Sync for Flags

§

impl Unpin for Flags

§

impl UnwindSafe for Flags

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.