Skip to main content

Header

Struct 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 copc_info_vlr(&self) -> Option<CopcInfoVlr>

Retrieves the COPC Info VLR (Variable Length Record) if available.

This function searches through the available VLRs to find the COPC Info VLR.

§Returns
  • Some(CopcInfolr) - If the COPC Info VLR exists and can be successfully parsed
  • None - If the COPC Info VLR doesn’t exist or if there was an error parsing it.
Source§

impl Header

Source

pub fn copc_hierarchy_evlr(&self) -> Option<CopcHierarchyVlr>

Retrieves the COPC hierarchy EVLR (Extended Variable Length Record) if available.

This function searches through the available EVLRs to find the COPC hierarchy EVLR, and then attempts to parse it using the COPC info VLR.

§Returns
  • Some(CopcHierarchyVlr) - If the COPC hierarchy EVLR exists and can be successfully parsed
  • None - If the COPC info VLR doesn’t exist, the COPC hierarchy EVLR doesn’t exist, or if there was an error parsing the COPC hierarchy EVLRto parse it using the CopcInfoVlr.
Source§

impl Header

Source

pub fn add_laz_vlr(&mut self) -> Result<()>

Adds a new laszip vlr to this header.

Ensures that there’s only one laszip vlr, as well.

§Examples
use las::Header;

let mut header = Header::default();
#[cfg(feature = "laz")]
header.add_laz_vlr().unwrap();
Source

pub fn laz_vlr(&self) -> Result<LazVlr>

Returns header’s LazVlr, or Error::LasZipVlrNotFound if none is found.

§Examples
use las::Header;

let mut header = Header::default();

#[cfg(feature = "laz")]
{
assert!(header.laz_vlr().is_err());
header.add_laz_vlr();
assert!(header.laz_vlr().is_ok());
}
Source§

impl Header

Source

pub fn remove_crs_vlrs(&mut self)

Removes all CRS (E)VLRs from the header

§Examples
use las::Reader;
let reader = Reader::from_path("tests/data/autzen.las").unwrap();
let mut header = reader.header().clone();
header.remove_crs_vlrs();
assert!(!header.has_crs_vlrs());
Source

pub fn set_wkt_crs(&mut self, wkt_crs_bytes: Vec<u8>) -> Result<()>

Adds a WKT CRS VLR to the header

Returns Err if the header already contains CRS (E)VLRs or the Las version is below 1.4.

The WKT bytes can be obtained from a horizontal EPSG code by using the crs-definitions crate

§Examples
use las::{Builder, Version};
let mut builder = Builder::from(Version::new(1, 4));
let mut header = builder.into_header().unwrap();
let wkt_bytes = b"PROJCS[\"WGS 84\"]".to_vec();
header.set_wkt_crs(wkt_bytes).unwrap();
assert!(header.has_crs_vlrs());
Source

pub fn get_wkt_crs_bytes(&self) -> Option<&[u8]>

Gets the WKT-CRS-data if the WKT-CRS (E)VLR exists

§Examples
use las::Reader;
let reader = Reader::from_path("tests/data/autzen.las").unwrap();
let header = reader.header();
if let Some(wkt_bytes) = header.get_wkt_crs_bytes() {
    println!("WKT CRS data: {} bytes", wkt_bytes.len());
}
Source

pub fn get_geotiff_crs(&self) -> Result<Option<GeoTiffCrs>>

Gets all the GeoTiff CRS data if the GeoTiff-CRS (E)VLR(s) exist

§Examples
use las::Reader;
let reader = Reader::from_path("tests/data/autzen.las").unwrap();
let header = reader.header();
match header.get_geotiff_crs() {
    Ok(Some(geotiff_crs)) => {
        println!("Found {} GeoTIFF key entries", geotiff_crs.entries.len());
    }
    Ok(None) => println!("No GeoTIFF CRS data"),
    Err(e) => eprintln!("Error reading GeoTIFF CRS: {}", e),
}
Source§

impl Header

Source

pub fn new<R: Read + Seek>(read: R) -> Result<Self>

Reads all header, vlr and evlr data from file and returns the complete 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 has_crs_vlrs(&self) -> bool

Returns whether or not this header has any CRS (E)VLRs

§Examples
use las::Header;
let header = Header::default();
assert!(!header.has_crs_vlrs());
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();
Source

pub fn write_to<W: Write>(&self, write: W) -> Result<()>

Writes this header to a Write.

§Examples
use std::io::Cursor;
use las::Header;

let header = Header::default();
let cursor = Cursor::new(Vec::new());
header.write_to(cursor).unwrap();

Trait Implementations§

Source§

impl Clone for Header

Source§

fn clone(&self) -> Header

Returns a duplicate 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

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

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 StructuralPartialEq for Header

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

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

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

Source§

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>,

Source§

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>,

Source§

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.