Skip to content

Commit ee1de1d

Browse files
committed
RasterArgument implementation for flexible raster arguments
1 parent e8ee569 commit ee1de1d

File tree

15 files changed

+466
-292
lines changed

15 files changed

+466
-292
lines changed

.cargo/config.toml

Lines changed: 0 additions & 84 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ standalone
2525
target
2626
*.so
2727
python/geodynamix.data/data/share/geodynamix/proj.db
28+
.cargo/config.toml

.zed/tasks.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
{
3+
"label": "Gdx build wheel",
4+
"command": "just",
5+
"args": ["wheel_develop"],
6+
"use_new_terminal": false,
7+
"allow_concurrent_runs": false,
8+
"reveal": "always"
9+
},
10+
{
11+
"label": "Gdx test wheel",
12+
"command": "just",
13+
"args": ["test"],
14+
"use_new_terminal": false,
15+
"allow_concurrent_runs": false,
16+
"reveal": "always"
17+
}
18+
]

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
[package]
2-
name = "geodynamix"
2+
name = "geodynamix"
33
version = "0.16.0"
44
edition = "2021"
55

66
[workspace]
77
members = ["infra-rs/crates/geo", "infra-rs/crates/inf"]
88

99
[lib]
10-
name = "geodynamix"
10+
name = "geodynamix"
1111
crate-type = ["cdylib"]
1212

1313
[dependencies]
14-
pyo3 = { version = "0.23", features = ["extension-module"] }
14+
pyo3 = { version = "0.23", features = ["extension-module"] }
1515
pyo3-log = "0.12"
16-
numpy = "0.23"
17-
inf = { path = "infra-rs/crates/inf" }
18-
geo = { path = "infra-rs/crates/geo", features = ["gdal", "python"] }
16+
numpy = "0.23"
17+
inf = { path = "infra-rs/crates/inf" }
18+
geo = { path = "infra-rs/crates/geo", features = ["gdal", "python"] }
1919

2020
[features]
21-
default = []
21+
default = []
2222
static_build = ["geo/gdal-static"]
2323

2424
[package.metadata.vcpkg]

infra-rs

Submodule infra-rs updated from 02a080c to bbecd1d

justfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ cargo-config-gen:
2121
cp infra-rs/.cargo/config.toml.in .cargo/config.toml
2222
sd @CARGO_VCPKG_TRIPLET@ {{VCPKG_DEFAULT_TRIPLET}} .cargo/config.toml
2323
sd @PYTHON_EXE@ {{PYTHON_EXE}} .cargo/config.toml
24-
24+
2525
bootstrap: cargo-config-gen
2626
echo "Bootstrapping vcpkg:{{VCPKG_DEFAULT_TRIPLET}}..."
2727
cargo vcpkg -v build
@@ -34,7 +34,7 @@ bootstrap: cargo-config-gen
3434
cp ./target/data/proj.db ./target/release/
3535
cp ./target/data/proj.db ./python/geodynamix.data/data/share/geodynamix/
3636
pixi install
37-
37+
3838
doc:
3939
cargo doc --workspace --exclude='infra-rs' --exclude='vector_derive' --no-deps --all-features --open
4040

@@ -48,10 +48,10 @@ build_release:
4848
cargo build --workspace --release
4949

5050
test_debug:
51-
cargo nextest run --profile ci --workspace --features=static_build
52-
53-
build: build_release
51+
cargo nextest run --profile ci --workspace --features=static_build
5452

55-
test:
56-
pixi run maturin develop; pixi run test
53+
wheel_develop:
54+
pixi run maturin develop
5755

56+
test: wheel_develop
57+
pixi run test

src/pyio.rs renamed to src/io.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use pyo3::prelude::*;
22

3-
use crate::{
4-
pyraster::{PythonDenseArray, Raster},
5-
pyutils,
6-
};
3+
use crate::{utils, PythonDenseArray, Raster};
74

85
#[pyfunction]
96
pub fn read(path: std::path::PathBuf) -> PyResult<Raster> {
@@ -12,7 +9,7 @@ pub fn read(path: std::path::PathBuf) -> PyResult<Raster> {
129

1310
#[pyfunction]
1411
pub fn read_as(dtype: &Bound<'_, PyAny>, path: std::path::PathBuf) -> PyResult<Raster> {
15-
let dtype = pyutils::convert_data_type(dtype)?;
12+
let dtype = utils::convert_data_type(dtype)?;
1613
Ok(PythonDenseArray::read_as(dtype, &path)?.into())
1714
}
1815

src/lib.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,41 @@
1+
use geo::AnyDenseArray;
12
use pyo3::prelude::*;
2-
use std::path::PathBuf;
33

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;
710

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>;
1215

13-
/// A Python module implemented in Rust.
16+
/// The main geodynamix module
17+
/// Typically imported as `import geodynamix as gdx`
1418
#[pymodule]
1519
fn geodynamix(m: &Bound<'_, PyModule>) -> PyResult<()> {
1620
pyo3_log::init();
1721

1822
#[cfg(feature = "static_build")]
1923
configure_proj_data()?;
2024

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())?;
2732
Ok(())
2833
}
2934

3035
#[cfg(feature = "static_build")]
3136
fn configure_proj_data() -> PyResult<()> {
37+
use std::path::PathBuf;
38+
3239
// If we are using a static build, we are responsible for shipping the proj.db
3340
// So make sure gdal can find it
3441
let python_exe = std::env::current_exe()?;

src/nodata.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use pyo3::prelude::*;
2+
3+
#[pyclass(name = "nodata")]
4+
#[derive(Default)]
5+
pub struct Nodata {}

0 commit comments

Comments
 (0)