Skip to content

Commit 942cc65

Browse files
authored
Merge pull request #4381 from rouault/gtiff_grid_name_improvement
Debugging/internals: append sub-grid index to grid name when opening a multi-grid TIFF file
2 parents 27cf3a9 + ad8bb71 commit 942cc65

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/grids.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,15 @@ std::unique_ptr<GTiffGrid> GTiffDataset::nextGrid() {
13201320
m_ifdIdx++;
13211321
m_hasNextGrid = TIFFReadDirectory(m_hTIFF) != 0;
13221322
m_nextDirOffset = TIFFCurrentDirOffset(m_hTIFF);
1323+
1324+
// If the TIFF file contains multiple grids, append the index of the grid
1325+
// in the grid name to help debugging.
1326+
if (m_ifdIdx >= 2 || m_hasNextGrid) {
1327+
ret->m_name += " (index ";
1328+
ret->m_name += std::to_string(m_ifdIdx); // 1-based
1329+
ret->m_name += ')';
1330+
}
1331+
13231332
return ret;
13241333
}
13251334

src/grids.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct ExtentAndRes {
5959

6060
class PROJ_GCC_DLL Grid {
6161
protected:
62+
friend class GTiffDataset;
6263
std::string m_name;
6364
int m_width;
6465
int m_height;

0 commit comments

Comments
 (0)