diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-09-11 16:22:32 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-09-15 13:20:43 +0200 |
| commit | a377a0e1ac5d2809703e8e83b368f26d171e5f9b (patch) | |
| tree | d6807fc6e347252c5e0f03d5904942d2dc3c3a08 | |
| parent | 0673f88a96adcabf3a21ed02c182bb94f50fcf89 (diff) | |
| download | PROJ-a377a0e1ac5d2809703e8e83b368f26d171e5f9b.tar.gz PROJ-a377a0e1ac5d2809703e8e83b368f26d171e5f9b.zip | |
createFromPROJString(): ignore +no_defs when instanciating a '+init=epsg:xxxx +no_defs' string (related to #1597)
| -rw-r--r-- | src/iso19111/io.cpp | 15 | ||||
| -rw-r--r-- | test/unit/test_io.cpp | 11 |
2 files changed, 22 insertions, 4 deletions
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<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 2642ed23..52608a4a 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -8641,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 = |
