PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ RASTER_getBandPixelType()

Datum RASTER_getBandPixelType ( PG_FUNCTION_ARGS  )

Definition at line 72 of file rtpg_band_properties.c.

73{
74 rt_pgraster *pgraster = NULL;
75 rt_raster raster = NULL;
76 rt_band band = NULL;
77 rt_pixtype pixtype;
78 int32_t bandindex;
79
80 /* Deserialize raster */
81 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
82 pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
83
84 /* Index is 1-based */
85 bandindex = PG_GETARG_INT32(1);
86 if ( bandindex < 1 ) {
87 elog(NOTICE, "Invalid band index (must use 1-based). Returning NULL");
88 PG_FREE_IF_COPY(pgraster, 0);
89 PG_RETURN_NULL();
90 }
91
93 if ( ! raster ) {
94 PG_FREE_IF_COPY(pgraster, 0);
95 elog(ERROR, "RASTER_getBandPixelType: Could not deserialize raster");
96 PG_RETURN_NULL();
97 }
98
99 /* Fetch requested band and its pixel type */
100 band = rt_raster_get_band(raster, bandindex - 1);
101 if ( ! band ) {
102 elog(NOTICE, "Could not find raster band of index %d when getting pixel type. Returning NULL", bandindex);
103 rt_raster_destroy(raster);
104 PG_FREE_IF_COPY(pgraster, 0);
105 PG_RETURN_NULL();
106 }
107
108 pixtype = rt_band_get_pixtype(band);
109
110 rt_raster_destroy(raster);
111 PG_FREE_IF_COPY(pgraster, 0);
112
113 PG_RETURN_INT32(pixtype);
114}
#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:188
rt_pixtype rt_band_get_pixtype(rt_band band)
Return pixeltype of this band.
Definition rt_band.c:790
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
Definition rt_raster.c:385
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition rtrowdump.py:125
Struct definitions.
Definition librtcore.h:2452

References FALSE, rt_band_get_pixtype(), rt_raster_deserialize(), rt_raster_destroy(), and rt_raster_get_band().

Here is the call graph for this function: