[raster] Modify ST_MapAlgebra to handle expressions and user-functions
|Reported by:||dzwarg||Owned by:||dzwarg|
- Modify ST_MapAlgebra to ST_MapAlgebraExp (with expression) to evaluate cells of a raster with a single expression.
- Create ST_MapAlgebraFct (with function) to evaluate cells of a raster with a user-specified plpgsql function.
To support item 2, the rt_pg layer needs a hook from SQL to callback a specified function. I am calling this ST_CallUserFn. This method takes a callback plpgsql function that will be evaluated for every cell in the raster.
A callback plpgsql function currently must be defined in the following manner:
CREATE OR REPLACE FUNCTION MyUserFunctionName(cell FLOAT, VARIADIC args TEXT) RETURNS FLOAT AS $$ DECLARE -- Some custom arguments, always passed in as TEXT type. arg1 FLOAT; arg2 FLOAT; BEGIN -- To use your custom arguments, cast them to the type you need, -- and perform your calculations. Return the new value for the -- new raster cell's value. RETURN cell; END; $$ LANGUAGE plpgsql;