554 int pgrastpos[2] = {-1, -1};
566 for (i = 0, j = 0; i < set_count; i++) {
568 if (PG_ARGISNULL(j)) {
569 for (k = 0; k < i; k++) {
571 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
575 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
582 for (k = 0; k <= i; k++) {
585 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
587 elog(ERROR,
"RASTER_containsProperly: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
594 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
596 for (k = 0; k < i; k++) {
598 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
604 if (!PG_ARGISNULL(j)) {
605 bandindex[i] = PG_GETARG_INT32(j);
606 if (bandindex[i] < 1 || bandindex[i] > numBands) {
607 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
609 for (k = 0; k < i; k++) {
611 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
626 (hasbandindex[0] && !hasbandindex[1]) ||
627 (!hasbandindex[0] && hasbandindex[1])
629 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
630 for (k = 0; k < set_count; k++) {
632 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
639 for (k = 0; k < set_count; k++) {
641 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
643 elog(ERROR,
"The two rasters provided have different SRIDs");
648 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
649 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
652 for (k = 0; k < set_count; k++) {
654 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
658 elog(ERROR,
"RASTER_containsProperly: Could not test that the first raster contains properly the second raster");
662 PG_RETURN_BOOL(result);
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
rt_errorstate rt_raster_contains_properly(rt_raster rast1, int nband1, rt_raster rast2, int nband2, int *contains)
Return ES_ERROR if error occurred in function.
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,...)