[][src]Enum las::raw::point::Flags

pub enum Flags {
    TwoByte(u8u8),
    ThreeByte(u8u8u8),
}

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(u8u8)

Two byte flags, used for point formats zero through five.

ThreeByte(u8u8u8)

Three byte flags, used for point formats six through ten.

Implementations

impl Flags[src]

pub fn return_number(&self) -> u8[src]

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

pub fn number_of_returns(&self) -> u8[src]

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

pub fn scan_direction(&self) -> ScanDirection[src]

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

pub fn is_synthetic(&self) -> bool[src]

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

pub fn is_key_point(&self) -> bool[src]

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

pub fn is_withheld(&self) -> bool[src]

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

pub fn is_overlap(&self) -> bool[src]

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

pub fn scanner_channel(&self) -> u8[src]

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

pub fn is_edge_of_flight_line(&self) -> bool[src]

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

pub fn to_two_bytes(&self) -> Result<(u8, u8)>[src]

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

pub fn to_classification(&self) -> Result<Classification>[src]

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

pub fn clear_overlap_class(&mut self)[src]

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

impl Clone for Flags[src]

impl Copy for Flags[src]

impl Debug for Flags[src]

impl Default for Flags[src]

impl From<Flags> for (u8, u8, u8)[src]

impl PartialEq<Flags> for Flags[src]

Auto Trait Implementations

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
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.