diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-02-21 01:04:55 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-02-21 11:48:29 +0100 |
| commit | 5c691e7fec7c244b1a1a6b5ef97df2cf69e403df (patch) | |
| tree | 4c50fbf77320b61b3510a8bbec17b3be23c167aa /src | |
| parent | 6d6ee7fa7d35bf57d1781136102f971cb0ac33d2 (diff) | |
| download | PROJ-5c691e7fec7c244b1a1a6b5ef97df2cf69e403df.tar.gz PROJ-5c691e7fec7c244b1a1a6b5ef97df2cf69e403df.zip | |
projinfo: add information about missing grids
Diffstat (limited to 'src')
| -rw-r--r-- | src/apps/projinfo.cpp | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/src/apps/projinfo.cpp b/src/apps/projinfo.cpp index 094587e2..7e401887 100644 --- a/src/apps/projinfo.cpp +++ b/src/apps/projinfo.cpp @@ -464,11 +464,42 @@ static void outputObject( } } } + + auto op = dynamic_cast<CoordinateOperation *>(obj.get()); + if (op && dbContext && getenv("PROJINFO_NO_GRID_CHECK") == nullptr) { + try { + auto setGrids = op->gridsNeeded(dbContext); + bool firstWarning = true; + for (const auto &grid : setGrids) { + if (!grid.available) { + if (firstWarning) { + std::cout << std::endl; + firstWarning = false; + } + std::cout << "Grid " << grid.shortName + << " needed but not found on the system."; + if (!grid.packageName.empty()) { + std::cout << " Can be obtained from the " + << grid.packageName << " package"; + if (!grid.url.empty()) { + std::cout << " at " << grid.url; + } + } else if (!grid.url.empty()) { + std::cout << " Can be obtained at " << grid.url; + } + std::cout << std::endl; + } + } + } catch (const std::exception &e) { + std::cerr << "Error in gridsNeeded(): " << e.what() << std::endl; + } + } } // --------------------------------------------------------------------------- -static void outputOperationSummary(const CoordinateOperationNNPtr &op) { +static void outputOperationSummary(const CoordinateOperationNNPtr &op, + const DatabaseContextPtr &dbContext) { auto ids = op->identifiers(); if (!ids.empty()) { std::cout << *(ids[0]->codeSpace()) << ":" << ids[0]->code(); @@ -512,6 +543,18 @@ static void outputOperationSummary(const CoordinateOperationNNPtr &op) { std::cout << ", has ballpark transformation"; } + if (dbContext && getenv("PROJINFO_NO_GRID_CHECK") == nullptr) { + try { + auto setGrids = op->gridsNeeded(dbContext); + for (const auto &grid : setGrids) { + if (!grid.available) { + std::cout << ", at least one grid missing"; + break; + } + } + } catch (const std::exception &) { + } + } std::cout << std::endl; } @@ -598,7 +641,7 @@ static void outputOperations( } if (summary) { for (const auto &op : list) { - outputOperationSummary(op); + outputOperationSummary(op, dbContext); } } else { bool first = true; @@ -613,7 +656,7 @@ static void outputOperations( "\xC2\xB0" << (i + 1) << ":" << std::endl << std::endl; - outputOperationSummary(op); + outputOperationSummary(op, dbContext); std::cout << std::endl; outputObject(dbContext, op, allowUseIntermediateCRS, outputOpt); } |
