PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ RASTER_getBandPixelType()

Datum RASTER_getBandPixelType ( PG_FUNCTION_ARGS  )

Definition at line 67 of file rtpg_band_properties.c.

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

68 {
69  rt_pgraster *pgraster = NULL;
70  rt_raster raster = NULL;
71  rt_band band = NULL;
72  rt_pixtype pixtype;
73  int32_t bandindex;
74 
75  /* Deserialize raster */
76  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
77  pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
78 
79  /* Index is 1-based */
80  bandindex = PG_GETARG_INT32(1);
81  if ( bandindex < 1 ) {
82  elog(NOTICE, "Invalid band index (must use 1-based). Returning NULL");
83  PG_FREE_IF_COPY(pgraster, 0);
84  PG_RETURN_NULL();
85  }
86 
87  raster = rt_raster_deserialize(pgraster, FALSE);
88  if ( ! raster ) {
89  PG_FREE_IF_COPY(pgraster, 0);
90  elog(ERROR, "RASTER_getBandPixelType: Could not deserialize raster");
91  PG_RETURN_NULL();
92  }
93 
94  /* Fetch requested band and its pixel type */
95  band = rt_raster_get_band(raster, bandindex - 1);
96  if ( ! band ) {
97  elog(NOTICE, "Could not find raster band of index %d when getting pixel type. Returning NULL", bandindex);
98  rt_raster_destroy(raster);
99  PG_FREE_IF_COPY(pgraster, 0);
100  PG_RETURN_NULL();
101  }
102 
103  pixtype = rt_band_get_pixtype(band);
104 
105  rt_raster_destroy(raster);
106  PG_FREE_IF_COPY(pgraster, 0);
107 
108  PG_RETURN_INT32(pixtype);
109 }
raster
Be careful!! Zeros function&#39;s input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
band
Definition: ovdump.py:57
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:2230
rt_pixtype rt_band_get_pixtype(rt_band band)
Return pixeltype of this band.
Definition: rt_band.c:583
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: