1054 const uint32_t set_count = 2;
1056 int pgrastpos[2] = {-1, -1};
1058 uint32_t bandindex[2] = {0};
1059 uint32_t hasbandindex[2] = {0};
1069 for (i = 0, j = 0; i < set_count; i++) {
1071 if (PG_ARGISNULL(j)) {
1072 for (k = 0; k < i; k++) {
1074 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1078 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
1085 for (k = 0; k <= i; k++) {
1088 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1090 elog(ERROR,
"RASTER_dfullywithin: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
1097 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
1099 for (k = 0; k < i; k++) {
1101 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1107 if (!PG_ARGISNULL(j)) {
1108 bandindex[i] = PG_GETARG_INT32(j);
1109 if (bandindex[i] < 1 || bandindex[i] > numBands) {
1110 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
1112 for (k = 0; k < i; k++) {
1114 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1118 hasbandindex[i] = 1;
1121 hasbandindex[i] = 0;
1128 if (PG_ARGISNULL(4)) {
1129 elog(NOTICE,
"Distance cannot be NULL. Returning NULL");
1130 for (k = 0; k < set_count; k++) {
1132 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1139 elog(NOTICE,
"Distance cannot be less than zero. Returning NULL");
1140 for (k = 0; k < set_count; k++) {
1142 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1149 (hasbandindex[0] && !hasbandindex[1]) ||
1150 (!hasbandindex[0] && hasbandindex[1])
1152 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
1153 for (k = 0; k < set_count; k++) {
1155 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1162 for (k = 0; k < set_count; k++) {
1164 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1166 elog(ERROR,
"The two rasters provided have different SRIDs");
1171 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
1172 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
1176 for (k = 0; k < set_count; k++) {
1178 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1182 elog(ERROR,
"RASTER_dfullywithin: Could not test that the two rasters are fully within the specified distance of each other");
char result[OUT_DOUBLE_BUFFER_SIZE]
rt_errorstate rt_raster_fully_within_distance(rt_raster rast1, int nband1, rt_raster rast2, int nband2, double distance, int *dfwithin)
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.
static double distance(double x1, double y1, double x2, double y2)
#define POSTGIS_RT_DEBUGF(level, msg,...)