Skip to content

Commit f82a101

Browse files
committed
Fix red main CI failures
1 parent 0482d07 commit f82a101

3 files changed

Lines changed: 23 additions & 15 deletions

File tree

raster/rt_core/rt_warp.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ rt_raster rt_raster_gdal_warp(
163163
) {
164164
CPLErr cplerr;
165165
char *dst_options[] = {"SUBCLASS=VRTWarpedDataset", NULL};
166+
const char *init_dest_nodata_option = "INIT_DEST=NO_DATA";
167+
#if POSTGIS_GDAL_VERSION >= 30302
168+
const char *unified_src_nodata_option = "UNIFIED_SRC_NODATA=PARTIAL";
169+
#else
170+
const char *unified_src_nodata_option = "UNIFIED_SRC_NODATA=NO";
171+
#endif
166172
_rti_warp_arg arg = NULL;
167173

168174
int nodata_count = 0;
@@ -197,6 +203,7 @@ rt_raster rt_raster_gdal_warp(
197203
int numBands = 0;
198204
int nodata_pos = 0;
199205
int data_pos = 0;
206+
int use_init_dest_nodata = 0;
200207

201208
int subspatial = 0;
202209

@@ -865,17 +872,21 @@ rt_raster rt_raster_gdal_warp(
865872
arg->wopts->hDstDS = arg->dst.ds;
866873
arg->wopts->pfnTransformer = arg->transform.func;
867874
arg->wopts->pTransformerArg = arg->transform.arg.transform;
868-
arg->wopts->papszWarpOptions = (char **) CPLMalloc(sizeof(char *) * 3);
869-
arg->wopts->papszWarpOptions[0] = (char *) CPLMalloc(sizeof(char) * (strlen("INIT_DEST=NO_DATA") + 1));
870-
strcpy(arg->wopts->papszWarpOptions[0], "INIT_DEST=NO_DATA");
871-
#if POSTGIS_GDAL_VERSION >= 30302
872-
arg->wopts->papszWarpOptions[1] = (char *) CPLMalloc(sizeof(char) * (strlen("UNIFIED_SRC_NODATA=PARTIAL") + 1));
873-
strcpy(arg->wopts->papszWarpOptions[1], "UNIFIED_SRC_NODATA=PARTIAL");
874-
#else
875-
arg->wopts->papszWarpOptions[1] = (char *) CPLMalloc(sizeof(char) * (strlen("UNIFIED_SRC_NODATA=NO") + 1));
876-
strcpy(arg->wopts->papszWarpOptions[1], "UNIFIED_SRC_NODATA=NO");
877-
#endif
878-
arg->wopts->papszWarpOptions[2] = NULL;
875+
/*
876+
* GDAL 3.11 warns, and later treats as an error, when INIT_DEST=NO_DATA
877+
* is requested without destination nodata values for every band.
878+
*/
879+
use_init_dest_nodata = numBands > 0 && nodata_count == numBands;
880+
arg->wopts->papszWarpOptions =
881+
(char **) CPLMalloc(sizeof(char *) * (use_init_dest_nodata ? 3 : 2));
882+
i = 0;
883+
if (use_init_dest_nodata) {
884+
arg->wopts->papszWarpOptions[i] = (char *) CPLMalloc(sizeof(char) * (strlen(init_dest_nodata_option) + 1));
885+
strcpy(arg->wopts->papszWarpOptions[i++], init_dest_nodata_option);
886+
}
887+
arg->wopts->papszWarpOptions[i] = (char *) CPLMalloc(sizeof(char) * (strlen(unified_src_nodata_option) + 1));
888+
strcpy(arg->wopts->papszWarpOptions[i++], unified_src_nodata_option);
889+
arg->wopts->papszWarpOptions[i] = NULL;
879890

880891
/* band mapping */
881892
arg->wopts->nBandCount = numBands;
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# Exercise raster-only long maintenance actions and constraint creation.
21
--add-constraints --vacuum --analyze

regress/loader/LongOptions.opts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
# Exercise the public long action names as one loader invocation:
2-
# drop, create-if-missing, load, idempotent index, no transaction, and analyze.
3-
--drop-table --create-table --load-data --create-index --if-not-exists --no-transaction --no-analyze --analyze
1+
--drop-table --create-table --load-data --create-index --if-not-exists --no-transaction --analyze

0 commit comments

Comments
 (0)