670 const int set_count = 2;
672 int pgrastpos[2] = {-1, -1};
684 for (i = 0, j = 0; i < set_count; i++) {
686 if (PG_ARGISNULL(j)) {
687 for (k = 0; k < i; k++) {
689 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
693 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
700 for (k = 0; k <= i; k++) {
703 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
705 elog(ERROR,
"RASTER_covers: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
712 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
714 for (k = 0; k < i; k++) {
716 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
722 if (!PG_ARGISNULL(j)) {
723 bandindex[i] = PG_GETARG_INT32(j);
724 if (bandindex[i] < 1 || bandindex[i] > numBands) {
725 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
727 for (k = 0; k < i; k++) {
729 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
744 (hasbandindex[0] && !hasbandindex[1]) ||
745 (!hasbandindex[0] && hasbandindex[1])
747 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
748 for (k = 0; k < set_count; k++) {
750 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
757 for (k = 0; k < set_count; k++) {
759 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
761 elog(ERROR,
"The two rasters provided have different SRIDs");
766 rast[0], (hasbandindex[0] ? bandindex[0] - 1 : -1),
767 rast[1], (hasbandindex[1] ? bandindex[1] - 1 : -1),
770 for (k = 0; k < set_count; k++) {
772 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
776 elog(ERROR,
"RASTER_covers: Could not test that the first raster covers the second raster");
780 PG_RETURN_BOOL(result);
int rt_raster_get_num_bands(rt_raster raster)
rt_errorstate rt_raster_covers(rt_raster rast1, int nband1, rt_raster rast2, int nband2, int *covers)
Return ES_ERROR if error occurred in function.
#define POSTGIS_RT_DEBUGF(level, msg,...)
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.