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
impl Header
Sourcepub fn copc_info_vlr(&self) -> Option<CopcInfoVlr>
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 parsedNone- If the COPC Info VLR doesn’t exist or if there was an error parsing it.
Source§impl Header
impl Header
Sourcepub fn copc_hierarchy_evlr(&self) -> Option<CopcHierarchyVlr>
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 parsedNone- 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
impl Header
Sourcepub fn add_laz_vlr(&mut self) -> Result<()>
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§impl Header
impl Header
Sourcepub fn remove_crs_vlrs(&mut self)
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());Sourcepub fn set_wkt_crs(&mut self, wkt_crs_bytes: Vec<u8>) -> Result<()>
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());Sourcepub fn get_wkt_crs_bytes(&self) -> Option<&[u8]>
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());
}Sourcepub fn get_geotiff_crs(&self) -> Result<Option<GeoTiffCrs>>
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
impl Header
Sourcepub fn new<R: Read + Seek>(read: R) -> Result<Self>
pub fn new<R: Read + Seek>(read: R) -> Result<Self>
Reads all header, vlr and evlr data from file and returns the complete header.
Sourcepub fn from_raw(raw_header: Header) -> Result<Header>
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();Sourcepub fn clear(&mut self)
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());Sourcepub fn add_point(&mut self, point: &Point)
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());Sourcepub fn file_source_id(&self) -> u16
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());Sourcepub fn gps_time_type(&self) -> GpsTimeType
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());Sourcepub fn has_synthetic_return_numbers(&self) -> bool
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());Sourcepub fn has_wkt_crs(&self) -> bool
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());Sourcepub fn version(&self) -> Version
pub fn version(&self) -> Version
Returns this header’s version.
§Examples
use las::{Header, Version};
assert_eq!(Version::new(1, 2), Header::default().version());Sourcepub fn system_identifier(&self) -> &str
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());Sourcepub fn generating_software(&self) -> &str
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"));Sourcepub fn date(&self) -> Option<NaiveDate>
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();Sourcepub fn padding(&self) -> &Vec<u8> ⓘ
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());Sourcepub fn point_format(&self) -> &Format
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());Sourcepub fn transforms(&self) -> &Vector<Transform>
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);Sourcepub fn bounds(&self) -> Bounds
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();Sourcepub fn number_of_points(&self) -> u64
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());Sourcepub fn number_of_points_by_return(&self, n: u8) -> Option<u64>
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));Sourcepub fn vlr_padding(&self) -> &Vec<u8> ⓘ
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());Sourcepub fn point_padding(&self) -> &Vec<u8> ⓘ
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());Sourcepub fn vlrs(&self) -> &Vec<Vlr>
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());Sourcepub fn evlrs(&self) -> &Vec<Vlr>
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());Sourcepub fn all_vlrs(&self) -> Vlrs<'_> ⓘ
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());Sourcepub fn has_crs_vlrs(&self) -> bool
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());Trait Implementations§
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 UnsafeUnpin for Header
impl UnwindSafe for Header
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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