675 const uint32_t set_count = 2;
677 int pgrastpos[2] = {-1, -1};
679 uint32_t bandindex[2] = {0};
680 uint32_t hasbandindex[2] = {0};
689 for (i = 0, j = 0; i < set_count; i++) {
691 if (PG_ARGISNULL(j)) {
692 for (k = 0; k < i; k++) {
694 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
698 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
705 for (k = 0; k <= i; k++) {
708 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
710 elog(ERROR,
"RASTER_covers: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
717 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
719 for (k = 0; k < i; k++) {
721 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
727 if (!PG_ARGISNULL(j)) {
728 bandindex[i] = PG_GETARG_INT32(j);
729 if (bandindex[i] < 1 || bandindex[i] > numBands) {
730 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
732 for (k = 0; k < i; k++) {
734 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
749 (hasbandindex[0] && !hasbandindex[1]) ||
750 (!hasbandindex[0] && hasbandindex[1])
752 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
753 for (k = 0; k < set_count; k++) {
755 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
762 for (k = 0; k < set_count; k++) {
764 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
766 elog(ERROR,
"The two rasters provided have different SRIDs");
771 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
772 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
775 for (k = 0; k < set_count; k++) {
777 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
781 elog(ERROR,
"RASTER_covers: Could not test that the first raster covers the second raster");
char result[OUT_DOUBLE_BUFFER_SIZE]
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_errorstate rt_raster_covers(rt_raster rast1, int nband1, rt_raster rast2, int nband2, int *covers)
Return ES_ERROR if error occurred in function.
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
#define POSTGIS_RT_DEBUGF(level, msg,...)