122 const size_t name_size = 8;
128 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
129 pgraster = (
rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
132 bandindex = PG_GETARG_INT32(1);
133 if ( bandindex < 1 ) {
134 elog(NOTICE,
"Invalid band index (must use 1-based). Returning NULL");
135 PG_FREE_IF_COPY(pgraster, 0);
141 PG_FREE_IF_COPY(pgraster, 0);
142 elog(ERROR,
"RASTER_getBandPixelTypeName: Could not deserialize raster");
149 elog(NOTICE,
"Could not find raster band of index %d when getting pixel type name. Returning NULL", bandindex);
151 PG_FREE_IF_COPY(pgraster, 0);
157 result = palloc(VARHDRSZ + name_size);
162 memset(VARDATA(result), 0, name_size);
163 ptr = (
char *)result + VARHDRSZ;
166 size = VARHDRSZ + strlen(ptr);
167 SET_VARSIZE(result, size);
170 PG_FREE_IF_COPY(pgraster, 0);
172 PG_RETURN_TEXT_P(result);
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
const char * rt_pixtype_name(rt_pixtype pixtype)
rt_pixtype rt_band_get_pixtype(rt_band band)
Return pixeltype of this band.
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.