380 ArrayType *mdValues = NULL;
381 Datum *_values = NULL;
382 bool *_nodata = NULL;
384 ArrayType *mdPos = NULL;
393 int lbound[3] = {1, 1, 1};
394 Datum datum = (Datum) NULL;
408 if (_values == NULL || _nodata == NULL) {
409 elog(ERROR,
"rtpg_nmapalgebra_callback: Could not allocate memory for values array");
416 for (z = 0; z < arg->
rasters; z++) {
418 for (
y = 0;
y < arg->
rows;
y++) {
424 _nodata[i] = (bool) arg->
nodata[z][
y][
x];
426 _values[i] = Float8GetDatum(arg->
values[z][
y][
x]);
428 _values[i] = (Datum) NULL;
436 get_typlenbyvalalign(FLOAT8OID, &typlen, &typbyval, &typalign);
439 mdValues = construct_md_array(
443 typlen, typbyval, typalign
448 _pos = palloc(
sizeof(Datum) * (arg->
rasters + 1) * 2);
449 _null = palloc(
sizeof(
bool) * (arg->
rasters + 1) * 2);
450 if (_pos == NULL || _null == NULL) {
452 elog(ERROR,
"rtpg_nmapalgebra_callback: Could not allocate memory for position array");
455 memset(_null, 0,
sizeof(
bool) * (arg->
rasters + 1) * 2);
464 for (z = 0; z < arg->
rasters; z++) {
465 _pos[i] = (Datum)arg->
src_pixel[z][0] + 1;
468 _pos[i] = (Datum)arg->
src_pixel[z][1] + 1;
473 get_typlenbyvalalign(INT4OID, &typlen, &typbyval, &typalign);
481 mdPos = construct_md_array(
485 typlen, typbyval, typalign
490 callback->
ufc_info->args[0].value = PointerGetDatum(mdValues);
491 callback->
ufc_info->args[1].value = PointerGetDatum(mdPos);
494 datum = FunctionCallInvoke(callback->
ufc_info);
503 *
value = DatumGetFloat8(datum);
506 *
value = (double) DatumGetFloat4(datum);
509 *
value = (double) DatumGetInt32(datum);
512 *
value = (double) DatumGetInt16(datum);
#define POSTGIS_RT_DEBUGF(level, msg,...)
FunctionCallInfo ufc_info