1use thiserror::Error;
4
5pub type Result<T> = core::result::Result<T, TerrainError>;
7
8#[derive(Debug, Error)]
10pub enum TerrainError {
11 #[error("Invalid DEM dimensions: width={width}, height={height}")]
13 InvalidDimensions {
14 width: usize,
16 height: usize,
18 },
19
20 #[error("Invalid cell size: {size}. Cell size must be positive.")]
22 InvalidCellSize {
23 size: f64,
25 },
26
27 #[error("Invalid azimuth: {azimuth}. Azimuth must be between 0 and 360 degrees.")]
29 InvalidAzimuth {
30 azimuth: f64,
32 },
33
34 #[error("Invalid altitude: {altitude}. Altitude must be between 0 and 90 degrees.")]
36 InvalidAltitude {
37 altitude: f64,
39 },
40
41 #[error("Invalid observer position: ({x}, {y}). Position must be within DEM bounds.")]
43 InvalidObserverPosition {
44 x: usize,
46 y: usize,
48 },
49
50 #[error("Invalid observer height: {height}. Height must be non-negative.")]
52 InvalidObserverHeight {
53 height: f64,
55 },
56
57 #[error("Invalid target height: {height}. Height must be non-negative.")]
59 InvalidTargetHeight {
60 height: f64,
62 },
63
64 #[error("Invalid radius: {radius}. Radius must be positive.")]
66 InvalidRadius {
67 radius: f64,
69 },
70
71 #[error("Invalid threshold: {threshold}. {message}")]
73 InvalidThreshold {
74 threshold: f64,
76 message: String,
78 },
79
80 #[error("Missing or invalid NoData handling: {message}")]
82 InvalidNoData {
83 message: String,
85 },
86
87 #[error("Flow direction error: {message}")]
89 FlowDirectionError {
90 message: String,
92 },
93
94 #[error("Watershed delineation error: {message}")]
96 WatershedError {
97 message: String,
99 },
100
101 #[error("Viewshed computation error: {message}")]
103 ViewshedError {
104 message: String,
106 },
107
108 #[error("Computation error: {message}")]
110 ComputationError {
111 message: String,
113 },
114
115 #[error("Insufficient memory for operation: {message}")]
117 InsufficientMemory {
118 message: String,
120 },
121
122 #[error("Core error: {0}")]
124 CoreError(#[from] oxigdal_core::error::OxiGdalError),
125}