Skip to main content

surtgis_core/
lib.rs

1//! # SurtGis Core
2//!
3//! Core types, traits and I/O for the SurtGis geospatial library.
4//!
5//! This crate provides:
6//! - `Raster<T>`: Generic raster grid type
7//! - `GeoTransform`: Affine transformation for georeferencing
8//! - `CRS`: Coordinate Reference System handling
9//! - Algorithm traits for consistent API
10//! - I/O for common geospatial formats
11
12pub mod crs;
13pub mod error;
14pub mod io;
15pub mod mosaic;
16pub mod raster;
17pub mod resample;
18pub mod streaming;
19pub mod vector;
20
21pub use crs::CRS;
22pub use error::{Error, Result};
23pub use mosaic::{MosaicOptions, mosaic};
24pub use raster::{GeoTransform, Raster, RasterElement};
25pub use resample::{ResampleMethod, resample_to_grid};
26pub use streaming::{StripProcessor, WindowAlgorithm};
27
28/// Prelude for convenient imports
29pub mod prelude {
30    pub use crate::Algorithm;
31    pub use crate::crs::CRS;
32    pub use crate::error::{Error, Result};
33    pub use crate::raster::{GeoTransform, Raster, RasterElement};
34}
35
36/// Core trait for all algorithms in SurtGis.
37///
38/// Algorithms are pure functions that transform input data according to parameters.
39pub trait Algorithm {
40    /// Input type for the algorithm
41    type Input;
42    /// Output type for the algorithm
43    type Output;
44    /// Parameters controlling algorithm behavior
45    type Params: Default;
46    /// Error type for algorithm execution
47    type Error: std::error::Error;
48
49    /// Returns the algorithm name
50    fn name(&self) -> &'static str;
51
52    /// Returns a description of what the algorithm does
53    fn description(&self) -> &'static str;
54
55    /// Execute the algorithm
56    fn execute(
57        &self,
58        input: Self::Input,
59        params: Self::Params,
60    ) -> std::result::Result<Self::Output, Self::Error>;
61
62    /// Execute with default parameters
63    fn execute_default(
64        &self,
65        input: Self::Input,
66    ) -> std::result::Result<Self::Output, Self::Error> {
67        self.execute(input, Self::Params::default())
68    }
69}
70
71/// Marker trait for algorithms that can be parallelized
72pub trait ParallelAlgorithm: Algorithm {
73    /// Execute in parallel using available cores
74    fn execute_parallel(
75        &self,
76        input: Self::Input,
77        params: Self::Params,
78    ) -> std::result::Result<Self::Output, Self::Error>;
79}