From 0673f88a96adcabf3a21ed02c182bb94f50fcf89 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 11 Sep 2019 15:55:17 +0200 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 7194a838..dfe6f6a8 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 a377a0e1ac5d2809703e8e83b368f26d171e5f9b Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 11 Sep 2019 16:22:32 +0200 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 dfe6f6a8..550312d8 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 3d082689d468828e62f101c9755c8d42202a0ea1 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 11 Sep 2019 17:43:38 +0200 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 3ed69ae9..9ecc0906 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