diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-02-10 18:53:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-10 18:53:54 +0100 |
| commit | 755d6d396ec29fdfa72d26bad28a9b17d8e1b4c6 (patch) | |
| tree | 5851e1d6d383db1b802b949603ea28813bd80ca0 | |
| parent | 36d8691b20bb0caeb87be262a9b1f0d088ccffd0 (diff) | |
| parent | 836af9dcf12c3870e8a412c97f6968b69c4b3bad (diff) | |
| download | PROJ-755d6d396ec29fdfa72d26bad28a9b17d8e1b4c6.tar.gz PROJ-755d6d396ec29fdfa72d26bad28a9b17d8e1b4c6.zip | |
Merge pull request #2524 from rouault/fix_2510
Fix handling of +proj=ob_tran +o_proj=longlat combined with +over (fixes #2510)
| -rw-r--r-- | src/iso19111/crs.cpp | 16 | ||||
| -rw-r--r-- | src/iso19111/io.cpp | 17 | ||||
| -rw-r--r-- | test/unit/test_operationfactory.cpp | 6 |
3 files changed, 23 insertions, 16 deletions
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp index 9d58f733..1ac60d88 100644 --- a/src/iso19111/crs.cpp +++ b/src/iso19111/crs.cpp @@ -5757,11 +5757,17 @@ void DerivedGeographicCRS::_exportToPROJString( { const auto &l_conv = derivingConversionRef(); const auto &methodName = l_conv->method()->nameStr(); - if (methodName == "PROJ ob_tran o_proj=longlat" || - methodName == "PROJ ob_tran o_proj=lonlat" || - methodName == "PROJ ob_tran o_proj=latlong" || - methodName == "PROJ ob_tran o_proj=latlon" || - ci_equal(methodName, + + for (const char *substr : + {"PROJ ob_tran o_proj=longlat", "PROJ ob_tran o_proj=lonlat", + "PROJ ob_tran o_proj=latlon", "PROJ ob_tran o_proj=latlong"}) { + if (starts_with(methodName, substr)) { + l_conv->_exportToPROJString(formatter); + return; + } + } + + if (ci_equal(methodName, PROJ_WKT2_NAME_METHOD_POLE_ROTATION_GRIB_CONVENTION)) { l_conv->_exportToPROJString(formatter); return; diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index c0844608..6ea6316c 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -9674,14 +9674,15 @@ CRSNNPtr PROJStringParser::Private::buildProjectedCRS( parameters, values) .as_nullable(); - if (is_in_stringlist(methodName, "PROJ ob_tran o_proj=longlat," - "PROJ ob_tran o_proj=lonlat," - "PROJ ob_tran o_proj=latlon," - "PROJ ob_tran o_proj=latlong")) { - return DerivedGeographicCRS::create( - PropertyMap().set(IdentifiedObject::NAME_KEY, "unnamed"), - geogCRS, NN_NO_CHECK(conv), - buildEllipsoidalCS(iStep, iUnitConvert, iAxisSwap, false)); + for (const char *substr : + {"PROJ ob_tran o_proj=longlat", "PROJ ob_tran o_proj=lonlat", + "PROJ ob_tran o_proj=latlon", "PROJ ob_tran o_proj=latlong"}) { + if (starts_with(methodName, substr)) { + return DerivedGeographicCRS::create( + PropertyMap().set(IdentifiedObject::NAME_KEY, "unnamed"), + geogCRS, NN_NO_CHECK(conv), + buildEllipsoidalCS(iStep, iUnitConvert, iAxisSwap, false)); + } } } diff --git a/test/unit/test_operationfactory.cpp b/test/unit/test_operationfactory.cpp index 32c872ac..a64959a8 100644 --- a/test/unit/test_operationfactory.cpp +++ b/test/unit/test_operationfactory.cpp @@ -6336,7 +6336,7 @@ TEST(operation, createOperation_ossfuzz_18587) { TEST(operation, derivedGeographicCRS_with_to_wgs84_to_geographicCRS) { auto objSrc = PROJStringParser().createFromPROJString( "+proj=ob_tran +o_proj=latlon +lat_0=0 +lon_0=180 +o_lat_p=18.0 " - "+o_lon_p=-200.0 +ellps=WGS84 +towgs84=1,2,3 +type=crs"); + "+o_lon_p=-200.0 +ellps=WGS84 +towgs84=1,2,3 +over +type=crs"); auto src = nn_dynamic_pointer_cast<CRS>(objSrc); ASSERT_TRUE(src != nullptr); auto objDst = PROJStringParser().createFromPROJString( @@ -6351,7 +6351,7 @@ TEST(operation, derivedGeographicCRS_with_to_wgs84_to_geographicCRS) { std::string pipeline( "+proj=pipeline " "+step +proj=unitconvert +xy_in=deg +xy_out=rad " - "+step +inv +proj=ob_tran +o_proj=latlon +lat_0=0 +lon_0=180 " + "+step +inv +proj=ob_tran +o_proj=latlon +over +lat_0=0 +lon_0=180 " "+o_lat_p=18 +o_lon_p=-200 +ellps=WGS84 " "+step +proj=push +v_3 " "+step +proj=cart +ellps=WGS84 " @@ -6381,7 +6381,7 @@ TEST(operation, derivedGeographicCRS_with_to_wgs84_to_geographicCRS) { "+step +proj=helmert +x=-1 +y=-2 +z=-3 " "+step +inv +proj=cart +ellps=WGS84 " "+step +proj=pop +v_3 " - "+step +proj=ob_tran +o_proj=latlon +lat_0=0 +lon_0=180 " + "+step +proj=ob_tran +o_proj=latlon +over +lat_0=0 +lon_0=180 " "+o_lat_p=18 +o_lon_p=-200 +ellps=WGS84 " "+step +proj=unitconvert +xy_in=rad +xy_out=deg"); EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), |
