Struct las::header::Header

source ·
pub struct Header { /* private fields */ }
Expand description

Metadata describing the layout, source, and interpretation of the points.

Headers include all las metadata, including regular and extended variable length records and any file padding (e.g. extra bytes after the header).

Implementations§

source§

impl Header

source

pub fn from_raw(raw_header: Header) -> Result<Header>

Creates a new header from a raw header.

§Examples
use las::{raw, Header};
let raw_header = raw::Header::default();
let header = Header::from_raw(raw_header).unwrap();
source

pub fn clear(&mut self)

Clears this header’s point counts and bounds.

§Examples
use las::{Header, Point, Bounds};
let mut header = Header::default();
header.add_point(&Point { return_number: 1, ..Default::default() });
assert_eq!(1, header.number_of_points());
assert_eq!(1, header.number_of_points_by_return(1).unwrap());
header.clear();
assert_eq!(0, header.number_of_points());
assert_eq!(None, header.number_of_points_by_return(1));
assert_eq!(Bounds::default(), header.bounds());
source

pub fn add_point(&mut self, point: &Point)

Adds a point to this header, incrementing the point counts and growing the bounds.

§Examples
use las::Header;
let mut header = Header::default();
header.add_point(&Default::default());
assert_eq!(1, header.number_of_points());
source

pub fn file_source_id(&self) -> u16

Returns this header’s file source id.

For airborne data, this is often the flight line number.

§Examples
use las::Header;
assert_eq!(0, Header::default().file_source_id());
source

pub fn gps_time_type(&self) -> GpsTimeType

Returns the gps time type.

This affects what the gps time values on points means. GpsTimeType::Week means that the time values are seconds from the start of the week. GpsTimeType::Standard means that the time values are standard GPS time (satellite gps time) minus 10e9.

§Examples
use las::{GpsTimeType, Header};
assert_eq!(GpsTimeType::Week, Header::default().gps_time_type());
source

pub fn has_synthetic_return_numbers(&self) -> bool

Returns true if the return numbers on the point data records have been synthetically generated.

Only supported in later las versions.

§Examples
use las::Header;
assert!(!Header::default().has_synthetic_return_numbers());
source

pub fn has_wkt_crs(&self) -> bool

Returns true if the coordinate reference system is Well Known Text (WKT).

Only supported in las 1.4.

§Examples
use las::Header;
assert!(!Header::default().has_wkt_crs());
source

pub fn guid(&self) -> Uuid

Returns this header’s guid.

§Examples
use las::Header;
let guid = Header::default().guid();
source

pub fn version(&self) -> Version

Returns this header’s version.

§Examples
use las::{Header, Version};
assert_eq!(Version::new(1, 2), Header::default().version());
source

pub fn system_identifier(&self) -> &str

Returns this header’s system identifier.

Describes the source of the data, whether it is a sensor or a processing operation.

§Examples
use las::Header;
println!("{}", Header::default().system_identifier());
source

pub fn generating_software(&self) -> &str

Returns this header’s generating software.

§Examples
use las::Header;
assert!(Header::default().generating_software().starts_with("las-rs"));
source

pub fn date(&self) -> Option<NaiveDate>

Returns this header’s file creation date.

Can be None, which is against spec but happens with files in the wild.

§Examples
use las::Header;
let date = Header::default().date().unwrap();
source

pub fn padding(&self) -> &Vec<u8>

Returns this header’s padding.

These are bytes that are after the header but before the vlr. Not recommended to use.

§Examples
use las::Header;
assert!(Header::default().padding().is_empty());
source

pub fn point_format(&self) -> &Format

Returns this header’s point format.

Point formats are used to describe the attributes and extra bytes of each point.

§Examples
use las::Header;
let header = Header::default();
assert_eq!(0, header.point_format().to_u8().unwrap());
source

pub fn transforms(&self) -> &Vector<Transform>

Returns this header’s transforms.

The transforms are the scales and offsets used to convert floating point numbers to i16. Las data stores point coordinates as i16s internally.

§Examples
use las::Header;
let header = Header::default();
let transforms = header.transforms();
assert_eq!(0.001, transforms.x.scale);
source

pub fn bounds(&self) -> Bounds

Returns the bounds of this header.

The bounds describe the min and max values in each dimension.

§Examples
use las::Header;
let bounds = Header::default().bounds();
source

pub fn number_of_points(&self) -> u64

Returns this header’s number of points.

§Examples
use las::Header;
let header = Header::default();
assert_eq!(0, header.number_of_points());
source

pub fn number_of_points_by_return(&self, n: u8) -> Option<u64>

Returns this header’s number of points for a given return number.

Note that return numbers are 1-indexed.

§Examples
use las::Header;
let header = Header::default();
assert_eq!(None, header.number_of_points_by_return(1));
source

pub fn vlr_padding(&self) -> &Vec<u8>

Returns a reference to this header’s vlr padding.

These are bytes after the vlrs but before the points. Again, not recommended for use.

§Examples
use las::Header;
assert!(Header::default().vlr_padding().is_empty());
source

pub fn point_padding(&self) -> &Vec<u8>

Returns a reference to this header’s point padding.

These are the bytes after the points but before eof/any evlrs. Not recommended.

§Examples
use las::Header;
assert!(Header::default().point_padding().is_empty());
source

pub fn vlrs(&self) -> &Vec<Vlr>

Returns a reference to this header’s vlrs.

§Examples
use las::{Vlr, Builder};
let mut builder = Builder::default();
builder.vlrs.push(Vlr::default());
let header = builder.into_header().unwrap();
assert_eq!(1, header.vlrs().len());
source

pub fn evlrs(&self) -> &Vec<Vlr>

Returns a reference to header’s extended variable length records.

§Examples
use las::{Vlr, Builder};
let mut builder = Builder::from((1, 4));
builder.evlrs.push(Vlr::default());
let header = builder.into_header().unwrap();
assert_eq!(1, header.evlrs().len());
source

pub fn all_vlrs(&self) -> Vlrs<'_>

Returns an iterator over all this header’s vlrs, both extended and regular.

§Examples
use las::{Vlr, Builder};
let mut builder = Builder::from((1, 4));
builder.vlrs.push(Vlr::default());
builder.evlrs.push(Vlr::default());
let header = builder.into_header().unwrap();
assert_eq!(2, header.all_vlrs().count());
source

pub fn into_raw(self) -> Result<Header>

Converts this header into a raw header.

§Examples
use las::Header;
let raw_header = Header::default().into_raw().unwrap();

Trait Implementations§

source§

impl Clone for Header

source§

fn clone(&self) -> Header

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 Header

source§

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

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

impl Default for Header

source§

fn default() -> Header

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

impl From<Header> for Builder

source§

fn from(header: Header) -> Builder

Converts to this type from the input type.
source§

impl<V: Into<Version>> From<V> for Header

source§

fn from(version: V) -> Header

Converts to this type from the input type.
source§

impl PartialEq for Header

source§

fn eq(&self, other: &Header) -> 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 StructuralPartialEq for Header

Auto Trait Implementations§

§

impl Freeze for Header

§

impl RefUnwindSafe for Header

§

impl Send for Header

§

impl Sync for Header

§

impl Unpin for Header

§

impl UnwindSafe for Header

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.