Skip to main content

Reader

Struct Reader 

Source
pub struct Reader { /* private fields */ }
Expand description

Reads LAS data.

Implementations§

Source§

impl Reader

Source

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();
Source

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();
Source

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();
Source

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();
Source

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();
Source

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);
Source

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();
Source

pub fn read(&mut self) -> Option<Result<Point>>

👎Deprecated since 0.9.0: Use read_point() instead, which returns a Result<Option<Point>>

Reads a point.

§Examples
let mut reader = Reader::from_path("tests/data/autzen.las").unwrap();
let point = reader.read().unwrap().unwrap();
Source

pub fn read_n(&mut self, n: u64) -> Result<Vec<Point>>

👎Deprecated since 0.9.0: Use read_points() instead

Reads n points into a vector.

Source

pub fn read_n_into(&mut self, n: u64, points: &mut Vec<Point>) -> Result<u64>

👎Deprecated since 0.9.0: Use read_points_into() instead

Reads n points into the vec

Source

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());
Source

pub fn read_all_points(&mut self, points: &mut Vec<Point>) -> Result<u64>

👎Deprecated since 0.9.0: Use read_all_points_into() instead

Reads all points into a vector.

Source

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();
Source

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

Source§

fn header(&self) -> &Header

👎Deprecated since 0.9.0: This interface has been refactored so that importing Read is no longer required

Returns 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

Reads 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

Seeks 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

Returns an iterator over this reader’s points.

Source§

fn read_n(&mut self, n: u64) -> Result<Vec<Point>>

👎Deprecated since 0.9.0: This interface has been refactored so that importing Read is no longer required
Reads n points.
Source§

fn read_n_into(&mut self, n: u64, points: &mut Vec<Point>) -> Result<u64>

👎Deprecated since 0.9.0: This interface has been refactored so that importing Read is no longer required
Reads n points into the vec
Source§

fn read_all_points(&mut self, points: &mut Vec<Point>) -> Result<u64>

👎Deprecated since 0.9.0: This interface has been refactored so that importing Read is no longer required
Reads all points left into the vec

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