|
| 1 | +use geo::AnyDenseArray; |
1 | 2 | use pyo3::prelude::*; |
2 | | -use std::path::PathBuf; |
3 | 3 |
|
4 | | -mod pyio; |
5 | | -mod pyraster; |
6 | | -pub(crate) mod pyutils; |
| 4 | +mod io; |
| 5 | +mod nodata; |
| 6 | +mod raster; |
| 7 | +mod rasterargument; |
| 8 | +mod rastermetadata; |
| 9 | +pub(crate) mod utils; |
7 | 10 |
|
8 | | -#[pyfunction] |
9 | | -fn version() -> String { |
10 | | - env!("CARGO_PKG_VERSION").to_string() |
11 | | -} |
| 11 | +pub use nodata::Nodata; |
| 12 | +pub use raster::Raster; |
| 13 | +pub use rastermetadata::RasterMetadata; |
| 14 | +pub type PythonDenseArray = AnyDenseArray<RasterMetadata>; |
12 | 15 |
|
13 | | -/// A Python module implemented in Rust. |
| 16 | +/// The main geodynamix module |
| 17 | +/// Typically imported as `import geodynamix as gdx` |
14 | 18 | #[pymodule] |
15 | 19 | fn geodynamix(m: &Bound<'_, PyModule>) -> PyResult<()> { |
16 | 20 | pyo3_log::init(); |
17 | 21 |
|
18 | 22 | #[cfg(feature = "static_build")] |
19 | 23 | configure_proj_data()?; |
20 | 24 |
|
21 | | - m.add_class::<pyraster::RasterMetadata>()?; |
22 | | - m.add_class::<pyraster::Raster>()?; |
23 | | - m.add_function(wrap_pyfunction!(version, m)?)?; |
24 | | - m.add_function(wrap_pyfunction!(pyio::read, m)?)?; |
25 | | - m.add_function(wrap_pyfunction!(pyio::read_as, m)?)?; |
26 | | - m.add_function(wrap_pyfunction!(pyio::write, m)?)?; |
| 25 | + m.add_class::<RasterMetadata>()?; |
| 26 | + m.add_class::<raster::Raster>()?; |
| 27 | + m.add_function(wrap_pyfunction!(io::read, m)?)?; |
| 28 | + m.add_function(wrap_pyfunction!(io::read_as, m)?)?; |
| 29 | + m.add_function(wrap_pyfunction!(io::write, m)?)?; |
| 30 | + m.add_function(wrap_pyfunction!(raster::raster_equal, m)?)?; |
| 31 | + m.add("nodata", Nodata::default())?; |
27 | 32 | Ok(()) |
28 | 33 | } |
29 | 34 |
|
30 | 35 | #[cfg(feature = "static_build")] |
31 | 36 | fn configure_proj_data() -> PyResult<()> { |
| 37 | + use std::path::PathBuf; |
| 38 | + |
32 | 39 | // If we are using a static build, we are responsible for shipping the proj.db |
33 | 40 | // So make sure gdal can find it |
34 | 41 | let python_exe = std::env::current_exe()?; |
|
0 commit comments