PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ RASTER_getBandPixelType()

Datum RASTER_getBandPixelType ( PG_FUNCTION_ARGS  )

Definition at line 70 of file rtpg_band_properties.c.

71 {
72  rt_pgraster *pgraster = NULL;
73  rt_raster raster = NULL;
74  rt_band band = NULL;
75  rt_pixtype pixtype;
76  int32_t bandindex;
77 
78  /* Deserialize raster */
79  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
80  pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
81 
82  /* Index is 1-based */
83  bandindex = PG_GETARG_INT32(1);
84  if ( bandindex < 1 ) {
85  elog(NOTICE, "Invalid band index (must use 1-based). Returning NULL");
86  PG_FREE_IF_COPY(pgraster, 0);
87  PG_RETURN_NULL();
88  }
89 
90  raster = rt_raster_deserialize(pgraster, FALSE);
91  if ( ! raster ) {
92  PG_FREE_IF_COPY(pgraster, 0);
93  elog(ERROR, "RASTER_getBandPixelType: Could not deserialize raster");
94  PG_RETURN_NULL();
95  }
96 
97  /* Fetch requested band and its pixel type */
98  band = rt_raster_get_band(raster, bandindex - 1);
99  if ( ! band ) {
100  elog(NOTICE, "Could not find raster band of index %d when getting pixel type. Returning NULL", bandindex);
102  PG_FREE_IF_COPY(pgraster, 0);
103  PG_RETURN_NULL();
104  }
105 
106  pixtype = rt_band_get_pixtype(band);
107 
109  PG_FREE_IF_COPY(pgraster, 0);
110 
111  PG_RETURN_INT32(pixtype);
112 }
#define FALSE
Definition: dbfopen.c:72
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:86
rt_pixtype
Definition: librtcore.h:187
rt_pixtype rt_band_get_pixtype(rt_band band)
Return pixeltype of this band.
Definition: rt_band.c:631
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:385
band
Definition: ovdump.py:58
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:2396

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

Here is the call graph for this function: