diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-08-19 10:11:47 +0200 |
|---|---|---|
| committer | github-actions[bot] <github-actions[bot]@users.noreply.github.com> | 2021-08-19 08:34:01 +0000 |
| commit | dff8e5df3f5e80a88590fc87aca17b39008289cc (patch) | |
| tree | 0a5e285a6383537a8318a5d2bc01a36ab8ac5e2a /test | |
| parent | b8ab9150834257bcb197ca73b5a81eef7becdbdc (diff) | |
| download | PROJ-dff8e5df3f5e80a88590fc87aca17b39008289cc.tar.gz PROJ-dff8e5df3f5e80a88590fc87aca17b39008289cc.zip | |
Merge pull request #2814 from rouault/fix_2813
BoundCRS: accept importing/exporting in WKT2 and PROJJSON the scope/area/extent/id attributes (fixes #2813)
Diffstat (limited to 'test')
| -rw-r--r-- | test/unit/test_crs.cpp | 87 | ||||
| -rw-r--r-- | test/unit/test_io.cpp | 127 |
2 files changed, 210 insertions, 4 deletions
diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp index fb3c14ae..c36aa9b7 100644 --- a/test/unit/test_crs.cpp +++ b/test/unit/test_crs.cpp @@ -4411,6 +4411,93 @@ TEST(crs, boundCRS_to_WKT2) { // --------------------------------------------------------------------------- +TEST(crs, boundCRS_with_usage) { + + auto wkt = + "BOUNDCRS[\n" + " SOURCECRS[\n" + " PROJCRS[\"Monte Mario / Italy zone 2\",\n" + " BASEGEOGCRS[\"Monte Mario\",\n" + " DATUM[\"Monte Mario\",\n" + " ELLIPSOID[\"International 1924\",6378388,297,\n" + " LENGTHUNIT[\"metre\",1]]],\n" + " PRIMEM[\"Greenwich\",0,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " ID[\"EPSG\",4265]],\n" + " CONVERSION[\"unnamed\",\n" + " METHOD[\"Transverse Mercator\",\n" + " ID[\"EPSG\",9807]],\n" + " PARAMETER[\"Latitude of natural origin\",0,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8801]],\n" + " PARAMETER[\"Longitude of natural origin\",15,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8802]],\n" + " PARAMETER[\"Scale factor at natural origin\",0.9996,\n" + " SCALEUNIT[\"unity\",1],\n" + " ID[\"EPSG\",8805]],\n" + " PARAMETER[\"False easting\",2520000,\n" + " LENGTHUNIT[\"metre\",1],\n" + " ID[\"EPSG\",8806]],\n" + " PARAMETER[\"False northing\",0,\n" + " LENGTHUNIT[\"metre\",1],\n" + " ID[\"EPSG\",8807]]],\n" + " CS[Cartesian,2],\n" + " AXIS[\"x\",east,\n" + " ORDER[1],\n" + " LENGTHUNIT[\"metre\",1]],\n" + " AXIS[\"y\",north,\n" + " ORDER[2],\n" + " LENGTHUNIT[\"metre\",1]],\n" + " ID[\"EPSG\",3004]]],\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 Monte Mario to " + "WGS84\",\n" + " METHOD[\"Position Vector transformation (geog2D domain)\",\n" + " ID[\"EPSG\",9606]],\n" + " PARAMETER[\"X-axis translation\",-50.2,\n" + " ID[\"EPSG\",8605]],\n" + " PARAMETER[\"Y-axis translation\",-50.4,\n" + " ID[\"EPSG\",8606]],\n" + " PARAMETER[\"Z-axis translation\",84.8,\n" + " ID[\"EPSG\",8607]],\n" + " PARAMETER[\"X-axis rotation\",-0.69,\n" + " ID[\"EPSG\",8608]],\n" + " PARAMETER[\"Y-axis rotation\",-2.012,\n" + " ID[\"EPSG\",8609]],\n" + " PARAMETER[\"Z-axis rotation\",0.459,\n" + " ID[\"EPSG\",8610]],\n" + " PARAMETER[\"Scale difference\",0.99997192,\n" + " ID[\"EPSG\",8611]]],\n" + " USAGE[\n" + " SCOPE[\"unknown\"],\n" + " AREA[\"Italy - Sicily onshore\"],\n" + " BBOX[36.59,12.36,38.35,15.71]]]"; + auto crs = + nn_dynamic_pointer_cast<BoundCRS>(WKTParser().createFromWKT(wkt)); + ASSERT_TRUE(crs != nullptr); + + auto got_wkt = crs->exportToWKT( + WKTFormatter::create(WKTFormatter::Convention::WKT2_2019).get()); + EXPECT_EQ(got_wkt, wkt); +} + +// --------------------------------------------------------------------------- + TEST(crs, boundCRS_crs_link) { { diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index 98ac5aa0..0235a0c1 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -11891,9 +11891,12 @@ TEST(json_import, compound_crs) { // --------------------------------------------------------------------------- TEST(json_import, bound_crs) { + // Explicitly check that the version is v0.2 in that circumstance. Might + // require adjustments in the future. auto json = "{\n" - " \"$schema\": \"foo\",\n" + " \"$schema\": " + "\"https://proj.org/schemas/v0.2/projjson.schema.json\",\n" " \"type\": \"BoundCRS\",\n" " \"source_crs\": {\n" " \"type\": \"GeographicCRS\",\n" @@ -11987,9 +11990,125 @@ TEST(json_import, bound_crs) { auto obj = createFromUserInput(json, nullptr); auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(obj); ASSERT_TRUE(boundCRS != nullptr); - EXPECT_EQ( - boundCRS->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), - json); + EXPECT_EQ(boundCRS->exportToJSON(JSONFormatter::create().get()), json); +} + +// --------------------------------------------------------------------------- + +TEST(json_import, bound_crs_with_name_and_usage) { + // Explicitly check that the version is v0.3 in that circumstance. Might + // require adjustments in the future. + auto json = + "{\n" + " \"$schema\": " + "\"https://proj.org/schemas/v0.3/projjson.schema.json\",\n" + " \"type\": \"BoundCRS\",\n" + " \"name\": \"my bound crs\",\n" + " \"source_crs\": {\n" + " \"type\": \"GeographicCRS\",\n" + " \"name\": \"unknown\",\n" + " \"datum\": {\n" + " \"type\": \"GeodeticReferenceFrame\",\n" + " \"name\": \"Unknown based on GRS80 ellipsoid\",\n" + " \"ellipsoid\": {\n" + " \"name\": \"GRS 1980\",\n" + " \"semi_major_axis\": 6378137,\n" + " \"inverse_flattening\": 298.257222101,\n" + " \"id\": {\n" + " \"authority\": \"EPSG\",\n" + " \"code\": 7019\n" + " }\n" + " }\n" + " },\n" + " \"coordinate_system\": {\n" + " \"subtype\": \"ellipsoidal\",\n" + " \"axis\": [\n" + " {\n" + " \"name\": \"Longitude\",\n" + " \"abbreviation\": \"lon\",\n" + " \"direction\": \"east\",\n" + " \"unit\": \"degree\"\n" + " },\n" + " {\n" + " \"name\": \"Latitude\",\n" + " \"abbreviation\": \"lat\",\n" + " \"direction\": \"north\",\n" + " \"unit\": \"degree\"\n" + " }\n" + " ]\n" + " }\n" + " },\n" + " \"target_crs\": {\n" + " \"type\": \"GeographicCRS\",\n" + " \"name\": \"WGS 84\",\n" + " \"datum\": {\n" + " \"type\": \"GeodeticReferenceFrame\",\n" + " \"name\": \"World Geodetic System 1984\",\n" + " \"ellipsoid\": {\n" + " \"name\": \"WGS 84\",\n" + " \"semi_major_axis\": 6378137,\n" + " \"inverse_flattening\": 298.257223563\n" + " }\n" + " },\n" + " \"coordinate_system\": {\n" + " \"subtype\": \"ellipsoidal\",\n" + " \"axis\": [\n" + " {\n" + " \"name\": \"Latitude\",\n" + " \"abbreviation\": \"lat\",\n" + " \"direction\": \"north\",\n" + " \"unit\": \"degree\"\n" + " },\n" + " {\n" + " \"name\": \"Longitude\",\n" + " \"abbreviation\": \"lon\",\n" + " \"direction\": \"east\",\n" + " \"unit\": \"degree\"\n" + " }\n" + " ]\n" + " },\n" + " \"id\": {\n" + " \"authority\": \"EPSG\",\n" + " \"code\": 4326\n" + " }\n" + " },\n" + " \"transformation\": {\n" + " \"name\": \"unknown to WGS84\",\n" + " \"method\": {\n" + " \"name\": \"NTv2\",\n" + " \"id\": {\n" + " \"authority\": \"EPSG\",\n" + " \"code\": 9615\n" + " }\n" + " },\n" + " \"parameters\": [\n" + " {\n" + " \"name\": \"Latitude and longitude difference file\",\n" + " \"value\": \"@foo\",\n" + " \"id\": {\n" + " \"authority\": \"EPSG\",\n" + " \"code\": 8656\n" + " }\n" + " }\n" + " ]\n" + " },\n" + " \"scope\": \"Example only (fictitious).\",\n" + " \"area\": \"Description of the extent of the CRS.\",\n" + " \"bbox\": {\n" + " \"south_latitude\": -90,\n" + " \"west_longitude\": -180,\n" + " \"north_latitude\": 90,\n" + " \"east_longitude\": 180\n" + " },\n" + " \"id\": {\n" + " \"authority\": \"foo\",\n" + " \"code\": 1234\n" + " }\n" + "}"; + auto obj = createFromUserInput(json, nullptr); + auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(obj); + ASSERT_TRUE(boundCRS != nullptr); + EXPECT_EQ(boundCRS->exportToJSON(JSONFormatter::create().get()), json); } // --------------------------------------------------------------------------- |
