diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/gie/builtins.gie | 12 | ||||
| -rw-r--r-- | test/gie/nkg.gie | 6 | ||||
| -rw-r--r-- | test/unit/test_io.cpp | 195 | ||||
| -rw-r--r-- | test/unit/test_operationfactory.cpp | 63 |
4 files changed, 273 insertions, 3 deletions
diff --git a/test/gie/builtins.gie b/test/gie/builtins.gie index 1a290294..38dfc6a2 100644 --- a/test/gie/builtins.gie +++ b/test/gie/builtins.gie @@ -3599,6 +3599,18 @@ roundtrip 1 accept -2 -1 expect -201113.698641813 -124066.283433860 roundtrip 1 +accept 0.0 89.99 +expect 0.00 9050917.562466157600 +roundtrip 1 +accept 0.0 89.999 +expect 0.00 9050964.513822982088 +roundtrip 1 +accept 0.0 -89.99 +expect 0.0 -9050917.562466157600 +roundtrip 1 +accept 0.0 -89.999 +expect 0.00 -9050964.513822982088 +roundtrip 1 direction inverse accept 200 100 diff --git a/test/gie/nkg.gie b/test/gie/nkg.gie index 5ea476cf..678b4680 100644 --- a/test/gie/nkg.gie +++ b/test/gie/nkg.gie @@ -208,15 +208,15 @@ tolerance 0.1 mm # STAS accept 3275753.4135 321111.2481 5445042.2134 2020.0 -expect 3275753.9111 321110.8658 5445041.8822 2020.0 +expect 3275753.9094 321110.8626 5445041.8818 2020.0 # BOD3 accept 2391773.9918 615615.1837 5860966.1279 2020.0 -expect 2391774.5535 615614.9100 5860965.8138 2020.0 +expect 2391774.5481 615614.9063 5860965.8185 2020.0 # KAUS accept 2107888.9134 895603.4769 5933242.6269 2020.0 -expect 2107889.5097 895603.2085 5933242.3152 2020.0 +expect 2107889.5014 895603.2055 5933242.3208 2020.0 # ------------------------------------------------------------------------------- diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index 69cab65c..f883ddb7 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -3827,6 +3827,201 @@ TEST( // --------------------------------------------------------------------------- +TEST(wkt_parse, CONCATENATEDOPERATION_with_inverse_conversion_of_compound) { + + auto wkt = + "CONCATENATEDOPERATION[\"Inverse of RD New + Amersfoort to ETRS89 (9) " + "+ Inverse of ETRS89 to NAP height (2) + ETRS89 to WGS 84 (1)\",\n" + " SOURCECRS[\n" + " COMPOUNDCRS[\"Amersfoort / RD New + NAP height\",\n" + " PROJCRS[\"Amersfoort / RD New\",\n" + " BASEGEOGCRS[\"Amersfoort\",\n" + " DATUM[\"Amersfoort\",\n" + " ELLIPSOID[\"Bessel " + "1841\",6377397.155,299.1528128,\n" + " LENGTHUNIT[\"metre\",1]]],\n" + " PRIMEM[\"Greenwich\",0,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " ID[\"EPSG\",4289]],\n" + " CONVERSION[\"RD New\",\n" + " METHOD[\"Oblique Stereographic\",\n" + " ID[\"EPSG\",9809]],\n" + " PARAMETER[\"Latitude of natural " + "origin\",52.1561605555556,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8801]],\n" + " PARAMETER[\"Longitude of natural " + "origin\",5.38763888888889,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8802]],\n" + " PARAMETER[\"Scale factor at natural " + "origin\",0.9999079,\n" + " SCALEUNIT[\"unity\",1],\n" + " ID[\"EPSG\",8805]],\n" + " PARAMETER[\"False easting\",155000,\n" + " LENGTHUNIT[\"metre\",1],\n" + " ID[\"EPSG\",8806]],\n" + " PARAMETER[\"False northing\",463000,\n" + " LENGTHUNIT[\"metre\",1],\n" + " ID[\"EPSG\",8807]]],\n" + " CS[Cartesian,2],\n" + " AXIS[\"easting (X)\",east,\n" + " ORDER[1],\n" + " LENGTHUNIT[\"metre\",1]],\n" + " AXIS[\"northing (Y)\",north,\n" + " ORDER[2],\n" + " LENGTHUNIT[\"metre\",1]]],\n" + " VERTCRS[\"NAP height\",\n" + " VDATUM[\"Normaal Amsterdams Peil\"],\n" + " CS[vertical,1],\n" + " AXIS[\"gravity-related height (H)\",up,\n" + " LENGTHUNIT[\"metre\",1]]],\n" + " ID[\"EPSG\",7415]]],\n" + " TARGETCRS[\n" + " GEOGCRS[\"WGS 84 (3D)\",\n" + " ENSEMBLE[\"World Geodetic System 1984 ensemble\",\n" + " MEMBER[\"World Geodetic System 1984 (Transit)\"],\n" + " MEMBER[\"World Geodetic System 1984 (G730)\"],\n" + " MEMBER[\"World Geodetic System 1984 (G873)\"],\n" + " MEMBER[\"World Geodetic System 1984 (G1150)\"],\n" + " MEMBER[\"World Geodetic System 1984 (G1674)\"],\n" + " MEMBER[\"World Geodetic System 1984 (G1762)\"],\n" + " MEMBER[\"World Geodetic System 1984 (G2139)\"],\n" + " ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n" + " LENGTHUNIT[\"metre\",1]],\n" + " ENSEMBLEACCURACY[2.0]],\n" + " PRIMEM[\"Greenwich\",0,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " CS[ellipsoidal,3],\n" + " AXIS[\"geodetic latitude (Lat)\",north,\n" + " ORDER[1],\n" + " ANGLEUNIT[\"degree minute second " + "hemisphere\",0.0174532925199433]],\n" + " AXIS[\"geodetic longitude (Long)\",east,\n" + " ORDER[2],\n" + " ANGLEUNIT[\"degree minute second " + "hemisphere\",0.0174532925199433]],\n" + " AXIS[\"ellipsoidal height (h)\",up,\n" + " ORDER[3],\n" + " LENGTHUNIT[\"metre\",1]],\n" + " ID[\"EPSG\",4329]]],\n" + " STEP[\n" + " CONVERSION[\"Inverse of RD New\",\n" + " METHOD[\"Inverse of Oblique Stereographic\",\n" + " ID[\"INVERSE(EPSG)\",9809]],\n" + " PARAMETER[\"Latitude of natural " + "origin\",52.1561605555556,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8801]],\n" + " PARAMETER[\"Longitude of natural " + "origin\",5.38763888888889,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8802]],\n" + " PARAMETER[\"Scale factor at natural origin\",0.9999079,\n" + " SCALEUNIT[\"unity\",1],\n" + " ID[\"EPSG\",8805]],\n" + " PARAMETER[\"False easting\",155000,\n" + " LENGTHUNIT[\"metre\",1],\n" + " ID[\"EPSG\",8806]],\n" + " PARAMETER[\"False northing\",463000,\n" + " LENGTHUNIT[\"metre\",1],\n" + " ID[\"EPSG\",8807]],\n" + " ID[\"INVERSE(EPSG)\",19914]]],\n" + " STEP[\n" + " COORDINATEOPERATION[\"PROJ-based coordinate operation\",\n" + " SOURCECRS[\n" + " COMPOUNDCRS[\"Amersfoort + NAP height\",\n" + " GEOGCRS[\"Amersfoort\",\n" + " DATUM[\"Amersfoort\",\n" + " ELLIPSOID[\"Bessel " + "1841\",6377397.155,299.1528128,\n" + " LENGTHUNIT[\"metre\",1]]],\n" + " PRIMEM[\"Greenwich\",0,\n" + " " + "ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " CS[ellipsoidal,2],\n" + " AXIS[\"geodetic latitude (Lat)\",north,\n" + " ORDER[1],\n" + " " + "ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " AXIS[\"geodetic longitude (Lon)\",east,\n" + " ORDER[2],\n" + " " + "ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " ID[\"EPSG\",4289]],\n" + " VERTCRS[\"NAP height\",\n" + " VDATUM[\"Normaal Amsterdams Peil\"],\n" + " CS[vertical,1],\n" + " AXIS[\"gravity-related height (H)\",up,\n" + " LENGTHUNIT[\"metre\",1]],\n" + " ID[\"EPSG\",5709]]]],\n" + " TARGETCRS[\n" + " GEOGCRS[\"WGS 84 (3D)\",\n" + " ENSEMBLE[\"World Geodetic System 1984 " + "ensemble\",\n" + " MEMBER[\"World Geodetic System 1984 " + "(Transit)\"],\n" + " MEMBER[\"World Geodetic System 1984 " + "(G730)\"],\n" + " MEMBER[\"World Geodetic System 1984 " + "(G873)\"],\n" + " MEMBER[\"World Geodetic System 1984 " + "(G1150)\"],\n" + " MEMBER[\"World Geodetic System 1984 " + "(G1674)\"],\n" + " MEMBER[\"World Geodetic System 1984 " + "(G1762)\"],\n" + " MEMBER[\"World Geodetic System 1984 " + "(G2139)\"],\n" + " ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n" + " LENGTHUNIT[\"metre\",1]],\n" + " ENSEMBLEACCURACY[2.0]],\n" + " PRIMEM[\"Greenwich\",0,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " CS[ellipsoidal,3],\n" + " AXIS[\"geodetic latitude (Lat)\",north,\n" + " ORDER[1],\n" + " ANGLEUNIT[\"degree minute second " + "hemisphere\",0.0174532925199433]],\n" + " AXIS[\"geodetic longitude (Long)\",east,\n" + " ORDER[2],\n" + " ANGLEUNIT[\"degree minute second " + "hemisphere\",0.0174532925199433]],\n" + " AXIS[\"ellipsoidal height (h)\",up,\n" + " ORDER[3],\n" + " LENGTHUNIT[\"metre\",1]],\n" + " ID[\"EPSG\",4329]]],\n" + " METHOD[\"PROJ-based operation method: +proj=pipeline " + "+step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg " + "+xy_out=rad +step +proj=hgridshift +grids=nl_nsgi_rdtrans2018.tif " + "+step +proj=vgridshift +grids=nl_nsgi_nlgeo2018.tif +multiplier=1 " + "+step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap " + "+order=2,1\"],\n" + " OPERATIONACCURACY[1.002]]],\n" + " USAGE[\n" + " SCOPE[\"unknown\"],\n" + " AREA[\"Netherlands - onshore, including Waddenzee, Dutch " + "Wadden Islands and 12-mile offshore coastal zone.\"],\n" + " BBOX[50.75,3.2,53.7,7.22]]]"; + + auto obj = WKTParser().createFromWKT(wkt); + auto concat = nn_dynamic_pointer_cast<ConcatenatedOperation>(obj); + ASSERT_TRUE(concat != nullptr); + + EXPECT_EQ(concat->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline " + "+step +inv +proj=sterea +lat_0=52.1561605555556 " + "+lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 " + "+ellps=bessel " + "+step +proj=hgridshift +grids=nl_nsgi_rdtrans2018.tif " + "+step +proj=vgridshift +grids=nl_nsgi_nlgeo2018.tif " + "+multiplier=1 " + "+step +proj=unitconvert +xy_in=rad +xy_out=deg " + "+step +proj=axisswap +order=2,1"); +} + +// --------------------------------------------------------------------------- + TEST(wkt_parse, BOUNDCRS_transformation_from_names) { auto projcrs = ProjectedCRS::create( diff --git a/test/unit/test_operationfactory.cpp b/test/unit/test_operationfactory.cpp index e07f88d1..89c4e7c4 100644 --- a/test/unit/test_operationfactory.cpp +++ b/test/unit/test_operationfactory.cpp @@ -3002,6 +3002,69 @@ TEST(operation, nadgrids_with_pm) { // --------------------------------------------------------------------------- +TEST(operation, towgs84_pm_3d) { + // Test fix for https://github.com/OSGeo/gdal/issues/5408 + + auto dbContext = DatabaseContext::create(); + auto authFactory = AuthorityFactory::create(dbContext, std::string()); + + auto objSrc = PROJStringParser().createFromPROJString( + "+proj=tmerc +lat_0=0 +lon_0=34 +k=1 +x_0=0 +y_0=-5000000 " + "+ellps=bessel +pm=ferro " + "+towgs84=1,2,3,4,5,6,7 " + "+units=m +no_defs +type=crs"); + auto src = nn_dynamic_pointer_cast<CRS>(objSrc); + ASSERT_TRUE(src != nullptr); + auto src3D = src->promoteTo3D(std::string(), dbContext); + + auto objDst = PROJStringParser().createFromPROJString( + "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs +type=crs"); + auto dst = nn_dynamic_pointer_cast<CRS>(objDst); + ASSERT_TRUE(dst != nullptr); + auto dst3D = dst->promoteTo3D(std::string(), dbContext); + + // Import thing to check is that there's no push/pop v_3 + const std::string expected_pipeline = + "+proj=pipeline " + "+step +inv +proj=tmerc +lat_0=0 +lon_0=34 +k=1 +x_0=0 +y_0=-5000000 " + "+ellps=bessel +pm=ferro " + "+step +proj=cart +ellps=bessel " + "+step +proj=helmert +x=1 +y=2 +z=3 +rx=4 " + "+ry=5 +rz=6 +s=7 +convention=position_vector " + "+step +inv +proj=cart +ellps=GRS80 " + "+step +proj=unitconvert +xy_in=rad +z_in=m +xy_out=deg +z_out=m"; + + auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0); + { + auto list = CoordinateOperationFactory::create()->createOperations( + src3D, dst3D, ctxt); + ASSERT_EQ(list.size(), 1U); + EXPECT_EQ( + list[0]->exportToPROJString(PROJStringFormatter::create().get()), + expected_pipeline); + } + + // Retry when creating objects from WKT + { + auto objSrcFromWkt = WKTParser().createFromWKT(src3D->exportToWKT( + WKTFormatter::create(WKTFormatter::Convention::WKT2_2019).get())); + auto srcFromWkt = nn_dynamic_pointer_cast<CRS>(objSrcFromWkt); + ASSERT_TRUE(srcFromWkt != nullptr); + auto objDstFromWkt = WKTParser().createFromWKT(dst3D->exportToWKT( + WKTFormatter::create(WKTFormatter::Convention::WKT2_2019).get())); + auto dstFromWkt = nn_dynamic_pointer_cast<CRS>(objDstFromWkt); + ASSERT_TRUE(dstFromWkt != nullptr); + auto list = CoordinateOperationFactory::create()->createOperations( + NN_NO_CHECK(srcFromWkt), NN_NO_CHECK(dstFromWkt), ctxt); + ASSERT_EQ(list.size(), 1U); + EXPECT_EQ( + list[0]->exportToPROJString(PROJStringFormatter::create().get()), + expected_pipeline); + } +} + +// --------------------------------------------------------------------------- + TEST(operation, WGS84_G1762_to_compoundCRS_with_bound_vertCRS) { auto authFactoryEPSG = AuthorityFactory::create(DatabaseContext::create(), "EPSG"); |
