794 const uint32_t set_count = 2;
796 int pgrastpos[2] = {-1, -1};
798 uint32_t bandindex[2] = {0};
799 uint32_t hasbandindex[2] = {0};
808 for (i = 0, j = 0; i < set_count; i++) {
810 if (PG_ARGISNULL(j)) {
811 for (k = 0; k < i; k++) {
813 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
817 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
824 for (k = 0; k <= i; k++) {
827 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
829 elog(ERROR,
"RASTER_coveredby: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
836 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
838 for (k = 0; k < i; k++) {
840 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
846 if (!PG_ARGISNULL(j)) {
847 bandindex[i] = PG_GETARG_INT32(j);
848 if (bandindex[i] < 1 || bandindex[i] > numBands) {
849 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
851 for (k = 0; k < i; k++) {
853 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
868 (hasbandindex[0] && !hasbandindex[1]) ||
869 (!hasbandindex[0] && hasbandindex[1])
871 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
872 for (k = 0; k < set_count; k++) {
874 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
881 for (k = 0; k < set_count; k++) {
883 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
885 elog(ERROR,
"The two rasters provided have different SRIDs");
890 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
891 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
894 for (k = 0; k < set_count; k++) {
896 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
900 elog(ERROR,
"RASTER_coveredby: Could not test that the first raster is covered by 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.
rt_errorstate rt_raster_coveredby(rt_raster rast1, int nband1, rt_raster rast2, int nband2, int *coveredby)
Return ES_ERROR if error occurred in function.
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,...)