Skip to content

Commit 2b0b1c5

Browse files
committed
Warper: add runtime warning when value changed to avoid colliding with dstnodata
1 parent 17a737f commit 2b0b1c5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

alg/gdalwarper.h

+2
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,8 @@ class CPL_DLL GDALWarpKernel
463463

464464
GWKTieStrategy eTieStrategy;
465465

466+
bool bWarnedAboutDstNoDataReplacement = false;
467+
466468
/*! @endcond */
467469

468470
GDALWarpKernel();

alg/gdalwarpkernel.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,19 @@ inline void AvoidNoData(const GDALWarpKernel *poWK, int iBand,
15611561
pDst[iDstOffset], std::numeric_limits<T>::max());
15621562
}
15631563
}
1564+
1565+
if (!poWK->bWarnedAboutDstNoDataReplacement)
1566+
{
1567+
const_cast<GDALWarpKernel *>(poWK)
1568+
->bWarnedAboutDstNoDataReplacement = true;
1569+
CPLError(CE_Warning, CPLE_AppDefined,
1570+
"Value %g in the source dataset has been changed to %g "
1571+
"in the destination dataset to avoid being treated as "
1572+
"NoData. To avoid this, select a different NoData value "
1573+
"for the destination dataset.",
1574+
poWK->padfDstNoDataReal[iBand],
1575+
static_cast<double>(pDst[iDstOffset]));
1576+
}
15641577
}
15651578
}
15661579

0 commit comments

Comments
 (0)