diff --git a/src/grids.cpp b/src/grids.cpp index 624f2dfa13..09e9b9fe3d 100644 --- a/src/grids.cpp +++ b/src/grids.cpp @@ -1320,6 +1320,15 @@ std::unique_ptr GTiffDataset::nextGrid() { m_ifdIdx++; m_hasNextGrid = TIFFReadDirectory(m_hTIFF) != 0; m_nextDirOffset = TIFFCurrentDirOffset(m_hTIFF); + + // If the TIFF file contains multiple grids, append the index of the grid + // in the grid name to help debugging. + if (m_ifdIdx >= 2 || m_hasNextGrid) { + ret->m_name += " (index "; + ret->m_name += std::to_string(m_ifdIdx); // 1-based + ret->m_name += ')'; + } + return ret; } diff --git a/src/grids.hpp b/src/grids.hpp index a5e0d8c4c4..a7b5946976 100644 --- a/src/grids.hpp +++ b/src/grids.hpp @@ -59,6 +59,7 @@ struct ExtentAndRes { class PROJ_GCC_DLL Grid { protected: + friend class GTiffDataset; std::string m_name; int m_width; int m_height;