1049 const int set_count = 2;
1051 int pgrastpos[2] = {-1, -1};
1064 for (i = 0, j = 0; i < set_count; i++) {
1066 if (PG_ARGISNULL(j)) {
1067 for (k = 0; k < i; k++) {
1069 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1073 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
1080 for (k = 0; k <= i; k++) {
1083 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1085 elog(ERROR,
"RASTER_dfullywithin: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
1092 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
1094 for (k = 0; k < i; k++) {
1096 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1102 if (!PG_ARGISNULL(j)) {
1103 bandindex[i] = PG_GETARG_INT32(j);
1104 if (bandindex[i] < 1 || bandindex[i] > numBands) {
1105 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
1107 for (k = 0; k < i; k++) {
1109 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1113 hasbandindex[i] = 1;
1116 hasbandindex[i] = 0;
1123 if (PG_ARGISNULL(4)) {
1124 elog(NOTICE,
"Distance cannot be NULL. Returning NULL");
1125 for (k = 0; k < set_count; k++) {
1127 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1132 distance = PG_GETARG_FLOAT8(4);
1134 elog(NOTICE,
"Distance cannot be less than zero. Returning NULL");
1135 for (k = 0; k < set_count; k++) {
1137 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1144 (hasbandindex[0] && !hasbandindex[1]) ||
1145 (!hasbandindex[0] && hasbandindex[1])
1147 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
1148 for (k = 0; k < set_count; k++) {
1150 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1157 for (k = 0; k < set_count; k++) {
1159 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1161 elog(ERROR,
"The two rasters provided have different SRIDs");
1166 rast[0], (hasbandindex[0] ? bandindex[0] - 1 : -1),
1167 rast[1], (hasbandindex[1] ? bandindex[1] - 1 : -1),
1171 for (k = 0; k < set_count; k++) {
1173 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1177 elog(ERROR,
"RASTER_dfullywithin: Could not test that the two rasters are fully within the specified distance of each other");
1181 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.
Datum distance(PG_FUNCTION_ARGS)
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.
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.