aboutsummaryrefslogtreecommitdiff
path: root/test/unit/test_operation.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-02-29 13:24:58 +0100
committerKristian Evers <kristianevers@gmail.com>2020-03-01 11:51:08 +0100
commit641df65880087ae40b4aef94cc5c104f016b6bdc (patch)
treee37e0fd332eaadeab64b41b698944577276db209 /test/unit/test_operation.cpp
parente8c150186fec758cc44d90b8efeb756534ae9338 (diff)
downloadPROJ-641df65880087ae40b4aef94cc5c104f016b6bdc.tar.gz
PROJ-641df65880087ae40b4aef94cc5c104f016b6bdc.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.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp
index fb611f68..952b5441 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");