macro_rules! dsl_function {
(fn $name:ident ( $($param:ident),* $(,)? ) = $body:expr ;) => { ... };
}Expand description
Define a helper that returns the DSL source definition of a reusable raster-algebra function.
This does not register a Rust-callable function and does not evaluate
anything: it expands to pub fn <name>() -> String returning a syntactically
valid DSL function declaration such as
"fn ndvi(nir, red) = (nir - red) / (nir + red);". Prepend that string to a
DSL program and then call the function from a DSL expression to use it.
§Examples
ⓘ
use oxigeo_algorithms::dsl_function;
use oxigeo_algorithms::dsl::RasterDsl;
dsl_function! {
fn ndvi(nir, red) = (nir - red) / (nir + red);
}
// `ndvi()` yields the DSL source; splice it into a program and call it.
let program = format!("{}\nndvi(B1, B2);", ndvi());
let dsl = RasterDsl::new();
// dsl.execute(&program, &[nir_band, red_band]) -> resulting raster