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

◆ RASTER_getBandFileTimestamp()

Datum RASTER_getBandFileTimestamp ( PG_FUNCTION_ARGS  )

Definition at line 412 of file rtpg_band_properties.c.

413{
414 rt_pgraster *pgraster;
416 rt_band band = NULL;
417 int64_t fileSize;
418 int32_t bandindex;
419
420 /* Index is 1-based */
421 bandindex = PG_GETARG_INT32(1);
422 if ( bandindex < 1 ) {
423 elog(NOTICE, "Invalid band index (must use 1-based). Returning NULL");
424 PG_RETURN_NULL();
425 }
426
427 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
428 pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
429
431 if ( ! raster ) {
432 PG_FREE_IF_COPY(pgraster, 0);
433 elog(ERROR, "RASTER_getBandFileTimestamp: Could not deserialize raster");
434 PG_RETURN_NULL();
435 }
436
437 /* Fetch requested band */
438 band = rt_raster_get_band(raster, bandindex - 1);
439 if (!band) {
440 elog(
441 NOTICE,
442 "Could not find raster band of index %d when getting band path. Returning NULL",
443 bandindex
444 );
445 rt_raster_destroy(raster);
446 PG_FREE_IF_COPY(pgraster, 0);
447 PG_RETURN_NULL();
448 }
449
450 if (!rt_band_is_offline(band)) {
451 elog(NOTICE, "Band of index %d is not out-db.", bandindex);
452 rt_band_destroy(band);
453 rt_raster_destroy(raster);
454 PG_FREE_IF_COPY(pgraster, 0);
455 PG_RETURN_NULL();
456 }
457
458 fileSize = rt_band_get_file_timestamp(band);
459
460 rt_band_destroy(band);
461 rt_raster_destroy(raster);
462 PG_FREE_IF_COPY(pgraster, 0);
463
464 PG_RETURN_INT64(fileSize);
465}
#define FALSE
Definition dbfopen.c:72
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:499
uint64_t rt_band_get_file_timestamp(rt_band band)
Return file timestamp.
Definition rt_band.c:767
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_timestamp(), rt_band_is_offline(), rt_raster_deserialize(), rt_raster_destroy(), and rt_raster_get_band().

Here is the call graph for this function: