diff options
Diffstat (limited to 'src/grids.cpp')
| -rw-r--r-- | src/grids.cpp | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/src/grids.cpp b/src/grids.cpp index ce0f6b76..3bde3cad 100644 --- a/src/grids.cpp +++ b/src/grids.cpp @@ -1140,7 +1140,7 @@ insertIntoHierarchy(PJ_CONTEXT *ctx, std::unique_ptr<GridType> &&grid, } mapGrids[gridName] = grid.get(); } - bool gridInserted = false; + if (!parentName.empty()) { auto iter = mapGrids.find(parentName); if (iter == mapGrids.end()) { @@ -1151,7 +1151,7 @@ insertIntoHierarchy(PJ_CONTEXT *ctx, std::unique_ptr<GridType> &&grid, } else { if (iter->second->extentAndRes().contains(extent)) { iter->second->m_children.emplace_back(std::move(grid)); - gridInserted = true; + return; } else { pj_log(ctx, PJ_LOG_DEBUG, "Grid %s refers to parent %s, but its extent is " @@ -1161,27 +1161,22 @@ insertIntoHierarchy(PJ_CONTEXT *ctx, std::unique_ptr<GridType> &&grid, } } else if (!gridName.empty()) { topGrids.emplace_back(std::move(grid)); - gridInserted = true; + return; } // Fallback to analyzing spatial extents - if (!gridInserted) { - for (const auto &candidateParent : topGrids) { - const auto &candidateParentExtent = candidateParent->extentAndRes(); - if (candidateParentExtent.contains(extent)) { - static_cast<GridType *>(candidateParent.get()) - ->insertGrid(ctx, std::move(grid)); - gridInserted = true; - break; - } else if (candidateParentExtent.intersects(extent)) { - pj_log(ctx, PJ_LOG_DEBUG, - "Partially intersecting grids found!"); - } - } - if (!gridInserted) { - topGrids.emplace_back(std::move(grid)); + for (const auto &candidateParent : topGrids) { + const auto &candidateParentExtent = candidateParent->extentAndRes(); + if (candidateParentExtent.contains(extent)) { + static_cast<GridType *>(candidateParent.get()) + ->insertGrid(ctx, std::move(grid)); + return; + } else if (candidateParentExtent.intersects(extent)) { + pj_log(ctx, PJ_LOG_DEBUG, "Partially intersecting grids found!"); } } + + topGrids.emplace_back(std::move(grid)); } #ifdef TIFF_ENABLED |
