PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ RASTER_getBandNoDataValue()

Datum RASTER_getBandNoDataValue ( PG_FUNCTION_ARGS  )

Definition at line 187 of file rtpg_band_properties.c.

188 {
189  rt_pgraster *pgraster = NULL;
190  rt_raster raster = NULL;
191  rt_band band = NULL;
192  int32_t bandindex;
193  double nodata;
194 
195  /* Deserialize raster */
196  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
197  pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
198 
199  /* Index is 1-based */
200  bandindex = PG_GETARG_INT32(1);
201  if ( bandindex < 1 ) {
202  elog(NOTICE, "Invalid band index (must use 1-based). Returning NULL");
203  PG_FREE_IF_COPY(pgraster, 0);
204  PG_RETURN_NULL();
205  }
206 
207  raster = rt_raster_deserialize(pgraster, FALSE);
208  if ( ! raster ) {
209  PG_FREE_IF_COPY(pgraster, 0);
210  elog(ERROR, "RASTER_getBandNoDataValue: Could not deserialize raster");
211  PG_RETURN_NULL();
212  }
213 
214  /* Fetch requested band and its nodata value */
215  band = rt_raster_get_band(raster, bandindex - 1);
216  if ( ! band ) {
217  elog(NOTICE, "Could not find raster band of index %d when getting band nodata value. Returning NULL", bandindex);
219  PG_FREE_IF_COPY(pgraster, 0);
220  PG_RETURN_NULL();
221  }
222 
223  if ( ! rt_band_get_hasnodata_flag(band) ) {
224  /* Raster does not have a nodata value set so we return NULL */
226  PG_FREE_IF_COPY(pgraster, 0);
227  PG_RETURN_NULL();
228  }
229 
230  rt_band_get_nodata(band, &nodata);
231 
233  PG_FREE_IF_COPY(pgraster, 0);
234 
235  PG_RETURN_FLOAT8(nodata);
236 }
#define FALSE
Definition: dbfopen.c:168
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
Definition: rt_band.c:674
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
Definition: rt_band.c:1730
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_serialize.c:725
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
Definition: rt_raster.c:381
band
Definition: ovdump.py:57
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
Struct definitions.
Definition: librtcore.h:2250

References ovdump::band, FALSE, rtrowdump::raster, rt_band_get_hasnodata_flag(), rt_band_get_nodata(), rt_raster_deserialize(), rt_raster_destroy(), and rt_raster_get_band().

Here is the call graph for this function: