Flags

Enum 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 duplicate of the value. Read more
1.0.0§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0§

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

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§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.