From b7e7a3bd4a85ce07cc9dee457f3c44be43950084 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 11 Sep 2019 13:55:17 +0000 Subject: Ingestion of +proj=somerc +type=crs: avoid adding twice alpha, gamma, lon_0 (related to #1597) --- src/iso19111/io.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index 25d122af..e5cabd3d 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -8313,10 +8313,13 @@ CRSNNPtr PROJStringParser::Private::buildProjectedCRS( } else if (step.name == "somerc") { mapping = getMapping(EPSG_CODE_METHOD_HOTINE_OBLIQUE_MERCATOR_VARIANT_B); - step.paramValues.emplace_back(Step::KeyValue("alpha", "90")); - step.paramValues.emplace_back(Step::KeyValue("gamma", "90")); - step.paramValues.emplace_back( - Step::KeyValue("lonc", getParamValue(step, "lon_0"))); + if (!hasParamValue(step, "alpha") && !hasParamValue(step, "gamma") && + !hasParamValue(step, "lonc")) { + step.paramValues.emplace_back(Step::KeyValue("alpha", "90")); + step.paramValues.emplace_back(Step::KeyValue("gamma", "90")); + step.paramValues.emplace_back( + Step::KeyValue("lonc", getParamValue(step, "lon_0"))); + } } else if (step.name == "krovak" && ((getParamValue(step, "axis") == "swu" && iAxisSwap < 0) || (iAxisSwap > 0 && -- cgit v1.2.3 From 9e5807499c5a37d31f983cd58eb21c918daf1fef Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 11 Sep 2019 14:22:32 +0000 Subject: createFromPROJString(): ignore +no_defs when instanciating a '+init=epsg:xxxx +no_defs' string (related to #1597) --- src/iso19111/io.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index e5cabd3d..ebccf78b 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -8759,10 +8759,17 @@ PROJStringParser::createFromPROJString(const std::string &projString) { if (!file_found) { auto obj = createFromUserInput(stepName, d->dbContext_, true); auto crs = dynamic_cast(obj.get()); - if (crs && - (d->steps_[0].paramValues.empty() || - (d->steps_[0].paramValues.size() == 1 && - d->getParamValue(d->steps_[0], "type") == "crs"))) { + + bool hasSignificantParamValues = false; + for (const auto &kv : d->steps_[0].paramValues) { + if (!((kv.key == "type" && kv.value == "crs") || + kv.key == "no_defs")) { + hasSignificantParamValues = true; + break; + } + } + + if (crs && !hasSignificantParamValues) { PropertyMap properties; properties.set(IdentifiedObject::NAME_KEY, d->title_.empty() ? crs->nameStr() -- cgit v1.2.3 From e5a1ea29ca10c6f56de27cc68b76569f4ed416e0 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 11 Sep 2019 15:43:38 +0000 Subject: DatabaseContext::lookForGridInfo(): avoid setting PROJ context errno. Fixes issue with test/gigs/5208.gie with previous commit when ntf_r93.gsb grid is not available --- src/iso19111/factory.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp index 0f6790c0..60083455 100644 --- a/src/iso19111/factory.cpp +++ b/src/iso19111/factory.cpp @@ -1000,9 +1000,11 @@ bool DatabaseContext::lookForGridInfo(const std::string &projFilename, if (d->pjCtxt() == nullptr) { d->setPjCtxt(pj_get_default_ctx()); } + int errno_before = proj_context_errno(d->pjCtxt()); gridAvailable = pj_find_file(d->pjCtxt(), projFilename.c_str(), &fullFilename[0], fullFilename.size() - 1) != 0; + proj_context_errno_set(d->pjCtxt(), errno_before); fullFilename.resize(strlen(fullFilename.c_str())); auto res = -- cgit v1.2.3