Skip to content

Commit

Permalink
Warper: add runtime warning when value changed to avoid colliding wit…
Browse files Browse the repository at this point in the history
…h dstnodata
  • Loading branch information
rouault committed Jan 24, 2025
1 parent 17a737f commit 2b0b1c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions alg/gdalwarper.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ class CPL_DLL GDALWarpKernel

GWKTieStrategy eTieStrategy;

bool bWarnedAboutDstNoDataReplacement = false;

/*! @endcond */

GDALWarpKernel();
Expand Down
13 changes: 13 additions & 0 deletions alg/gdalwarpkernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,19 @@ inline void AvoidNoData(const GDALWarpKernel *poWK, int iBand,
pDst[iDstOffset], std::numeric_limits<T>::max());
}
}

if (!poWK->bWarnedAboutDstNoDataReplacement)
{
const_cast<GDALWarpKernel *>(poWK)
->bWarnedAboutDstNoDataReplacement = true;
CPLError(CE_Warning, CPLE_AppDefined,
"Value %g in the source dataset has been changed to %g "
"in the destination dataset to avoid being treated as "
"NoData. To avoid this, select a different NoData value "
"for the destination dataset.",
poWK->padfDstNoDataReal[iBand],
static_cast<double>(pDst[iDstOffset]));
}
}
}

Expand Down

0 comments on commit 2b0b1c5

Please sign in to comment.