From 648add692701007aaa34a5e4b857a6334e0f399a Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 4 Nov 2024 13:34:30 +0100 Subject: [PATCH 1/2] gcore/CMakeLists.txt: also install gdal_priv_templates.hpp --- gcore/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/gcore/CMakeLists.txt b/gcore/CMakeLists.txt index 08fe7e646b7b..bc710a7fcc65 100644 --- a/gcore/CMakeLists.txt +++ b/gcore/CMakeLists.txt @@ -210,6 +210,7 @@ target_public_header( gdal_typetraits.h gdal_adbc.h gdal_minmax_element.hpp + gdal_priv_templates.hpp # Required by gdal_minmax_element.hpp ) set(GDAL_DATA_FILES From 9164d9d55d2d81c4699ce3ee2fb3feaec998b86b Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 4 Nov 2024 13:31:56 +0100 Subject: [PATCH 2/2] gdal_minmax_element.hpp: fixes when vendoring with GDAL < 3.7 --- gcore/gdal_minmax_element.hpp | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/gcore/gdal_minmax_element.hpp b/gcore/gdal_minmax_element.hpp index 0da63649a06d..b6c30d2e509d 100644 --- a/gcore/gdal_minmax_element.hpp +++ b/gcore/gdal_minmax_element.hpp @@ -43,29 +43,6 @@ #endif #include "gdal_priv_templates.hpp" -#if GDAL_VERSION < GDAL_COMPUTE_VERSION(3, 10, 0) -// For vendoring in other applications -namespace GDAL_MINMAXELT_NS -{ -template inline bool GDALIsValueExactAs(double dfValue) -{ - return GDALIsValueInRange(dfValue) && - static_cast(static_cast(dfValue)) == dfValue; -} - -template <> inline bool GDALIsValueExactAs(double dfValue) -{ - return std::isnan(dfValue) || - (GDALIsValueInRange(dfValue) && - static_cast(static_cast(dfValue)) == dfValue); -} - -template <> inline bool GDALIsValueExactAs(double) -{ - return true; -} -} // namespace GDAL_MINMAXELT_NS -#endif namespace GDAL_MINMAXELT_NS { @@ -989,6 +966,7 @@ size_t extremum_element(const void *buffer, size_t nElts, GDALDataType eDT, { switch (eDT) { +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 7, 0) case GDT_Int8: { using T = int8_t; @@ -997,6 +975,7 @@ size_t extremum_element(const void *buffer, size_t nElts, GDALDataType eDT, static_cast(buffer), nElts, bHasNoData, bHasNoData ? static_cast(dfNoDataValue) : 0); } +#endif case GDT_Byte: { using T = uint8_t; @@ -1037,6 +1016,7 @@ size_t extremum_element(const void *buffer, size_t nElts, GDALDataType eDT, static_cast(buffer), nElts, bHasNoData, bHasNoData ? static_cast(dfNoDataValue) : 0); } +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 5, 0) case GDT_Int64: { using T = int64_t; @@ -1053,6 +1033,7 @@ size_t extremum_element(const void *buffer, size_t nElts, GDALDataType eDT, static_cast(buffer), nElts, bHasNoData, bHasNoData ? static_cast(dfNoDataValue) : 0); } +#endif case GDT_Float32: { using T = float; @@ -1330,6 +1311,7 @@ inline std::pair minmax_element(const void *buffer, { switch (eDT) { +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 7, 0) case GDT_Int8: { using T = int8_t; @@ -1338,6 +1320,7 @@ inline std::pair minmax_element(const void *buffer, static_cast(buffer), nElts, bHasNoData, bHasNoData ? static_cast(dfNoDataValue) : 0); } +#endif case GDT_Byte: { using T = uint8_t; @@ -1378,6 +1361,7 @@ inline std::pair minmax_element(const void *buffer, static_cast(buffer), nElts, bHasNoData, bHasNoData ? static_cast(dfNoDataValue) : 0); } +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 5, 0) case GDT_Int64: { using T = int64_t; @@ -1394,6 +1378,7 @@ inline std::pair minmax_element(const void *buffer, static_cast(buffer), nElts, bHasNoData, bHasNoData ? static_cast(dfNoDataValue) : 0); } +#endif case GDT_Float32: { using T = float;