diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-03-07 11:57:33 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-07 11:57:33 +0100 |
| commit | 5b9d009293db4021b57a4949f467f2dd1081870a (patch) | |
| tree | f85526da58a867c77040906e0cd9013cb59e1d30 /src/grids.cpp | |
| parent | 5089106b18b3fd8ea4bf091901d6b74349095cd1 (diff) | |
| parent | 8d786107bd0bf756674319dfc357f121873d9e76 (diff) | |
| download | PROJ-5b9d009293db4021b57a4949f467f2dd1081870a.tar.gz PROJ-5b9d009293db4021b57a4949f467f2dd1081870a.zip | |
Merge pull request #2561 from rouault/cppcheck_fixes
Two Cppcheck fixes
Diffstat (limited to 'src/grids.cpp')
| -rw-r--r-- | src/grids.cpp | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/src/grids.cpp b/src/grids.cpp index 03a324f9..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 @@ -1799,7 +1794,6 @@ class NTv2GridSet : public HorizontalShiftGridSet { class NTv2Grid : public HorizontalShiftGrid { friend class NTv2GridSet; - std::string m_name; PJ_CONTEXT *m_ctx; // owned by the parent NTv2GridSet File *m_fp; // owned by the parent NTv2GridSet unsigned long long m_offset; @@ -1812,9 +1806,8 @@ class NTv2Grid : public HorizontalShiftGrid { NTv2Grid(const std::string &nameIn, PJ_CONTEXT *ctx, File *fp, unsigned long long offsetIn, bool mustSwapIn, int widthIn, int heightIn, const ExtentAndRes &extentIn) - : HorizontalShiftGrid(nameIn, widthIn, heightIn, extentIn), - m_name(nameIn), m_ctx(ctx), m_fp(fp), m_offset(offsetIn), - m_mustSwap(mustSwapIn) {} + : HorizontalShiftGrid(nameIn, widthIn, heightIn, extentIn), m_ctx(ctx), + m_fp(fp), m_offset(offsetIn), m_mustSwap(mustSwapIn) {} bool valueAt(int, int, bool, float &lonShift, float &latShift) const override; |
