Skip to main content

CopcStreamingReader

Struct CopcStreamingReader 

Source
pub struct CopcStreamingReader<S: ByteSource> { /* private fields */ }
Expand description

Async streaming COPC reader.

open() reads the LAS header, VLRs, and root hierarchy page. Deeper hierarchy pages and point chunks are loaded on demand.

Implementations§

Source§

impl<S: ByteSource> CopcStreamingReader<S>

Source

pub async fn open(source: S) -> Result<Self, CopcError>

Open a COPC file.

Source

pub fn header(&self) -> &CopcHeader

The parsed COPC file header.

Source

pub fn copc_info(&self) -> &CopcInfo

Shortcut for header().copc_info().

Source

pub fn evlr_offset(&self) -> u64

File offset where EVLRs start.

Source

pub fn evlr_count(&self) -> u32

Number of EVLRs in the file.

Source

pub fn source(&self) -> &S

The underlying byte source.

Source

pub fn get(&self, key: &VoxelKey) -> Option<&HierarchyEntry>

Look up a hierarchy entry by voxel key.

Source

pub fn entries(&self) -> impl Iterator<Item = (&VoxelKey, &HierarchyEntry)>

Iterate all loaded hierarchy entries.

Source

pub fn children(&self, key: &VoxelKey) -> Vec<&HierarchyEntry>

Return loaded child entries for a given node.

Only returns children that are already in the hierarchy cache. If deeper hierarchy pages haven’t been loaded yet, this may return fewer children than actually exist in the file.

Source

pub fn node_count(&self) -> usize

Number of loaded hierarchy entries.

Source

pub fn has_pending_pages(&self) -> bool

Whether there are hierarchy pages that haven’t been loaded yet.

Source

pub async fn load_pending_pages(&mut self) -> Result<(), CopcError>

Load the next batch of pending hierarchy pages.

Source

pub async fn load_hierarchy_for_bounds( &mut self, bounds: &Aabb, ) -> Result<(), CopcError>

Load only hierarchy pages whose subtree intersects bounds.

Pages outside the region are left pending for future calls. Much cheaper than load_all_hierarchy when querying a small area.

Source

pub async fn load_hierarchy_for_bounds_to_level( &mut self, bounds: &Aabb, max_level: i32, ) -> Result<(), CopcError>

Load hierarchy pages intersecting bounds, down to max_level.

Pages deeper than max_level are left pending even if they overlap the bounds. Combine with CopcInfo::level_for_resolution to load only the detail you need:

let level = reader.copc_info().level_for_resolution(0.5);
reader.load_hierarchy_for_bounds_to_level(&camera_box, level).await?;
Source

pub async fn load_all_hierarchy(&mut self) -> Result<(), CopcError>

Load all remaining hierarchy pages.

Source

pub async fn fetch_chunk( &self, key: &VoxelKey, ) -> Result<DecompressedChunk, CopcError>

Fetch and decompress a single point chunk.

Source

pub async fn fetch_chunk_with_source( &self, source: &impl ByteSource, key: &VoxelKey, ) -> Result<DecompressedChunk, CopcError>

Fetch and decompress a point chunk using an external byte source.

This is useful when the reader is behind a lock and you want to extract the metadata under the lock, then do the async fetch without holding it.

Source

pub fn read_points( &self, chunk: &DecompressedChunk, ) -> Result<Vec<Point>, CopcError>

Parse all points from a decompressed chunk.

Source

pub fn read_points_range( &self, chunk: &DecompressedChunk, range: Range<u32>, ) -> Result<Vec<Point>, CopcError>

Parse a sub-range of points from a decompressed chunk.

Only the points in range are parsed — bytes outside the range are skipped. Pair with NodeTemporalEntry::estimate_point_range from the copc-temporal crate to read only the points that fall within a time window.

Source

pub fn read_points_in_bounds( &self, chunk: &DecompressedChunk, bounds: &Aabb, ) -> Result<Vec<Point>, CopcError>

Parse all points from a chunk, keeping only those inside bounds.

Source

pub fn read_points_range_in_bounds( &self, chunk: &DecompressedChunk, range: Range<u32>, bounds: &Aabb, ) -> Result<Vec<Point>, CopcError>

Parse a sub-range of points, keeping only those inside bounds.

Combines temporal range estimation with spatial filtering: first only the points in range are decompressed, then points outside bounds are discarded.

Source

pub async fn query_points( &mut self, bounds: &Aabb, ) -> Result<Vec<Point>, CopcError>

Load hierarchy and return all points inside bounds.

This is the simplest way to query a spatial region. It loads the hierarchy pages that overlap bounds, fetches and decompresses matching chunks, and returns only the points inside the bounding box.

let points = reader.query_points(&my_query_box).await?;
Source

pub async fn query_points_to_level( &mut self, bounds: &Aabb, max_level: i32, ) -> Result<Vec<Point>, CopcError>

Load hierarchy to max_level and return all points inside bounds.

Like query_points but limits the octree depth. Use with CopcInfo::level_for_resolution for LOD control:

let level = reader.copc_info().level_for_resolution(0.5);
let points = reader.query_points_to_level(&visible_box, level).await?;

Auto Trait Implementations§

§

impl<S> Freeze for CopcStreamingReader<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for CopcStreamingReader<S>
where S: RefUnwindSafe,

§

impl<S> Send for CopcStreamingReader<S>
where S: Send,

§

impl<S> Sync for CopcStreamingReader<S>
where S: Sync,

§

impl<S> Unpin for CopcStreamingReader<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for CopcStreamingReader<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for CopcStreamingReader<S>
where S: UnwindSafe,

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