pub struct PointDataBuilder { /* private fields */ }Expand description
Builder for PointData.
Construct via PointDataBuilder::new, configure the point format and
coordinate transforms, then finalize with one of:
build— an emptyPointData, sized to zero points.build_from_bytes— wrap an existingVec<u8>of tightly-packed records for the configured format.build_from_points— encode ownedPoints against the configured format and transforms.
Configure by either passing a Header wholesale with
for_header — the typical case when you already
have a Reader or Writer in hand —
or by setting the pieces individually with
with_format and
with_transforms.
The format and transforms are cached for per-point accessor dispatch and must match the file these records will be filled from or were produced from.
§Example
use las::{PointDataBuilder, Reader};
let reader = Reader::from_path("tests/data/autzen.las").unwrap();
let points = PointDataBuilder::new().for_header(reader.header()).build();
assert!(points.is_empty());Implementations§
Source§impl PointDataBuilder
impl PointDataBuilder
Sourcepub fn with_format(self, format: Format) -> Self
pub fn with_format(self, format: Format) -> Self
Sets the point format the resulting PointData will be decoded against.
Sourcepub fn with_transforms(self, transforms: Vector<Transform>) -> Self
pub fn with_transforms(self, transforms: Vector<Transform>) -> Self
Sets the coordinate transforms applied when decoding x/y/z.
Sourcepub fn for_header(self, header: &Header) -> Self
pub fn for_header(self, header: &Header) -> Self
Configures format and transforms from a Header.
Shorthand for chaining
with_format(*header.point_format()) and
with_transforms(*header.transforms()).
Works equally well with reader.header(), writer.header(), or a
Header built manually via Builder.
§Example
use las::{PointDataBuilder, Reader};
let reader = Reader::from_path("tests/data/autzen.las").unwrap();
let points = PointDataBuilder::new().for_header(reader.header()).build();
assert!(points.is_empty());Sourcepub fn build_from_bytes(self, bytes: Vec<u8>) -> Result<PointData>
pub fn build_from_bytes(self, bytes: Vec<u8>) -> Result<PointData>
Builds a PointData by taking ownership of an existing byte buffer.
The byte buffer must be a sequence of tightly-packed point records for
the configured format — i.e. its length must be a multiple of the
format’s record length. Useful for callers that already have a
decompressed Vec<u8> in hand (custom decompressor, memory-mapped
region, received over the wire).
§Errors
Returns Error::InvalidCloudByteLength
if bytes.len() is not a multiple of the format’s record length.
§Example
use las::{point::Format, PointDataBuilder, Transform, Vector};
let format = Format::new(0).unwrap();
let transforms: Vector<Transform> = Default::default();
let record_len = format.len() as usize;
let bytes = vec![0u8; record_len * 5];
let points = PointDataBuilder::new()
.with_format(format)
.with_transforms(transforms)
.build_from_bytes(bytes)
.unwrap();
assert_eq!(points.len(), 5);Sourcepub fn build_from_points<I>(self, points: I) -> Result<PointData>where
I: IntoIterator<Item = Point>,
pub fn build_from_points<I>(self, points: I) -> Result<PointData>where
I: IntoIterator<Item = Point>,
Builds a PointData by encoding owned Points against the
configured format and transforms.
This is the bulk-write counterpart to
Reader::read_points: if you’re
constructing points programmatically (not reading a file), hand them
here and pass the result to
Writer::write_points.
§Errors
Returns an error if any point’s optional field set doesn’t match the target format, or if a coordinate transform overflows.
Trait Implementations§
Source§impl Clone for PointDataBuilder
impl Clone for PointDataBuilder
Source§fn clone(&self) -> PointDataBuilder
fn clone(&self) -> PointDataBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PointDataBuilder
impl Debug for PointDataBuilder
Source§impl Default for PointDataBuilder
impl Default for PointDataBuilder
Source§fn default() -> PointDataBuilder
fn default() -> PointDataBuilder
Auto Trait Implementations§
impl Freeze for PointDataBuilder
impl RefUnwindSafe for PointDataBuilder
impl Send for PointDataBuilder
impl Sync for PointDataBuilder
impl Unpin for PointDataBuilder
impl UnsafeUnpin for PointDataBuilder
impl UnwindSafe for PointDataBuilder
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