435 int pgrastpos[2] = {-1, -1};
447 for (i = 0, j = 0; i < set_count; i++) {
449 if (PG_ARGISNULL(j)) {
450 for (k = 0; k < i; k++) {
452 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
456 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
463 for (k = 0; k <= i; k++) {
466 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
468 elog(ERROR,
"RASTER_contains: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
475 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
477 for (k = 0; k < i; k++) {
479 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
485 if (!PG_ARGISNULL(j)) {
486 bandindex[i] = PG_GETARG_INT32(j);
487 if (bandindex[i] < 1 || bandindex[i] > numBands) {
488 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
490 for (k = 0; k < i; k++) {
492 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
507 (hasbandindex[0] && !hasbandindex[1]) ||
508 (!hasbandindex[0] && hasbandindex[1])
510 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
511 for (k = 0; k < set_count; k++) {
513 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
520 for (k = 0; k < set_count; k++) {
522 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
524 elog(ERROR,
"The two rasters provided have different SRIDs");
529 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
530 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
533 for (k = 0; k < set_count; k++) {
535 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
539 elog(ERROR,
"RASTER_contains: Could not test that the first raster contains the second raster");
543 PG_RETURN_BOOL(result);
rt_errorstate rt_raster_contains(rt_raster rast1, int nband1, rt_raster rast2, int nband2, int *contains)
Return ES_ERROR if error occurred in function.
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.
uint16_t rt_raster_get_num_bands(rt_raster raster)
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
#define POSTGIS_RT_DEBUGF(level, msg,...)