diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-11-21 22:58:05 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-11-22 01:23:51 +0100 |
| commit | 35cd325e7391a7f8eea848d12889e74026541179 (patch) | |
| tree | 7ebcdb1a604a57488ff3c8907d94af06992d017c /src | |
| parent | 66a4bef622b5919a9a78b0f01c890d16c6e95119 (diff) | |
| download | PROJ-35cd325e7391a7f8eea848d12889e74026541179.tar.gz PROJ-35cd325e7391a7f8eea848d12889e74026541179.zip | |
WKT parsing: fix ingestion of WKT with a Geocentric CRS as the base of the projected CRS
Diffstat (limited to 'src')
| -rw-r--r-- | src/iso19111/io.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index ddfe9ce3..fff24e2f 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -2790,6 +2790,32 @@ WKTParser::Private::buildGeodeticCRS(const WKTNodeNNPtr &node) { .as_nullable() : nullptr; auto cs = buildCS(csNode, node, angularUnit); + + // If there's no CS[] node, typically for a BASEGEODCRS of a projected CRS, + // in a few rare cases, this might be a Geocentric CRS, and thus a + // Cartesian CS, and not the ellipsoidalCS we assumed above. The only way + // to figure that is to resolve the CRS from its code... + if (isNull(csNode) && dbContext_ && + ci_equal(nodeName, WKTConstants::BASEGEODCRS)) { + const auto &nodeChildren = nodeP->children(); + for (const auto &subNode : nodeChildren) { + const auto &subNodeName(subNode->GP()->value()); + if (ci_equal(subNodeName, WKTConstants::ID) || + ci_equal(subNodeName, WKTConstants::AUTHORITY)) { + auto id = buildId(subNode, true, false); + if (id) { + try { + auto authFactory = AuthorityFactory::create( + NN_NO_CHECK(dbContext_), *id->codeSpace()); + auto dbCRS = authFactory->createGeodeticCRS(id->code()); + cs = dbCRS->coordinateSystem(); + } catch (const util::Exception &) { + } + } + } + } + } + auto ellipsoidalCS = nn_dynamic_pointer_cast<EllipsoidalCS>(cs); if (ellipsoidalCS) { if (ci_equal(nodeName, WKTConstants::GEOCCS)) { |
