PostGIS  2.2.7dev-r@@SVN_REVISION@@
Datum RASTER_bandIsNoData ( PG_FUNCTION_ARGS  )

Definition at line 233 of file rtpg_band_properties.c.

References ovdump::band, FALSE, rtrowdump::raster, rt_band_check_is_nodata(), rt_band_get_isnodata_flag(), rt_raster_deserialize(), rt_raster_destroy(), and rt_raster_get_band().

234 {
235  rt_pgraster *pgraster = NULL;
236  rt_raster raster = NULL;
237  rt_band band = NULL;
238  int32_t bandindex;
239  bool forcechecking = FALSE;
240  bool bandisnodata = FALSE;
241 
242  /* Index is 1-based */
243  bandindex = PG_GETARG_INT32(1);
244  if ( bandindex < 1 ) {
245  elog(NOTICE, "Invalid band index (must use 1-based). Returning NULL");
246  PG_RETURN_NULL();
247  }
248 
249  /* Deserialize raster */
250  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
251  pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
252 
253  raster = rt_raster_deserialize(pgraster, FALSE);
254  if ( ! raster ) {
255  PG_FREE_IF_COPY(pgraster, 0);
256  elog(ERROR, "RASTER_bandIsNoData: Could not deserialize raster");
257  PG_RETURN_NULL();
258  }
259 
260  /* Fetch requested band and its nodata value */
261  band = rt_raster_get_band(raster, bandindex - 1);
262  if ( ! band ) {
263  elog(NOTICE, "Could not find raster band of index %d when determining if band is nodata. Returning NULL", bandindex);
264  rt_raster_destroy(raster);
265  PG_FREE_IF_COPY(pgraster, 0);
266  PG_RETURN_NULL();
267  }
268 
269  forcechecking = PG_GETARG_BOOL(2);
270 
271  bandisnodata = (forcechecking) ?
273 
274  rt_raster_destroy(raster);
275  PG_FREE_IF_COPY(pgraster, 0);
276 
277  PG_RETURN_BOOL(bandisnodata);
278 }
tuple band
Definition: ovdump.py:57
tuple raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
Definition: rt_raster.c:381
int rt_band_check_is_nodata(rt_band band)
Returns TRUE if the band is only nodata values.
Definition: rt_band.c:1619
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
#define FALSE
Definition: dbfopen.c:168
Struct definitions.
Definition: librtcore.h:2213
int rt_band_get_isnodata_flag(rt_band band)
Get isnodata flag value.
Definition: rt_band.c:581
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_serialize.c:717

Here is the call graph for this function: