copc_rs/
error.rs

1use thiserror::Error;
2
3/// crate specific Result type
4pub type Result<T> = std::result::Result<T, Error>;
5
6/// crate specific Error enum
7#[derive(Error, Debug)]
8pub enum Error {
9    /// When trying to add points to a writer that already been closed
10    #[error("This writer has already been closed")]
11    ClosedWriter,
12
13    /// When trying to close an empty copc file
14    #[error("There are no points added to this file")]
15    EmptyCopcFile,
16
17    /// [las::Error]
18    #[error(transparent)]
19    LasError(#[from] las::Error),
20
21    /// [laz::LasZipError]
22    #[error(transparent)]
23    LasZipError(#[from] laz::LasZipError),
24
25    /// The input file-path does not end in .copc.laz
26    #[error("The extension of the file to write does not match .copc.laz")]
27    WrongCopcExtension,
28
29    /// The requested resolution is either negative or not normal
30    #[error("The requested error is not possible: {}", .0)]
31    InvalidResolution(f64),
32
33    /// [std::io::Error]
34    #[error(transparent)]
35    Io(#[from] std::io::Error),
36
37    /// The Copc Info vlr was not found, octree can not be built
38    #[error("The source to be read does not contain a COPC info vlr")]
39    CopcInfoVlrNotFound,
40
41    /// The Ept hierarchy evlr was not found, octree can not be built
42    #[error("The source to be read does not contain a EPT hierarchy vlr")]
43    EptHierarchyVlrNotFound,
44
45    /// The laszip vlr was not found, the points cannot be decompressed.
46    #[error("laszip vlr not found")]
47    LasZipVlrNotFound,
48
49    /// The provided iterator for writing points to copc did not contain any points
50    #[error("The provided iterator for writing points to copc did not contain any points")]
51    EmptyIterator,
52
53    /// Should not be possible
54    #[error("The point could not be added to any node in the octree")]
55    PointNotAddedToAnyNode,
56
57    /// If the bounds in the passed in header is invalid
58    #[error("the bounds in the passed in header is not normal: {:?}", .0)]
59    InvalidBounds(las::Bounds),
60
61    /// If a point fails to be added to the copc
62    #[error(transparent)]
63    InvalidPoint(crate::PointAddError),
64
65    /// If a copc writer is created with invalid max or min node cound bounds
66    #[error("the set min or max sizes for point in node is invalid")]
67    InvalidNodeSize,
68
69    /// [las_crs::CrsError]
70    #[error(transparent)]
71    InvalidCrs(#[from] las_crs::CrsError),
72
73    /// Unsupported epsg
74    #[error("the found epsg-code is not defined in the crs-definitions library")]
75    InvalidEPSGCode(u16),
76}
77
78/// crate specific Error enum related to adding points to the writer
79#[derive(Error, Debug)]
80pub enum PointAddError {
81    /// A point in the iterator passed to [write] did not
82    /// match the format specified by the `header` passed to [new]
83    ///
84    /// [new]: crate::writer::CopcWriter::new
85    /// [write]: crate::writer::CopcWriter::write
86    #[error("The point attributes of a point in the iterator don't match the header: {:?}", .0)]
87    PointAttributesDoNotMatch(las::point::Format),
88
89    /// A point in the iterator passed to [write] was not
90    /// inside the bounds of the header passed to [new]
91    ///
92    /// [new]: crate::writer::CopcWriter::new
93    /// [write]: crate::writer::CopcWriter::write
94    #[error("A point in the iterator was not inside the bounds of the header")]
95    PointNotInBounds,
96}