Struct las::point::Format[][src]

pub struct Format {
    pub has_gps_time: bool,
    pub has_color: bool,
    pub is_extended: bool,
    pub has_waveform: bool,
    pub has_nir: bool,
    pub extra_bytes: u16,
    pub is_compressed: bool,
}

Point formats are defined by the las spec.

As of las 1.4, there are eleven point formats (0-10). A new Format can be created from its code and converted back into it:

use las::point::Format;

let format_1 = Format::new(1).unwrap();
assert!(format_1.has_gps_time);
assert_eq!(1, format_1.to_u8().unwrap());

assert!(Format::new(11).is_err());

Point formats can have extra bytes, which are user-defined attributes. Extra bytes were introduced in las 1.4.

use las::point::Format;
let mut format = Format::new(0).unwrap();
format.extra_bytes = 1;
assert_eq!(21, format.len());

Certain combinations of attributes in a point format are illegal, e.g. gps time is required for all formats >= 6:

use las::point::Format;
let mut format = Format::new(6).unwrap();
format.has_gps_time = false;
assert!(format.to_u8().is_err());

Fields

has_gps_time: bool

Does this point format include gps time?

has_color: bool

Does this point format include red, green, and blue colors?

is_extended: bool

Does this point format use two bytes for its flags and scaled scan angles?

has_waveform: bool

Does this point format have waveforms?

has_nir: bool

Does this point format have near infrared data?

extra_bytes: u16

The number of extra bytes on each point.

is_compressed: bool

Is this point format compressed?

Implementations

impl Format[src]

pub fn new(n: u8) -> Result<Format>[src]

Creates a new point format from a u8.

Examples

use las::point::Format;
let format = Format::new(0).unwrap();
assert!(!format.has_gps_time);
assert!(!format.has_color);

let format = Format::new(3).unwrap();
assert!(format.has_gps_time);
assert!(format.has_color);

assert!(Format::new(11).is_err());

pub fn extend(&mut self)[src]

Converts this point format into an extended format.

"Extended" formats can contain more information per point, and must have gps time.

Examples

use las::point::Format;
let mut format = Format::default();
assert!(!format.has_gps_time);
assert!(!format.is_extended);
format.extend();
assert!(format.has_gps_time);
assert!(format.is_extended);

pub fn len(&self) -> u16[src]

Returns this point format's length.

Examples

use las::point::Format;
let mut format = Format::new(0).unwrap();
assert_eq!(20, format.len());
format.has_gps_time = true;
assert_eq!(28, format.len());

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

Converts this point format to a u8.

Can return an error if there is an invalid combination of attributes.

Examples

use las::point::Format;
let mut format = Format::default();
assert_eq!(0, format.to_u8().unwrap());
format.is_extended = true;
assert!(format.to_u8().is_err());
format.has_gps_time = true;
assert_eq!(6, format.to_u8().unwrap());

Trait Implementations

impl Clone for Format[src]

impl Copy for Format[src]

impl Debug for Format[src]

impl Default for Format[src]

impl Display for Format[src]

impl PartialEq<Format> for Format[src]

impl StructuralPartialEq for Format[src]

Auto Trait Implementations

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> ToString for T where
    T: Display + ?Sized
[src]

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.