Struct las::file::File [] [src]

pub struct File<T: Read + Seek> {
    pub header: Header,
    pub vlrs: Vec<Vlr>,
    // some fields omitted
}

A lasfile.

This is generic so that a lasfile can be created from many types of readers. Seek is required at this time so we can jump to the beginning of the point records. Fully streaming lasfiles could be supported in the future.

Fields

header: Header vlrs: Vec<Vlr>

Methods

impl<T: Read + Seek> File<T>
[src]

fn new(reader: T) -> LasResult<File<T>>

Initializes a lasfile from a generic reader.

Examples

let mut file = std::fs::File::open("data/1.2_0.las").unwrap();
let lasfile = las::File::new(file);

fn read_next_point(&mut self) -> LasResult<Point>

Reads the next point from the file.

We don't do any checking of the reader state or the number of point records as specified in the Header, since those can often be bunk. We just blindly read from the reader and return Err if there's any sort of read problem.

It's a bit ask forgiveness instead of permission, but so far I don't see any big problems with that.

Examples

Use read_next_point to fetch the next point from the underlying reader.

let point = lasfile.read_next_point().unwrap();
assert_eq!(47069244, point.x);

If we're out of points, read_next_point returns an error.

assert!(lasfile.read_next_point().is_err());

fn point_iter(&mut self) -> LasResult<FileIter<T>>

Returns an interator over the file's points.

Examples

let points = file.point_iter().unwrap().collect::<Vec<las::Point>>();
assert_eq!(1, points.len());

fn write_to<W: Write>(&mut self, writer: &mut W, version_string: &str, point_data_format_id: u8) -> LasResult<()>

Writes the las data to a writer.

Examples

let mut file = las::File::open("data/1.2_0.las").unwrap();
let mut data: Vec<u8> = Vec::new();
let mut cursor = Cursor::new(data);
file.write_to(&mut cursor, "1.2", 0);

impl File<File>
[src]

fn open(filename: &str) -> LasResult<File<File>>

Open a lasfile.

Examples

let lasfile = las::File::open("data/1.2_0.las");