diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-02-25 15:31:41 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-02-25 16:32:08 +0100 |
| commit | 4dbb80b693aa547a7e1cca6df470392869ccdfff (patch) | |
| tree | 826c244aa812bfe820f073f086d70bf27259ac6d /src | |
| parent | 8a1f24dd37db128417a40de353a682bb825c4442 (diff) | |
| download | PROJ-4dbb80b693aa547a7e1cca6df470392869ccdfff.tar.gz PROJ-4dbb80b693aa547a7e1cca6df470392869ccdfff.zip | |
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 4996001f..ea938e10 100644 --- a/src/iso19111/coordinateoperation.cpp +++ b/src/iso19111/coordinateoperation.cpp @@ -11489,11 +11489,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()) { @@ -11521,8 +11540,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( |
