197 int pgrastpos[2] = {-1, -1};
209 for (i = 0, j = 0; i < set_count; i++) {
211 if (PG_ARGISNULL(j)) {
212 for (k = 0; k < i; k++) {
214 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
218 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
225 for (k = 0; k <= i; k++) {
228 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
230 elog(ERROR,
"RASTER_overlaps: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
237 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
239 for (k = 0; k < i; k++) {
241 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
247 if (!PG_ARGISNULL(j)) {
248 bandindex[i] = PG_GETARG_INT32(j);
249 if (bandindex[i] < 1 || bandindex[i] > numBands) {
250 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
252 for (k = 0; k < i; k++) {
254 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
269 (hasbandindex[0] && !hasbandindex[1]) ||
270 (!hasbandindex[0] && hasbandindex[1])
272 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
273 for (k = 0; k < set_count; k++) {
275 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
282 for (k = 0; k < set_count; k++) {
284 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
286 elog(ERROR,
"The two rasters provided have different SRIDs");
291 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
292 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
295 for (k = 0; k < set_count; k++) {
297 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
301 elog(ERROR,
"RASTER_overlaps: Could not test for overlap on the two rasters");
305 PG_RETURN_BOOL(result);
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_overlaps(rt_raster rast1, int nband1, rt_raster rast2, int nband2, int *overlaps)
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,...)