1052 int pgrastpos[2] = {-1, -1};
1065 for (i = 0, j = 0; i < set_count; i++) {
1067 if (PG_ARGISNULL(j)) {
1068 for (k = 0; k < i; k++) {
1070 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1074 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
1081 for (k = 0; k <= i; k++) {
1084 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1086 elog(ERROR,
"RASTER_dfullywithin: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
1093 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
1095 for (k = 0; k < i; k++) {
1097 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1103 if (!PG_ARGISNULL(j)) {
1104 bandindex[i] = PG_GETARG_INT32(j);
1105 if (bandindex[i] < 1 || bandindex[i] > numBands) {
1106 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
1108 for (k = 0; k < i; k++) {
1110 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1114 hasbandindex[i] = 1;
1117 hasbandindex[i] = 0;
1124 if (PG_ARGISNULL(4)) {
1125 elog(NOTICE,
"Distance cannot be NULL. Returning NULL");
1126 for (k = 0; k < set_count; k++) {
1128 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1135 elog(NOTICE,
"Distance cannot be less than zero. Returning NULL");
1136 for (k = 0; k < set_count; k++) {
1138 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1145 (hasbandindex[0] && !hasbandindex[1]) ||
1146 (!hasbandindex[0] && hasbandindex[1])
1148 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
1149 for (k = 0; k < set_count; k++) {
1151 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1158 for (k = 0; k < set_count; k++) {
1160 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1162 elog(ERROR,
"The two rasters provided have different SRIDs");
1167 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
1168 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
1172 for (k = 0; k < set_count; k++) {
1174 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1178 elog(ERROR,
"RASTER_dfullywithin: Could not test that the two rasters are fully within the specified distance of each other");
1182 PG_RETURN_BOOL(result);
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.
Datum distance(PG_FUNCTION_ARGS)
#define POSTGIS_RT_DEBUGF(level, msg,...)