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

Definition at line 2307 of file rt_pg.c.

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

2308 {
2309  rt_pgraster *pgraster = NULL;
2310  rt_raster raster = NULL;
2311  rt_band band = NULL;
2312  rt_pixtype pixtype;
2313  int32_t bandindex;
2314 
2315  /* Deserialize raster */
2316  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
2317  pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
2318 
2319  /* Index is 1-based */
2320  bandindex = PG_GETARG_INT32(1);
2321  if ( bandindex < 1 ) {
2322  elog(NOTICE, "Invalid band index (must use 1-based). Returning NULL");
2323  PG_FREE_IF_COPY(pgraster, 0);
2324  PG_RETURN_NULL();
2325  }
2326 
2327  raster = rt_raster_deserialize(pgraster, FALSE);
2328  if ( ! raster ) {
2329  PG_FREE_IF_COPY(pgraster, 0);
2330  elog(ERROR, "RASTER_getBandPixelType: Could not deserialize raster");
2331  PG_RETURN_NULL();
2332  }
2333 
2334  /* Fetch requested band and its pixel type */
2335  band = rt_raster_get_band(raster, bandindex - 1);
2336  if ( ! band ) {
2337  elog(NOTICE, "Could not find raster band of index %d when getting pixel type. Returning NULL", bandindex);
2338  rt_raster_destroy(raster);
2339  PG_FREE_IF_COPY(pgraster, 0);
2340  PG_RETURN_NULL();
2341  }
2342 
2343  pixtype = rt_band_get_pixtype(band);
2344 
2345  rt_raster_destroy(raster);
2346  PG_FREE_IF_COPY(pgraster, 0);
2347 
2348  PG_RETURN_INT32(pixtype);
2349 }
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_api.c:5387
rt_pixtype rt_band_get_pixtype(rt_band band)
Return pixeltype of this band.
Definition: rt_api.c:1900
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
rt_pixtype
Definition: rt_api.h:172
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
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: