diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-09-15 22:38:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-15 22:38:14 +0200 |
| commit | 1aaca77c2aa548a7be16fc2a2a00a5ef8e867e2a (patch) | |
| tree | 03bb1cb4a1b33b83ec18ef476be4e19180195b43 | |
| parent | eb5906bb14afba3a5a5508314cfcaa661b75d29d (diff) | |
| parent | 73042b0139ccbdb86996c653b179746e5bc4de67 (diff) | |
| download | PROJ-1aaca77c2aa548a7be16fc2a2a00a5ef8e867e2a.tar.gz PROJ-1aaca77c2aa548a7be16fc2a2a00a5ef8e867e2a.zip | |
Merge pull request #1616 from OSGeo/backport-1614-to-6.2
[Backport 6.2] Fixes related to #1597
| -rw-r--r-- | docs/source/development/migration.rst | 28 | ||||
| -rw-r--r-- | src/iso19111/factory.cpp | 2 | ||||
| -rw-r--r-- | src/iso19111/io.cpp | 26 | ||||
| -rw-r--r-- | test/unit/test_io.cpp | 15 |
4 files changed, 62 insertions, 9 deletions
diff --git a/docs/source/development/migration.rst b/docs/source/development/migration.rst index 00e251c3..e22d7b16 100644 --- a/docs/source/development/migration.rst +++ b/docs/source/development/migration.rst @@ -117,7 +117,8 @@ Function mapping from old to new API +---------------------------------------+-------------------------------------------------+ | pj_inv3 | :c:func:`proj_trans` | +---------------------------------------+-------------------------------------------------+ -| pj_transform | :c:func:`proj_create_crs_to_crs` + | +| pj_transform | :c:func:`proj_create_crs_to_crs` | +| | or :c:func:`proj_create_crs_to_crs_from_pj` + | | | (:c:func:`proj_normalize_for_visualization` +) | | | :c:func:`proj_trans`, | | | :c:func:`proj_trans_array` or | @@ -155,6 +156,31 @@ Function mapping from old to new API | pj_get_release | :c:func:`proj_info` | +---------------------------------------+-------------------------------------------------+ + +Backward incompatibilities +############################################################################### + +Access to the proj_api.h is still possible but requires to define the +``ACCEPT_USE_OF_DEPRECATED_PROJ_API_H`` macro. + +The emulation of the now deprecated ``+init=epsg:XXXX`` syntax in PROJ 6 is not +fully compatible with previous versions. + +In particular, when used with the ``pj_transform()`` function, no datum shift term +(``towgs84``, ``nadgrids``, ``geoidgrids``) will be added during the expansion of the +``+init=epsg:XXXX`` string to ``+proj=YYYY ....``. If you still uses ``pj_transform()`` +and want datum shift to be applied, then you need to provide a fully expanded +string with appropriate ``towgs84``, ``nadgrids`` or ``geoidgrids`` terms to ``pj_init()``. + +To use the ``+init=epsg:XXXX`` syntax with :c:func:`proj_create` and then +:c:func:`proj_create_crs_to_crs`, ``proj_context_use_proj4_init_rules(ctx, TRUE)`` +or the ``PROJ_USE_PROJ4_INIT_RULES=YES`` environment variable must have been +previously set. In that context, datum shift will be researched. However they +might be different than with PROJ 4 or PROJ 5, since a "late-binding" approach +will be used (that is trying to find as much as possible the most direct +transformation between the source and target datum), whereas PROJ 4 or PROJ 5 +used an "early-binding" approach consisting in always going to EPSG:4326 / WGS 84. + ================================================================================ Version 4 to 5 API Migration ================================================================================ 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 = diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index 25d122af..ebccf78b 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 && @@ -8756,10 +8759,17 @@ PROJStringParser::createFromPROJString(const std::string &projString) { if (!file_found) { auto obj = createFromUserInput(stepName, d->dbContext_, true); auto crs = dynamic_cast<CRS *>(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() diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index 7930ff53..0eed2d15 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -7800,6 +7800,10 @@ TEST(io, projparse_somerc) { EXPECT_TRUE(wkt.find("\"Northing at projection centre\",5") != std::string::npos) << wkt; + + auto wkt1 = crs->exportToWKT( + WKTFormatter::create(WKTFormatter::Convention::WKT1_GDAL).get()); + EXPECT_TRUE(wkt1.find("EXTENSION") == std::string::npos) << wkt1; } // --------------------------------------------------------------------------- @@ -8637,6 +8641,17 @@ TEST(io, projparse_init) { } { + // Test that +no_defs +type=crs have no effect + auto obj = createFromUserInput("+init=epsg:4326 +no_defs +type=crs", + dbContext, true); + auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj); + ASSERT_TRUE(crs != nullptr); + + auto wkt = crs->exportToWKT(WKTFormatter::create().get()); + EXPECT_TRUE(wkt.find("GEODCRS[\"WGS 84\"") == 0) << wkt; + } + + { // EPSG:3040 is normally northing-easting order, but in compatibillity // mode it will be easting-northing auto obj = |
