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>
impl<S: ByteSource> CopcStreamingReader<S>
Sourcepub fn header(&self) -> &CopcHeader
pub fn header(&self) -> &CopcHeader
The parsed COPC file header.
Sourcepub fn evlr_offset(&self) -> u64
pub fn evlr_offset(&self) -> u64
File offset where EVLRs start.
Sourcepub fn evlr_count(&self) -> u32
pub fn evlr_count(&self) -> u32
Number of EVLRs in the file.
Sourcepub fn get(&self, key: &VoxelKey) -> Option<&HierarchyEntry>
pub fn get(&self, key: &VoxelKey) -> Option<&HierarchyEntry>
Look up a hierarchy entry by voxel key.
Sourcepub fn entries(&self) -> impl Iterator<Item = (&VoxelKey, &HierarchyEntry)>
pub fn entries(&self) -> impl Iterator<Item = (&VoxelKey, &HierarchyEntry)>
Iterate all loaded hierarchy entries.
Sourcepub fn children(&self, key: &VoxelKey) -> Vec<&HierarchyEntry>
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.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of loaded hierarchy entries.
Sourcepub fn has_pending_pages(&self) -> bool
pub fn has_pending_pages(&self) -> bool
Whether there are hierarchy pages that haven’t been loaded yet.
Sourcepub fn pending_page_keys(&self) -> impl Iterator<Item = VoxelKey> + '_
pub fn pending_page_keys(&self) -> impl Iterator<Item = VoxelKey> + '_
Iterate the VoxelKeys anchoring the currently-pending hierarchy
pages. See HierarchyCache::pending_page_keys.
Sourcepub async fn load_pending_pages(&mut self) -> Result<(), CopcError>
pub async fn load_pending_pages(&mut self) -> Result<(), CopcError>
Load the next batch of pending hierarchy pages.
Sourcepub async fn load_hierarchy_for_bounds(
&mut self,
bounds: &Aabb,
) -> Result<(), CopcError>
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.
Sourcepub async fn load_hierarchy_for_bounds_to_level(
&mut self,
bounds: &Aabb,
max_level: i32,
) -> Result<(), CopcError>
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?;Sourcepub async fn load_all_hierarchy(&mut self) -> Result<(), CopcError>
pub async fn load_all_hierarchy(&mut self) -> Result<(), CopcError>
Load all remaining hierarchy pages.
Sourcepub async fn fetch_chunk(
&self,
key: &VoxelKey,
fields: Fields,
) -> Result<Chunk, CopcError>
pub async fn fetch_chunk( &self, key: &VoxelKey, fields: Fields, ) -> Result<Chunk, CopcError>
Fetch and decompress a single chunk, decoding only the fields in
fields.
On LAS 1.4 layered formats (6/7/8 — the formats COPC mandates) this
is a real CPU saving proportional to the number of skipped layers.
Fields listed in Fields map directly to LAZ layer-level
DecompressionSelection and the omitted layers are not arithmetically
decoded at all.
Sourcepub async fn fetch_chunk_with_source(
&self,
source: &impl ByteSource,
key: &VoxelKey,
fields: Fields,
) -> Result<Chunk, CopcError>
pub async fn fetch_chunk_with_source( &self, source: &impl ByteSource, key: &VoxelKey, fields: Fields, ) -> Result<Chunk, 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.
Sourcepub async fn fetch_chunks(
&self,
keys: &[VoxelKey],
fields: Fields,
) -> Result<Vec<Chunk>, CopcError>
pub async fn fetch_chunks( &self, keys: &[VoxelKey], fields: Fields, ) -> Result<Vec<Chunk>, CopcError>
Fetch and decompress multiple chunks in one batched I/O call.
Uses ByteSource::read_ranges to coalesce the fetches — HTTP
sources that override read_ranges with parallel requests or
range merging will issue far fewer round-trips than calling
fetch_chunk in a loop.
All keys must already be present in the loaded hierarchy; call
one of the load_hierarchy_* methods first.
Sourcepub fn visible_keys(
&self,
bounds: &Aabb,
max_level: Option<i32>,
) -> Vec<VoxelKey>
pub fn visible_keys( &self, bounds: &Aabb, max_level: Option<i32>, ) -> Vec<VoxelKey>
Keys in the currently-loaded hierarchy whose subtree intersects
bounds and whose level is at most max_level (if provided).
Use this to drive your own fetch loop — for parallelism, cancellation, prioritization, or streaming:
reader.load_hierarchy_for_bounds_to_level(&bbox, lod).await?;
for key in reader.visible_keys(&bbox, Some(lod)) {
let chunk = reader.fetch_chunk(&key, Fields::Z | Fields::RGB).await?;
// ...
}Sourcepub async fn query_chunks(
&mut self,
bounds: &Aabb,
fields: Fields,
) -> Result<Vec<Chunk>, CopcError>
pub async fn query_chunks( &mut self, bounds: &Aabb, fields: Fields, ) -> Result<Vec<Chunk>, CopcError>
Load hierarchy for bounds, fetch every intersecting chunk, and
return them.
Uses fetch_chunks to batch all chunk
fetches into a single ByteSource::read_ranges call.
Sourcepub async fn query_chunks_to_level(
&mut self,
bounds: &Aabb,
max_level: i32,
fields: Fields,
) -> Result<Vec<Chunk>, CopcError>
pub async fn query_chunks_to_level( &mut self, bounds: &Aabb, max_level: i32, fields: Fields, ) -> Result<Vec<Chunk>, CopcError>
Same as query_chunks but limits the octree
depth to max_level.
Sourcepub async fn fetch_points(
&self,
key: &VoxelKey,
) -> Result<Vec<Point>, CopcError>
pub async fn fetch_points( &self, key: &VoxelKey, ) -> Result<Vec<Point>, CopcError>
Fetch, decompress, and materialize every point in one chunk as
owned las::Point values.
Equivalent to fetch_chunk(key, Fields::ALL).await?.to_points()?.
Prefer fetch_chunk for performance-sensitive
code paths.
Sourcepub async fn query_points(
&mut self,
bounds: &Aabb,
) -> Result<Vec<Point>, CopcError>
pub async fn query_points( &mut self, bounds: &Aabb, ) -> Result<Vec<Point>, CopcError>
Load hierarchy for bounds, fetch all intersecting chunks, and
return the points inside bounds.
Thin wrapper over query_chunks with
Fields::ALL. Decodes everything and materializes; prefer
query_chunks when you only need a subset of fields or want to
walk points column-by-column.
Sourcepub async fn query_points_to_level(
&mut self,
bounds: &Aabb,
max_level: i32,
) -> Result<Vec<Point>, CopcError>
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?;