Skip to content

Commit

Permalink
Merge pull request #4381 from rouault/gtiff_grid_name_improvement
Browse files Browse the repository at this point in the history
Debugging/internals: append sub-grid index to grid name when opening a multi-grid TIFF file
  • Loading branch information
rouault authored Jan 17, 2025
2 parents 27cf3a9 + ad8bb71 commit 942cc65
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/grids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,15 @@ std::unique_ptr<GTiffGrid> 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;
}

Expand Down
1 change: 1 addition & 0 deletions src/grids.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 942cc65

Please sign in to comment.