PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ RASTER_getBandFileSize()

Datum RASTER_getBandFileSize ( PG_FUNCTION_ARGS  )

Definition at line 351 of file rtpg_band_properties.c.

352 {
353  rt_pgraster *pgraster;
355  rt_band band = NULL;
356  int64_t fileSize;
357  int32_t bandindex;
358 
359  /* Index is 1-based */
360  bandindex = PG_GETARG_INT32(1);
361  if ( bandindex < 1 ) {
362  elog(NOTICE, "Invalid band index (must use 1-based). Returning NULL");
363  PG_RETURN_NULL();
364  }
365 
366  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
367  pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
368 
369  raster = rt_raster_deserialize(pgraster, FALSE);
370  if ( ! raster ) {
371  PG_FREE_IF_COPY(pgraster, 0);
372  elog(ERROR, "RASTER_getFileSize: Could not deserialize raster");
373  PG_RETURN_NULL();
374  }
375 
376  /* Fetch requested band */
377  band = rt_raster_get_band(raster, bandindex - 1);
378  if (!band) {
379  elog(
380  NOTICE,
381  "Could not find raster band of index %d when getting band path. Returning NULL",
382  bandindex
383  );
385  PG_FREE_IF_COPY(pgraster, 0);
386  PG_RETURN_NULL();
387  }
388 
389  if (!rt_band_is_offline(band)) {
390  elog(NOTICE, "Band of index %d is not out-db.", bandindex);
393  PG_FREE_IF_COPY(pgraster, 0);
394  PG_RETURN_NULL();
395  }
396 
397  fileSize = rt_band_get_file_size(band);
398 
401  PG_FREE_IF_COPY(pgraster, 0);
402 
403  PG_RETURN_INT64(fileSize);
404 }
#define FALSE
Definition: dbfopen.c:72
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:86
uint64_t rt_band_get_file_size(rt_band band)
Return file size in bytes.
Definition: rt_band.c:586
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition: rt_band.c:340
int rt_band_is_offline(rt_band band)
Return non-zero if the given band data is on the filesystem.
Definition: rt_band.c:329
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, rt_band_destroy(), rt_band_get_file_size(), rt_band_is_offline(), rt_raster_deserialize(), rt_raster_destroy(), and rt_raster_get_band().

Here is the call graph for this function: