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

Definition at line 2606 of file rt_pg.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().

2607 {
2608  rt_pgraster *pgraster = NULL;
2609  rt_raster raster = NULL;
2610  rt_band band = NULL;
2611  int32_t bandindex;
2612  bool forcechecking = FALSE;
2613  bool bandisnodata = FALSE;
2614 
2615  /* Index is 1-based */
2616  bandindex = PG_GETARG_INT32(1);
2617  if ( bandindex < 1 ) {
2618  elog(NOTICE, "Invalid band index (must use 1-based). Returning NULL");
2619  PG_RETURN_NULL();
2620  }
2621 
2622  /* Deserialize raster */
2623  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
2624  pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
2625 
2626  raster = rt_raster_deserialize(pgraster, FALSE);
2627  if ( ! raster ) {
2628  PG_FREE_IF_COPY(pgraster, 0);
2629  elog(ERROR, "RASTER_bandIsNoData: Could not deserialize raster");
2630  PG_RETURN_NULL();
2631  }
2632 
2633  /* Fetch requested band and its nodata value */
2634  band = rt_raster_get_band(raster, bandindex - 1);
2635  if ( ! band ) {
2636  elog(NOTICE, "Could not find raster band of index %d when determining if band is nodata. Returning NULL", bandindex);
2637  rt_raster_destroy(raster);
2638  PG_FREE_IF_COPY(pgraster, 0);
2639  PG_RETURN_NULL();
2640  }
2641 
2642  forcechecking = PG_GETARG_BOOL(2);
2643 
2644  bandisnodata = (forcechecking) ?
2646 
2647  rt_raster_destroy(raster);
2648  PG_FREE_IF_COPY(pgraster, 0);
2649 
2650  PG_RETURN_BOOL(bandisnodata);
2651 }
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_api.c:5387
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:123
int rt_band_get_isnodata_flag(rt_band band)
Get isnodata flag value.
Definition: rt_api.c:2042
rt_band rt_raster_get_band(rt_raster raster, int n)
Return Nth band, or NULL if unavailable.
Definition: rt_api.c:5686
#define FALSE
Definition: dbfopen.c:169
Struct definitions.
Definition: rt_api.h:2175
int rt_band_check_is_nodata(rt_band band)
Returns TRUE if the band is only nodata values.
Definition: rt_api.c:3080
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_api.c:8350

Here is the call graph for this function: