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/unit/test_io.cpp | |
| 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/unit/test_io.cpp')
| -rw-r--r-- | test/unit/test_io.cpp | 127 |
1 files changed, 123 insertions, 4 deletions
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); } // --------------------------------------------------------------------------- |
