PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ RASTER_getBandPath()

Datum RASTER_getBandPath ( PG_FUNCTION_ARGS  )

Definition at line 291 of file rtpg_band_properties.c.

References ovdump::band, FALSE, PG_FUNCTION_INFO_V1(), rtrowdump::raster, RASTER_getBandFileSize(), rt_band_destroy(), rt_band_get_ext_path(), rt_raster_deserialize(), rt_raster_destroy(), and rt_raster_get_band().

Referenced by RASTER_bandIsNoData().

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