diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-02-29 13:24:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-29 13:24:58 +0100 |
| commit | 10a8d5c98499127e5aa61d6cdeee466fcabb12ed (patch) | |
| tree | 241ad35a9c6866c565d096fc9b0357747a347ec7 /test/unit/test_operation.cpp | |
| parent | 1f3a571d32fb311a7bd4528b04071dbf332498c4 (diff) | |
| download | PROJ-10a8d5c98499127e5aa61d6cdeee466fcabb12ed.tar.gz PROJ-10a8d5c98499127e5aa61d6cdeee466fcabb12ed.zip | |
createOperations(): fix wrong pipeline generation with CRS that has +nadgrids= and +pm= (#1998)
Fixes issue reported at
https://lists.osgeo.org/pipermail/gdal-dev/2020-February/051749.html
The generated pipeline assumes that the input coordinates for the grid transformation
were related to the non-Greenwich based datum, so we must compensate for that and
add logic to go back to Greenwich.
Diffstat (limited to 'test/unit/test_operation.cpp')
| -rw-r--r-- | test/unit/test_operation.cpp | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index 84415efb..19b71cee 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -6567,6 +6567,64 @@ TEST(operation, ETRS89_3D_to_proj_string_with_geoidgrids_nadgrids) { // --------------------------------------------------------------------------- +TEST(operation, nadgrids_with_pm) { + auto authFactory = + AuthorityFactory::create(DatabaseContext::create(), "EPSG"); + auto objSrc = PROJStringParser().createFromPROJString( + "+proj=tmerc +lat_0=39.66666666666666 +lon_0=1 +k=1 +x_0=200000 " + "+y_0=300000 +ellps=intl +nadgrids=foo.gsb +pm=lisbon " + "+units=m +type=crs"); + auto src = nn_dynamic_pointer_cast<CRS>(objSrc); + ASSERT_TRUE(src != nullptr); + auto dst = authFactory->createCoordinateReferenceSystem("4326"); + auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0); + auto list = CoordinateOperationFactory::create()->createOperations( + NN_NO_CHECK(src), dst, ctxt); + ASSERT_EQ(list.size(), 1U); + EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline " + "+step +inv +proj=tmerc +lat_0=39.6666666666667 +lon_0=1 " + "+k=1 +x_0=200000 +y_0=300000 +ellps=intl +pm=lisbon " + // Check that there is no extra +step +proj=longlat +pm=lisbon + "+step +proj=hgridshift +grids=foo.gsb " + "+step +proj=unitconvert +xy_in=rad +xy_out=deg " + "+step +proj=axisswap +order=2,1"); + + // ETRS89 + dst = authFactory->createCoordinateReferenceSystem("4258"); + list = CoordinateOperationFactory::create()->createOperations( + NN_NO_CHECK(src), dst, ctxt); + ASSERT_EQ(list.size(), 1U); + EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline " + "+step +inv +proj=tmerc +lat_0=39.6666666666667 +lon_0=1 " + "+k=1 +x_0=200000 +y_0=300000 +ellps=intl +pm=lisbon " + // Check that there is no extra +step +proj=longlat +pm=lisbon + "+step +proj=hgridshift +grids=foo.gsb " + "+step +proj=unitconvert +xy_in=rad +xy_out=deg " + "+step +proj=axisswap +order=2,1"); + + // From WKT BOUNDCRS + auto formatter = WKTFormatter::create(WKTFormatter::Convention::WKT2_2019); + auto src_wkt = src->exportToWKT(formatter.get()); + auto objFromWkt = WKTParser().createFromWKT(src_wkt); + auto crsFromWkt = nn_dynamic_pointer_cast<BoundCRS>(objFromWkt); + ASSERT_TRUE(crsFromWkt); + list = CoordinateOperationFactory::create()->createOperations( + NN_NO_CHECK(crsFromWkt), dst, ctxt); + ASSERT_EQ(list.size(), 1U); + EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline " + "+step +inv +proj=tmerc +lat_0=39.6666666666667 +lon_0=1 " + "+k=1 +x_0=200000 +y_0=300000 +ellps=intl +pm=lisbon " + // Check that there is no extra +step +proj=longlat +pm=lisbon + "+step +proj=hgridshift +grids=foo.gsb " + "+step +proj=unitconvert +xy_in=rad +xy_out=deg " + "+step +proj=axisswap +order=2,1"); +} + +// --------------------------------------------------------------------------- + TEST(operation, WGS84_G1762_to_compoundCRS_with_bound_vertCRS) { auto authFactoryEPSG = AuthorityFactory::create(DatabaseContext::create(), "EPSG"); @@ -6767,7 +6825,6 @@ TEST(operation, transformation_BEV_AT_to_PROJ_string) { "+multiplier=1"); } - // --------------------------------------------------------------------------- TEST(operation, transformation_longitude_rotation_to_PROJ_string) { |
