551 const int set_count = 2;
553 int pgrastpos[2] = {-1, -1};
565 for (i = 0, j = 0; i < set_count; i++) {
567 if (PG_ARGISNULL(j)) {
568 for (k = 0; k < i; k++) {
570 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
574 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
581 for (k = 0; k <= i; k++) {
584 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
586 elog(ERROR,
"RASTER_containsProperly: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
593 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
595 for (k = 0; k < i; k++) {
597 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
603 if (!PG_ARGISNULL(j)) {
604 bandindex[i] = PG_GETARG_INT32(j);
605 if (bandindex[i] < 1 || bandindex[i] > numBands) {
606 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
608 for (k = 0; k < i; k++) {
610 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
625 (hasbandindex[0] && !hasbandindex[1]) ||
626 (!hasbandindex[0] && hasbandindex[1])
628 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
629 for (k = 0; k < set_count; k++) {
631 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
638 for (k = 0; k < set_count; k++) {
640 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
642 elog(ERROR,
"The two rasters provided have different SRIDs");
647 rast[0], (hasbandindex[0] ? bandindex[0] - 1 : -1),
648 rast[1], (hasbandindex[1] ? bandindex[1] - 1 : -1),
651 for (k = 0; k < set_count; k++) {
653 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
657 elog(ERROR,
"RASTER_containsProperly: Could not test that the first raster contains properly the second raster");
661 PG_RETURN_BOOL(result);
int rt_raster_get_num_bands(rt_raster raster)
#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.
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.