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

◆ RASTER_getBandFileSize()

Datum RASTER_getBandFileSize ( PG_FUNCTION_ARGS  )

Definition at line 353 of file rtpg_band_properties.c.

354{
355 rt_pgraster *pgraster;
357 rt_band band = NULL;
358 int64_t fileSize;
359 int32_t bandindex;
360
361 /* Index is 1-based */
362 bandindex = PG_GETARG_INT32(1);
363 if ( bandindex < 1 ) {
364 elog(NOTICE, "Invalid band index (must use 1-based). Returning NULL");
365 PG_RETURN_NULL();
366 }
367
368 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
369 pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
370
372 if ( ! raster ) {
373 PG_FREE_IF_COPY(pgraster, 0);
374 elog(ERROR, "RASTER_getFileSize: Could not deserialize raster");
375 PG_RETURN_NULL();
376 }
377
378 /* Fetch requested band */
379 band = rt_raster_get_band(raster, bandindex - 1);
380 if (!band) {
381 elog(
382 NOTICE,
383 "Could not find raster band of index %d when getting band path. Returning NULL",
384 bandindex
385 );
386 rt_raster_destroy(raster);
387 PG_FREE_IF_COPY(pgraster, 0);
388 PG_RETURN_NULL();
389 }
390
391 if (!rt_band_is_offline(band)) {
392 elog(NOTICE, "Band of index %d is not out-db.", bandindex);
393 rt_band_destroy(band);
394 rt_raster_destroy(raster);
395 PG_FREE_IF_COPY(pgraster, 0);
396 PG_RETURN_NULL();
397 }
398
399 fileSize = rt_band_get_file_size(band);
400
401 rt_band_destroy(band);
402 rt_raster_destroy(raster);
403 PG_FREE_IF_COPY(pgraster, 0);
404
405 PG_RETURN_INT64(fileSize);
406}
#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:745
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition rt_band.c:499
int rt_band_is_offline(rt_band band)
Return non-zero if the given band data is on the filesystem.
Definition rt_band.c:488
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_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: