aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-11-21 22:58:05 +0100
committerEven Rouault <even.rouault@spatialys.com>2020-11-21 23:58:50 +0100
commiteb66679cde834096ff18f40b5b1d4bc10e3f4c1d (patch)
treebbdf11e04042d79aa2cee50109082437144ce3d2 /src
parent3f4058308bc328765dcf6ecdcb8fa7a644f3cc19 (diff)
downloadPROJ-eb66679cde834096ff18f40b5b1d4bc10e3f4c1d.tar.gz
PROJ-eb66679cde834096ff18f40b5b1d4bc10e3f4c1d.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.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp
index fa359d39..284729cd 100644
--- a/src/iso19111/io.cpp
+++ b/src/iso19111/io.cpp
@@ -2794,6 +2794,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)) {