83 int32_t bandindex = 0;
87 bool exclude_nodata_value =
TRUE;
91 bandindex = PG_GETARG_INT32(1);
92 if ( bandindex < 1 ) {
93 elog(NOTICE,
"Invalid band index (must use 1-based). Returning NULL");
97 x = PG_GETARG_INT32(2);
99 y = PG_GETARG_INT32(3);
101 exclude_nodata_value = PG_GETARG_BOOL(4);
106 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
107 pgraster = (
rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
111 PG_FREE_IF_COPY(pgraster, 0);
112 elog(ERROR,
"RASTER_getPixelValue: Could not deserialize raster");
119 elog(NOTICE,
"Could not find raster band of index %d when getting pixel "
120 "value. Returning NULL", bandindex);
122 PG_FREE_IF_COPY(pgraster, 0);
130 if (
result !=
ES_NONE || (exclude_nodata_value && isnodata)) {
132 PG_FREE_IF_COPY(pgraster, 0);
137 PG_FREE_IF_COPY(pgraster, 0);
139 PG_RETURN_FLOAT8(pixvalue);
char result[OUT_DOUBLE_BUFFER_SIZE]
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
#define POSTGIS_RT_DEBUGF(level, msg,...)