318 const uint32_t set_count = 2;
320 int pgrastpos[2] = {-1, -1};
322 uint32_t bandindex[2] = {0};
323 uint32_t hasbandindex[2] = {0};
332 for (i = 0, j = 0; i < set_count; i++) {
334 if (PG_ARGISNULL(j)) {
335 for (k = 0; k < i; k++) {
337 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
341 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
348 for (k = 0; k <= i; k++) {
351 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
353 elog(ERROR,
"RASTER_touches: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
360 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
362 for (k = 0; k < i; k++) {
364 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
370 if (!PG_ARGISNULL(j)) {
371 bandindex[i] = PG_GETARG_INT32(j);
372 if (bandindex[i] < 1 || bandindex[i] > numBands) {
373 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
375 for (k = 0; k < i; k++) {
377 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
392 (hasbandindex[0] && !hasbandindex[1]) ||
393 (!hasbandindex[0] && hasbandindex[1])
395 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
396 for (k = 0; k < set_count; k++) {
398 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
405 for (k = 0; k < set_count; k++) {
407 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
409 elog(ERROR,
"The two rasters provided have different SRIDs");
414 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
415 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
418 for (k = 0; k < set_count; k++) {
420 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
424 elog(ERROR,
"RASTER_touches: Could not test for touch on the two rasters");
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_touches(rt_raster rast1, int nband1, rt_raster rast2, int nband2, int *touches)
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,...)