diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-02-25 16:27:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-25 16:27:10 +0100 |
| commit | 414ae2699ccfafdabacd12010acf7ad2f16fd889 (patch) | |
| tree | 9de48999cc66e130c1266bee4a559d5422cfc88d /src | |
| parent | 1ce2cc80a4a0ff248cda778ae16de51946fa61b7 (diff) | |
| parent | 5c79670110c114c720a9a9bad516f78eee59ea49 (diff) | |
| download | PROJ-414ae2699ccfafdabacd12010acf7ad2f16fd889.tar.gz PROJ-414ae2699ccfafdabacd12010acf7ad2f16fd889.zip | |
Merge pull request #1983 from rouault/fix_1982
createOperations(): be robust to a GeographicCRS having a wrong ID attached to it (fixes #1982)
Diffstat (limited to 'src')
| -rw-r--r-- | src/iso19111/coordinateoperation.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp index fef13e41..c97763e4 100644 --- a/src/iso19111/coordinateoperation.cpp +++ b/src/iso19111/coordinateoperation.cpp @@ -11687,11 +11687,30 @@ applyInverse(const std::vector<CoordinateOperationNNPtr> &list) { void CoordinateOperationFactory::Private::buildCRSIds( const crs::CRSNNPtr &crs, Private::Context &context, std::list<std::pair<std::string, std::string>> &ids) { + const auto &authFactory = context.context->getAuthorityFactory(); + assert(authFactory); for (const auto &id : crs->identifiers()) { const auto &authName = *(id->codeSpace()); const auto &code = id->code(); if (!authName.empty()) { - ids.emplace_back(authName, code); + const auto tmpAuthFactory = io::AuthorityFactory::create( + authFactory->databaseContext(), authName); + try { + // Consistency check for the ID attached to the object. + // See https://github.com/OSGeo/PROJ/issues/1982 where EPSG:4656 + // is attached to a GeographicCRS whereas it is a ProjectedCRS + if (tmpAuthFactory->createCoordinateReferenceSystem(code) + ->_isEquivalentTo( + crs.get(), + util::IComparable::Criterion:: + EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS)) { + ids.emplace_back(authName, code); + } else { + // TODO? log this inconsistency + } + } catch (const std::exception &) { + // TODO? log this inconsistency + } } } if (ids.empty()) { @@ -11719,8 +11738,6 @@ void CoordinateOperationFactory::Private::buildCRSIds( return; } - const auto &authFactory = context.context->getAuthorityFactory(); - assert(authFactory); const auto &authFactoryName = authFactory->getAuthority(); try { const auto tmpAuthFactory = io::AuthorityFactory::create( |
