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

Definition at line 65 of file rtpg_band_properties.c.

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

66 {
67  rt_pgraster *pgraster = NULL;
68  rt_raster raster = NULL;
69  rt_band band = NULL;
70  rt_pixtype pixtype;
71  int32_t bandindex;
72 
73  /* Deserialize raster */
74  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
75  pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
76 
77  /* Index is 1-based */
78  bandindex = PG_GETARG_INT32(1);
79  if ( bandindex < 1 ) {
80  elog(NOTICE, "Invalid band index (must use 1-based). Returning NULL");
81  PG_FREE_IF_COPY(pgraster, 0);
82  PG_RETURN_NULL();
83  }
84 
85  raster = rt_raster_deserialize(pgraster, FALSE);
86  if ( ! raster ) {
87  PG_FREE_IF_COPY(pgraster, 0);
88  elog(ERROR, "RASTER_getBandPixelType: Could not deserialize raster");
89  PG_RETURN_NULL();
90  }
91 
92  /* Fetch requested band and its pixel type */
93  band = rt_raster_get_band(raster, bandindex - 1);
94  if ( ! band ) {
95  elog(NOTICE, "Could not find raster band of index %d when getting pixel type. Returning NULL", bandindex);
96  rt_raster_destroy(raster);
97  PG_FREE_IF_COPY(pgraster, 0);
98  PG_RETURN_NULL();
99  }
100 
101  pixtype = rt_band_get_pixtype(band);
102 
103  rt_raster_destroy(raster);
104  PG_FREE_IF_COPY(pgraster, 0);
105 
106  PG_RETURN_INT32(pixtype);
107 }
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_pixtype
Definition: librtcore.h:185
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
Definition: rt_raster.c:381
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:2201
rt_pixtype rt_band_get_pixtype(rt_band band)
Return pixeltype of this band.
Definition: rt_band.c:498
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: