pub struct Reader { /* private fields */ }Expand description
Reads LAS data.
Implementations§
Source§impl Reader
impl Reader
Sourcepub fn new<R: Read + Seek + Send + Sync + 'static>(read: R) -> Result<Reader>
pub fn new<R: Read + Seek + Send + Sync + 'static>(read: R) -> Result<Reader>
Creates a new reader with default options.
This does not wrap the Read in a BufRead, so if you’re concerned
about performance you should do that wrapping yourself (or use
from_path).
§Examples
use std::io::BufReader;
use std::fs::File;
let file = File::open("tests/data/autzen.las").unwrap();
let reader = Reader::new(BufReader::new(file)).unwrap();Sourcepub fn with_options<R: Read + Seek + Send + Sync + 'static>(
read: R,
options: ReaderOptions,
) -> Result<Reader>
pub fn with_options<R: Read + Seek + Send + Sync + 'static>( read: R, options: ReaderOptions, ) -> Result<Reader>
Creates a new reader with custom options.
This does not wrap the Read in a BufRead, so if you’re concerned
about performance you should do that wrapping yourself (or use
from_path).
§Examples
use std::io::BufReader;
use std::fs::File;
let file = File::open("tests/data/autzen.las").unwrap();
let reader = Reader::with_options(BufReader::new(file), ReaderOptions::default()).unwrap();Sourcepub fn from_path<P: AsRef<Path>>(path: P) -> Result<Reader>
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Reader>
Creates a new reader from a path.
The underlying File is wrapped in a BufReader for performance reasons.
§Examples
let reader = Reader::from_path("tests/data/autzen.las").unwrap();Sourcepub fn header(&self) -> &Header
pub fn header(&self) -> &Header
Returns a reference to this reader’s header.
§Examples
use las::Reader;
let reader = Reader::from_path("tests/data/autzen.las").unwrap();
let header = reader.header();Sourcepub fn read_point(&mut self) -> Result<Option<Point>>
pub fn read_point(&mut self) -> Result<Option<Point>>
Reads a point.
§Examples
let mut reader = Reader::from_path("tests/data/autzen.las").unwrap();
let point = reader.read_point().unwrap().unwrap();Sourcepub fn read_points(&mut self, n: u64) -> Result<Vec<Point>>
pub fn read_points(&mut self, n: u64) -> Result<Vec<Point>>
Reads n points into a vector.
§Examples
let mut reader = Reader::from_path("tests/data/autzen.las").unwrap();
let points = reader.read_points(10).unwrap();
assert_eq!(points.len(), 10);Sourcepub fn read_points_into(
&mut self,
n: u64,
points: &mut Vec<Point>,
) -> Result<u64>
pub fn read_points_into( &mut self, n: u64, points: &mut Vec<Point>, ) -> Result<u64>
Reads n points into a provided vector, returning the number of points read.
§Examples
let mut reader = Reader::from_path("tests/data/autzen.las").unwrap();
let mut points = Vec::new();
let count = reader.read_points_into(10, &mut points).unwrap();Sourcepub fn read(&mut self) -> Option<Result<Point>>
👎Deprecated since 0.9.0: Use read_point() instead, which returns a Result<Option<Point>>
pub fn read(&mut self) -> Option<Result<Point>>
Reads a point.
§Examples
let mut reader = Reader::from_path("tests/data/autzen.las").unwrap();
let point = reader.read().unwrap().unwrap();Sourcepub fn read_n(&mut self, n: u64) -> Result<Vec<Point>>
👎Deprecated since 0.9.0: Use read_points() instead
pub fn read_n(&mut self, n: u64) -> Result<Vec<Point>>
Reads n points into a vector.
Sourcepub fn read_n_into(&mut self, n: u64, points: &mut Vec<Point>) -> Result<u64>
👎Deprecated since 0.9.0: Use read_points_into() instead
pub fn read_n_into(&mut self, n: u64, points: &mut Vec<Point>) -> Result<u64>
Reads n points into the vec
Sourcepub fn read_all_points_into(&mut self, points: &mut Vec<Point>) -> Result<u64>
pub fn read_all_points_into(&mut self, points: &mut Vec<Point>) -> Result<u64>
Reads all points into a vector.
§Examples
let mut reader = Reader::from_path("tests/data/autzen.las").unwrap();
let mut points = Vec::new();
let count = reader.read_all_points(&mut points).unwrap();
assert_eq!(points.len(), count.try_into().unwrap());Sourcepub fn read_all_points(&mut self, points: &mut Vec<Point>) -> Result<u64>
👎Deprecated since 0.9.0: Use read_all_points_into() instead
pub fn read_all_points(&mut self, points: &mut Vec<Point>) -> Result<u64>
Reads all points into a vector.
Sourcepub fn seek(&mut self, position: u64) -> Result<()>
pub fn seek(&mut self, position: u64) -> Result<()>
Seeks to the given point number, zero-indexed.
Note that seeking on compressed (LAZ) data can be expensive as the reader will have to seek to the closest chunk start and decompress all points up until the point seeked to.
§Examples
use las::Reader;
let mut reader = Reader::from_path("tests/data/autzen.las").unwrap();
reader.seek(1).unwrap(); // <- seeks to the second point
let the_second_point = reader.read().unwrap().unwrap();Sourcepub fn points(&mut self) -> PointIterator<'_> ⓘ
pub fn points(&mut self) -> PointIterator<'_> ⓘ
Returns an iterator over this reader’s points.
§Examples
let mut reader = Reader::from_path("tests/data/autzen.las").unwrap();
let points = reader.points().collect::<Result<Vec<_>, _>>().unwrap();Trait Implementations§
Source§impl Read for Reader
impl Read for Reader
Source§fn header(&self) -> &Header
👎Deprecated since 0.9.0: This interface has been refactored so that importing Read is no longer required
fn header(&self) -> &Header
Read is no longer requiredReturns a reference to this reader’s header.
Source§fn read(&mut self) -> Option<Result<Point>>
👎Deprecated since 0.9.0: This interface has been refactored so that importing Read is no longer required
fn read(&mut self) -> Option<Result<Point>>
Read is no longer requiredReads a point.
Source§fn seek(&mut self, position: u64) -> Result<()>
👎Deprecated since 0.9.0: This interface has been refactored so that importing Read is no longer required
fn seek(&mut self, position: u64) -> Result<()>
Read is no longer requiredSeeks to the given point number, zero-indexed.
Source§fn points(&mut self) -> PointIterator<'_> ⓘ
👎Deprecated since 0.9.0: This interface has been refactored so that importing Read is no longer required
fn points(&mut self) -> PointIterator<'_> ⓘ
Read is no longer requiredReturns an iterator over this reader’s points.
Source§fn read_n(&mut self, n: u64) -> Result<Vec<Point>>
fn read_n(&mut self, n: u64) -> Result<Vec<Point>>
Read is no longer requiredAuto Trait Implementations§
impl Freeze for Reader
impl !RefUnwindSafe for Reader
impl !Send for Reader
impl !Sync for Reader
impl Unpin for Reader
impl !UnwindSafe for Reader
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> 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