/* one-raster neighborhood MapAlgebra */
Datum RASTER_mapAlgebraFctNgb(PG_FUNCTION_ARGS);
-/* Replace function taken from
+/* string replacement function taken from
* http://ubuntuforums.org/showthread.php?s=aa6f015109fd7e4c7e30d2fd8b717497&t=141670&page=3
*/
/* ---------------------------------------------------------------------------
sprintf(strnewval, "%f", r);
if (initexpr != NULL) {
+ count = 0;
newexpr = replace(initexpr, "RAST", strnewval, &count);
POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraExpr: (%dx%d), "
if (!PG_ARGISNULL(exprpos[i])) {
expr = strtoupper(text_to_cstring(PG_GETARG_TEXT_P(exprpos[i])));
POSTGIS_RT_DEBUGF(3, "raw expr #%d: %s", i, expr);
+ len = 0;
expr = replace(expr, "RAST1", "$1", &len);
if (len) {
argcount[i]++;
argexists[i][0] = 1;
}
+ len = 0;
expr = replace(expr, "RAST2", (argexists[i][0] ? "$2" : "$1"), &len);
if (len) {
argcount[i]++;
}
else
hasnodatanodataval = 0;
- } break;
+ break;
+ }
case REGPROCEDUREOID: {
POSTGIS_RT_DEBUG(3, "arg 4 is \"userfunction\"!");
if (!PG_ARGISNULL(4)) {
ufcnullcount++;
}
}
- } break;
+ break;
+ }
default:
elog(ERROR, "RASTER_mapAlgebra2: Invalid data type for expression or userfunction");
for (k = 0; k < set_count; k++) rt_raster_destroy(_rast[k]);