PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ RASTER_getBandPath()

Datum RASTER_getBandPath ( PG_FUNCTION_ARGS  )

Definition at line 289 of file rtpg_band_properties.c.

290 {
291  rt_pgraster *pgraster = NULL;
292  rt_raster raster = NULL;
293  rt_band band = NULL;
294  int32_t bandindex;
295  const char *bandpath;
296  text *result;
297 
298  /* Index is 1-based */
299  bandindex = PG_GETARG_INT32(1);
300  if ( bandindex < 1 ) {
301  elog(NOTICE, "Invalid band index (must use 1-based). Returning NULL");
302  PG_RETURN_NULL();
303  }
304 
305  /* Deserialize raster */
306  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
307  pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
308 
309  raster = rt_raster_deserialize(pgraster, FALSE);
310  if (!raster) {
311  PG_FREE_IF_COPY(pgraster, 0);
312  elog(ERROR, "RASTER_getBandPath: Could not deserialize raster");
313  PG_RETURN_NULL();
314  }
315 
316  /* Fetch requested band */
317  band = rt_raster_get_band(raster, bandindex - 1);
318  if (!band) {
319  elog(
320  NOTICE,
321  "Could not find raster band of index %d when getting band path. Returning NULL",
322  bandindex
323  );
325  PG_FREE_IF_COPY(pgraster, 0);
326  PG_RETURN_NULL();
327  }
328 
329  bandpath = rt_band_get_ext_path(band);
330  if (!bandpath) {
333  PG_FREE_IF_COPY(pgraster, 0);
334  PG_RETURN_NULL();
335  }
336 
337  result = cstring_to_text(bandpath);
338 
341  PG_FREE_IF_COPY(pgraster, 0);
342 
343  PG_RETURN_TEXT_P(result);
344 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:267
#define FALSE
Definition: dbfopen.c:72
const char * rt_band_get_ext_path(rt_band band)
Return band's external path (only valid when rt_band_is_offline returns non-zero).
Definition: rt_band.c:363
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:86
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition: rt_band.c:340
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, result, rt_band_destroy(), rt_band_get_ext_path(), rt_raster_deserialize(), rt_raster_destroy(), and rt_raster_get_band().

Here is the call graph for this function: