aboutsummaryrefslogtreecommitdiff
path: root/test/unit/test_operation.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-02-10 15:46:10 +0100
committerEven Rouault <even.rouault@spatialys.com>2021-02-10 15:48:29 +0100
commit4b44a55f6f2e60230e56f5431120dd3c3e07603f (patch)
treed825f44742426ab69058e25133984515da612b7f /test/unit/test_operation.cpp
parenta7f6b407446b35a50b5601650aed993c706fe8ee (diff)
downloadPROJ-4b44a55f6f2e60230e56f5431120dd3c3e07603f.tar.gz
PROJ-4b44a55f6f2e60230e56f5431120dd3c3e07603f.zip
Allow a BoundCRS to use a PROJ string transformation
Related to https://lists.osgeo.org/pipermail/proj/2021-February/010040.html Given test.wkt with ``` BOUNDCRS[ SOURCECRS[ GEOGCRS["unknown", DATUM["Unknown based on GRS80 ellipsoid", ELLIPSOID["GRS 1980",6378137,298.257222101, LENGTHUNIT["metre",1], ID["EPSG",7019]]], PRIMEM["Greenwich",0, ANGLEUNIT["degree",0.0174532925199433], ID["EPSG",8901]], CS[ellipsoidal,2], AXIS["longitude",east, ORDER[1], ANGLEUNIT["degree",0.0174532925199433, ID["EPSG",9122]]], AXIS["latitude",north, ORDER[2], ANGLEUNIT["degree",0.0174532925199433, ID["EPSG",9122]]]]], TARGETCRS[ GEOGCRS["WGS 84", DATUM["World Geodetic System 1984", ELLIPSOID["WGS 84",6378137,298.257223563, LENGTHUNIT["metre",1]]], PRIMEM["Greenwich",0, ANGLEUNIT["degree",0.0174532925199433]], CS[ellipsoidal,2], AXIS["latitude",north, ORDER[1], ANGLEUNIT["degree",0.0174532925199433]], AXIS["longitude",east, ORDER[2], ANGLEUNIT["degree",0.0174532925199433]], ID["EPSG",4326]]], ABRIDGEDTRANSFORMATION["Transformation from unknown to WGS84", METHOD["PROJ-based operation method: +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=axisswap +order=2,1 +step +proj=cart +ellps=GRS80 +step +proj=helmert +convention=coordinate_frame +exact +step +inv +proj=cart +ellps=WGS84 +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=rad +xy_out=deg"]]] ``` ``projinfo -s @test.wkt -t "WGS 84" -o PROJ -q`` outputs: ``` +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=axisswap +order=2,1 +step +proj=cart +ellps=GRS80 +step +proj=helmert +convention=coordinate_frame +exact +step +inv +proj=cart +ellps=WGS84 +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=rad +xy_out=deg ```
Diffstat (limited to 'test/unit/test_operation.cpp')
-rw-r--r--test/unit/test_operation.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp
index b40ebd5e..74bddee8 100644
--- a/test/unit/test_operation.cpp
+++ b/test/unit/test_operation.cpp
@@ -5564,3 +5564,67 @@ TEST(operation,
"+step +proj=unitconvert +xy_in=rad +xy_out=deg "
"+step +proj=axisswap +order=2,1");
}
+
+// ---------------------------------------------------------------------------
+
+TEST(operation, export_of_boundCRS_with_proj_string_method) {
+
+ auto wkt =
+ "BOUNDCRS[\n"
+ " SOURCECRS[\n"
+ " GEOGCRS[\"unknown\",\n"
+ " DATUM[\"Unknown based on GRS80 ellipsoid\",\n"
+ " ELLIPSOID[\"GRS 1980\",6378137,298.257222101,\n"
+ " LENGTHUNIT[\"metre\",1],\n"
+ " ID[\"EPSG\",7019]]],\n"
+ " PRIMEM[\"Greenwich\",0,\n"
+ " ANGLEUNIT[\"degree\",0.0174532925199433],\n"
+ " ID[\"EPSG\",8901]],\n"
+ " CS[ellipsoidal,2],\n"
+ " AXIS[\"longitude\",east,\n"
+ " ORDER[1],\n"
+ " ANGLEUNIT[\"degree\",0.0174532925199433,\n"
+ " ID[\"EPSG\",9122]]],\n"
+ " AXIS[\"latitude\",north,\n"
+ " ORDER[2],\n"
+ " ANGLEUNIT[\"degree\",0.0174532925199433,\n"
+ " ID[\"EPSG\",9122]]]]],\n"
+ " TARGETCRS[\n"
+ " GEOGCRS[\"WGS 84\",\n"
+ " DATUM[\"World Geodetic System 1984\",\n"
+ " ELLIPSOID[\"WGS 84\",6378137,298.257223563,\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\",4326]]],\n"
+ " ABRIDGEDTRANSFORMATION[\"Transformation from unknown to WGS84\",\n"
+ " METHOD[\"PROJ-based operation method: +proj=pipeline +step "
+ "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=axisswap "
+ "+order=2,1 "
+ "+step +proj=cart +ellps=GRS80 +step +proj=helmert "
+ "+convention=coordinate_frame +exact +step +inv +proj=cart "
+ "+ellps=WGS84 "
+ "+step +proj=axisswap +order=2,1 "
+ "+step +proj=unitconvert +xy_in=rad +xy_out=deg\"]]]";
+
+ auto obj = WKTParser().createFromWKT(wkt);
+ auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(obj);
+ ASSERT_TRUE(boundCRS != nullptr);
+ EXPECT_EQ(boundCRS->transformation()->exportToPROJString(
+ PROJStringFormatter::create().get()),
+ "+proj=pipeline "
+ "+step +proj=unitconvert +xy_in=deg +xy_out=rad "
+ "+step +proj=axisswap +order=2,1 "
+ "+step +proj=cart +ellps=GRS80 "
+ "+step +proj=helmert +convention=coordinate_frame +exact "
+ "+step +inv +proj=cart +ellps=WGS84 "
+ "+step +proj=axisswap +order=2,1 "
+ "+step +proj=unitconvert +xy_in=rad +xy_out=deg");
+}