aboutsummaryrefslogtreecommitdiff
path: root/src/grids.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-03-07 00:30:19 +0100
committerEven Rouault <even.rouault@spatialys.com>2021-03-07 00:30:19 +0100
commit8d786107bd0bf756674319dfc357f121873d9e76 (patch)
tree6b0937c8eeb685c0a1a82e112ec9f41e004df28e /src/grids.cpp
parenta14026d71582c5a913e9266a36ec0693ab376cf0 (diff)
downloadPROJ-8d786107bd0bf756674319dfc357f121873d9e76.tar.gz
PROJ-8d786107bd0bf756674319dfc357f121873d9e76.zip
insertIntoHierarchy(): avoid confusing cppcheck about potential use of moved grid
Diffstat (limited to 'src/grids.cpp')
-rw-r--r--src/grids.cpp31
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