Skip to main content

CopcReader

Struct CopcReader 

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

A parsed COPC file ready for spatial queries.

§Example

use oxigdal_copc::copc_reader::CopcReader;
use oxigdal_copc::point::BoundingBox3D;

let data = std::fs::read("my_file.copc.laz").expect("read file");
let reader = CopcReader::from_bytes(&data).expect("parse COPC");
let bbox = BoundingBox3D::new(0.0, 0.0, 0.0, 100.0, 100.0, 50.0).expect("valid bbox");
let points = reader.query_points_in_bbox(&bbox).expect("query");

Implementations§

Source§

impl CopcReader

Source

pub fn from_bytes(data: &[u8]) -> Result<Self, CopcError>

Parse a COPC file from an in-memory byte slice.

Parses the LAS header, walks the VLR chain to extract the COPC info and hierarchy VLR, and stores the raw data for later queries.

§Errors

Returns CopcError when the data is not a valid COPC file (bad magic, missing VLRs, truncated data, etc.).

Source

pub fn header(&self) -> &LasHeader

Return a reference to the parsed LAS header.

Source

pub fn copc_info(&self) -> &CopcInfo

Return a reference to the parsed COPC info.

Source

pub fn vlrs(&self) -> &[Vlr]

Return a reference to the VLR list.

Source

pub fn octree_bounds(&self) -> BoundingBox3D

Return the full octree bounding box as a BoundingBox3D.

Source

pub fn query_points_in_bbox( &self, bbox: &BoundingBox3D, ) -> Result<Vec<Point3D>, CopcError>

Query all points whose positions fall within the given 3D bounding box.

Traverses the COPC hierarchy to find octree nodes that intersect bbox, reads the corresponding point data chunks and deserializes them, then filters to only those points geometrically inside bbox.

§Errors

Returns CopcError on hierarchy traversal or point deserialization errors.

Source

pub fn all_points(&self) -> Result<Vec<Point3D>, CopcError>

Query all points within the entire file (no spatial filter).

Walks the hierarchy and reads all point data chunks.

§Errors

Returns CopcError on hierarchy or point deserialization errors.

Source

pub fn count_intersecting_chunks( &self, bbox: &BoundingBox3D, ) -> Result<Vec<HierarchyEntry>, CopcError>

Return the total number of hierarchy entries (data chunks) that intersect the given bounding box, without reading point data.

Useful for estimating query cost before fetching actual points.

Source

pub fn entries_at_depth( &self, depth: i32, ) -> Result<Vec<HierarchyEntry>, CopcError>

Return all hierarchy entries at a given depth level.

This traverses the full hierarchy and filters by depth.

Trait Implementations§

Source§

impl Debug for CopcReader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.