32 #include <utils/builtins.h>
34 #include "../../postgis_config.h"
36 #include "lwgeom_pg.h"
80 const uint32_t set_count = 2;
82 int pgrastpos[2] = {-1, -1};
84 uint32_t bandindex[2] = {0};
85 uint32_t hasbandindex[2] = {0};
94 for (i = 0, j = 0; i < set_count; i++) {
96 if (PG_ARGISNULL(j)) {
97 for (k = 0; k < i; k++) {
99 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
103 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
110 for (k = 0; k <= i; k++) {
113 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
115 elog(ERROR,
"RASTER_intersects: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
122 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
124 for (k = 0; k < i; k++) {
126 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
132 if (!PG_ARGISNULL(j)) {
133 bandindex[i] = PG_GETARG_INT32(j);
134 if (bandindex[i] < 1 || bandindex[i] > numBands) {
135 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
137 for (k = 0; k < i; k++) {
139 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
154 (hasbandindex[0] && !hasbandindex[1]) ||
155 (!hasbandindex[0] && hasbandindex[1])
157 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
158 for (k = 0; k < set_count; k++) {
160 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
167 for (k = 0; k < set_count; k++) {
169 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
171 elog(ERROR,
"The two rasters provided have different SRIDs");
176 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
177 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
180 for (k = 0; k < set_count; k++) {
182 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
186 elog(ERROR,
"RASTER_intersects: Could not test for intersection on the two rasters");
199 const uint32_t set_count = 2;
201 int pgrastpos[2] = {-1, -1};
203 uint32_t bandindex[2] = {0};
204 uint32_t hasbandindex[2] = {0};
213 for (i = 0, j = 0; i < set_count; i++) {
215 if (PG_ARGISNULL(j)) {
216 for (k = 0; k < i; k++) {
218 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
222 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
229 for (k = 0; k <= i; k++) {
232 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
234 elog(ERROR,
"RASTER_overlaps: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
241 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
243 for (k = 0; k < i; k++) {
245 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
251 if (!PG_ARGISNULL(j)) {
252 bandindex[i] = PG_GETARG_INT32(j);
253 if (bandindex[i] < 1 || bandindex[i] > numBands) {
254 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
256 for (k = 0; k < i; k++) {
258 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
273 (hasbandindex[0] && !hasbandindex[1]) ||
274 (!hasbandindex[0] && hasbandindex[1])
276 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
277 for (k = 0; k < set_count; k++) {
279 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
286 for (k = 0; k < set_count; k++) {
288 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
290 elog(ERROR,
"The two rasters provided have different SRIDs");
295 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
296 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
299 for (k = 0; k < set_count; k++) {
301 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
305 elog(ERROR,
"RASTER_overlaps: Could not test for overlap on the two rasters");
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");
437 const uint32_t set_count = 2;
439 int pgrastpos[2] = {-1, -1};
441 uint32_t bandindex[2] = {0};
442 uint32_t hasbandindex[2] = {0};
451 for (i = 0, j = 0; i < set_count; i++) {
453 if (PG_ARGISNULL(j)) {
454 for (k = 0; k < i; k++) {
456 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
460 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
467 for (k = 0; k <= i; k++) {
470 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
472 elog(ERROR,
"RASTER_contains: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
479 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
481 for (k = 0; k < i; k++) {
483 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
489 if (!PG_ARGISNULL(j)) {
490 bandindex[i] = PG_GETARG_INT32(j);
491 if (bandindex[i] < 1 || bandindex[i] > numBands) {
492 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
494 for (k = 0; k < i; k++) {
496 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
511 (hasbandindex[0] && !hasbandindex[1]) ||
512 (!hasbandindex[0] && hasbandindex[1])
514 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
515 for (k = 0; k < set_count; k++) {
517 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
524 for (k = 0; k < set_count; k++) {
526 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
528 elog(ERROR,
"The two rasters provided have different SRIDs");
533 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
534 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
537 for (k = 0; k < set_count; k++) {
539 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
543 elog(ERROR,
"RASTER_contains: Could not test that the first raster contains the second raster");
556 const uint32_t set_count = 2;
558 int pgrastpos[2] = {-1, -1};
560 uint32_t bandindex[2] = {0};
561 uint32_t hasbandindex[2] = {0};
570 for (i = 0, j = 0; i < set_count; i++) {
572 if (PG_ARGISNULL(j)) {
573 for (k = 0; k < i; k++) {
575 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
579 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
586 for (k = 0; k <= i; k++) {
589 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
591 elog(ERROR,
"RASTER_containsProperly: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
598 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
600 for (k = 0; k < i; k++) {
602 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
608 if (!PG_ARGISNULL(j)) {
609 bandindex[i] = PG_GETARG_INT32(j);
610 if (bandindex[i] < 1 || bandindex[i] > numBands) {
611 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
613 for (k = 0; k < i; k++) {
615 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
630 (hasbandindex[0] && !hasbandindex[1]) ||
631 (!hasbandindex[0] && hasbandindex[1])
633 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
634 for (k = 0; k < set_count; k++) {
636 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
643 for (k = 0; k < set_count; k++) {
645 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
647 elog(ERROR,
"The two rasters provided have different SRIDs");
652 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
653 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
656 for (k = 0; k < set_count; k++) {
658 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
662 elog(ERROR,
"RASTER_containsProperly: Could not test that the first raster contains properly the second raster");
675 const uint32_t set_count = 2;
677 int pgrastpos[2] = {-1, -1};
679 uint32_t bandindex[2] = {0};
680 uint32_t hasbandindex[2] = {0};
689 for (i = 0, j = 0; i < set_count; i++) {
691 if (PG_ARGISNULL(j)) {
692 for (k = 0; k < i; k++) {
694 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
698 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
705 for (k = 0; k <= i; k++) {
708 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
710 elog(ERROR,
"RASTER_covers: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
717 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
719 for (k = 0; k < i; k++) {
721 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
727 if (!PG_ARGISNULL(j)) {
728 bandindex[i] = PG_GETARG_INT32(j);
729 if (bandindex[i] < 1 || bandindex[i] > numBands) {
730 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
732 for (k = 0; k < i; k++) {
734 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
749 (hasbandindex[0] && !hasbandindex[1]) ||
750 (!hasbandindex[0] && hasbandindex[1])
752 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
753 for (k = 0; k < set_count; k++) {
755 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
762 for (k = 0; k < set_count; k++) {
764 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
766 elog(ERROR,
"The two rasters provided have different SRIDs");
771 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
772 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
775 for (k = 0; k < set_count; k++) {
777 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
781 elog(ERROR,
"RASTER_covers: Could not test that the first raster covers the second raster");
794 const uint32_t set_count = 2;
796 int pgrastpos[2] = {-1, -1};
798 uint32_t bandindex[2] = {0};
799 uint32_t hasbandindex[2] = {0};
808 for (i = 0, j = 0; i < set_count; i++) {
810 if (PG_ARGISNULL(j)) {
811 for (k = 0; k < i; k++) {
813 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
817 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
824 for (k = 0; k <= i; k++) {
827 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
829 elog(ERROR,
"RASTER_coveredby: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
836 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
838 for (k = 0; k < i; k++) {
840 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
846 if (!PG_ARGISNULL(j)) {
847 bandindex[i] = PG_GETARG_INT32(j);
848 if (bandindex[i] < 1 || bandindex[i] > numBands) {
849 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
851 for (k = 0; k < i; k++) {
853 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
868 (hasbandindex[0] && !hasbandindex[1]) ||
869 (!hasbandindex[0] && hasbandindex[1])
871 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
872 for (k = 0; k < set_count; k++) {
874 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
881 for (k = 0; k < set_count; k++) {
883 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
885 elog(ERROR,
"The two rasters provided have different SRIDs");
890 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
891 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
894 for (k = 0; k < set_count; k++) {
896 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
900 elog(ERROR,
"RASTER_coveredby: Could not test that the first raster is covered by the second raster");
913 const uint32_t set_count = 2;
915 int pgrastpos[2] = {-1, -1};
917 uint32_t bandindex[2] = {0};
918 uint32_t hasbandindex[2] = {0};
928 for (i = 0, j = 0; i < set_count; i++) {
930 if (PG_ARGISNULL(j)) {
931 for (k = 0; k < i; k++) {
933 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
937 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
944 for (k = 0; k <= i; k++) {
947 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
949 elog(ERROR,
"RASTER_dwithin: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
956 elog(NOTICE,
"The %s raster provided has no bands", i < 1 ?
"first" :
"second");
958 for (k = 0; k < i; k++) {
960 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
966 if (!PG_ARGISNULL(j)) {
967 bandindex[i] = PG_GETARG_INT32(j);
968 if (bandindex[i] < 1 || bandindex[i] > numBands) {
969 elog(NOTICE,
"Invalid band index (must use 1-based) for the %s raster. Returning NULL", i < 1 ?
"first" :
"second");
971 for (k = 0; k < i; k++) {
973 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
987 if (PG_ARGISNULL(4)) {
988 elog(NOTICE,
"Distance cannot be NULL. Returning NULL");
989 for (k = 0; k < set_count; k++) {
991 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
998 elog(NOTICE,
"Distance cannot be less than zero. Returning NULL");
999 for (k = 0; k < set_count; k++) {
1001 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1008 (hasbandindex[0] && !hasbandindex[1]) ||
1009 (!hasbandindex[0] && hasbandindex[1])
1011 elog(NOTICE,
"Missing band index. Band indices must be provided for both rasters if any one is provided");
1012 for (k = 0; k < set_count; k++) {
1014 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1021 for (k = 0; k < set_count; k++) {
1023 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1025 elog(ERROR,
"The two rasters provided have different SRIDs");
1030 rast[0], (hasbandindex[0] ? (
int)bandindex[0] - 1 : -1),
1031 rast[1], (hasbandindex[1] ? (
int)bandindex[1] - 1 : -1),
1035 for (k = 0; k < set_count; k++) {
1037 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1041 elog(ERROR,
"RASTER_dwithin: Could not test that the two rasters are within the specified distance of each other");
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");
1195 const uint32_t set_count = 2;
1197 int pgrastpos[2] = {-1, -1};
1205 char *reason = NULL;
1207 for (i = 0, j = 0; i < set_count; i++) {
1209 if (PG_ARGISNULL(j)) {
1210 for (k = 0; k < i; k++) {
1212 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1223 for (k = 0; k <= i; k++) {
1226 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1228 elog(ERROR,
"RASTER_sameAlignment: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
1239 for (k = 0; k < set_count; k++) {
1241 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1245 elog(ERROR,
"RASTER_sameAlignment: Could not test for alignment on the two rasters");
1250 if (reason != NULL && !aligned)
1251 elog(NOTICE,
"%s", reason);
1253 PG_RETURN_BOOL(aligned);
1262 const uint32_t set_count = 2;
1264 int pgrastpos[2] = {-1, -1};
1272 char *reason = NULL;
1275 for (i = 0, j = 0; i < set_count; i++) {
1277 if (PG_ARGISNULL(j)) {
1278 for (k = 0; k < i; k++) {
1280 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1291 for (k = 0; k <= i; k++) {
1294 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1296 elog(ERROR,
"RASTER_notSameAlignmentReason: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
1307 for (k = 0; k < set_count; k++) {
1309 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1313 elog(ERROR,
"RASTER_notSameAlignmentReason: Could not test for alignment on the two rasters");
1317 result = cstring_to_text(reason);
1318 PG_RETURN_TEXT_P(
result);
1327 #if POSTGIS_GEOS_VERSION < 31400
1328 elog(ERROR,
"The GEOS version this PostGIS binary "
1329 "was compiled against (%d) does not include the "
1330 "'GEOSGridIntersectionFractions' function (3.14.0+ required)",
1345 elog(ERROR,
"ST_IntersectionFractions: Unsupported geometry type '%s'",
lwtype_name(gtype));
1348 rast_out = rt_raster_intersection_fractions(rast_in, lwg);
1350 elog(ERROR,
"ST_IntersectionFractions: calculation returned NULL");
1357 SET_VARSIZE(pgrast_out, pgrast_out->
size);
1358 PG_RETURN_POINTER(pgrast_out);
char result[OUT_DOUBLE_BUFFER_SIZE]
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
rt_errorstate rt_raster_contains(rt_raster rast1, int nband1, rt_raster rast2, int nband2, int *contains)
Return ES_ERROR if error occurred in function.
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.
rt_errorstate rt_raster_contains_properly(rt_raster rast1, int nband1, rt_raster rast2, int nband2, int *contains)
Return ES_ERROR if error occurred in function.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
rt_errorstate rt_raster_intersects(rt_raster rast1, int nband1, rt_raster rast2, int nband2, int *intersects)
Return ES_ERROR if error occurred in function.
rt_errorstate rt_raster_coveredby(rt_raster rast1, int nband1, rt_raster rast2, int nband2, int *coveredby)
Return ES_ERROR if error occurred in function.
void * rt_raster_serialize(rt_raster raster)
Return this raster in serialized form.
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.
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_errorstate rt_raster_within_distance(rt_raster rast1, int nband1, rt_raster rast2, int nband2, double distance, int *dwithin)
Return ES_ERROR if error occurred in function.
rt_errorstate rt_raster_same_alignment(rt_raster rast1, rt_raster rast2, int *aligned, char **reason)
rt_errorstate rt_raster_covers(rt_raster rast1, int nband1, rt_raster rast2, int nband2, int *covers)
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.
static uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
static double distance(double x1, double y1, double x2, double y2)
PG_FUNCTION_INFO_V1(RASTER_intersects)
See if two rasters intersect.
Datum RASTER_coveredby(PG_FUNCTION_ARGS)
Datum RASTER_sameAlignment(PG_FUNCTION_ARGS)
Datum RASTER_containsProperly(PG_FUNCTION_ARGS)
Datum RASTER_dfullywithin(PG_FUNCTION_ARGS)
Datum RASTER_notSameAlignmentReason(PG_FUNCTION_ARGS)
Datum RASTER_dwithin(PG_FUNCTION_ARGS)
Datum RASTER_contains(PG_FUNCTION_ARGS)
Datum RASTER_intersectionFractions(PG_FUNCTION_ARGS)
Datum RASTER_intersects(PG_FUNCTION_ARGS)
Datum RASTER_covers(PG_FUNCTION_ARGS)
Datum RASTER_touches(PG_FUNCTION_ARGS)
Datum RASTER_overlaps(PG_FUNCTION_ARGS)
#define POSTGIS_RT_DEBUGF(level, msg,...)
#define POSTGIS_GEOS_VERSION