diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-09-14 18:13:47 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-09-14 18:13:47 +0200 |
| commit | bca0a82921594c675ed1212f54e032f19004ee82 (patch) | |
| tree | 29373bee072524c43091b0b0597d9bd1a74d3006 /test/unit | |
| parent | 92ca1a9455cdd136aaaeb1dbb0d8d867020e70c6 (diff) | |
| download | PROJ-bca0a82921594c675ed1212f54e032f19004ee82.tar.gz PROJ-bca0a82921594c675ed1212f54e032f19004ee82.zip | |
PROJJSON: support additional properties allowed in id object (version, authority_citation, uri) for parity with WKT2:2019
Diffstat (limited to 'test/unit')
| -rw-r--r-- | test/unit/test_c_api.cpp | 2 | ||||
| -rw-r--r-- | test/unit/test_io.cpp | 90 |
2 files changed, 81 insertions, 11 deletions
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index 721c54d5..600f47ff 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -4288,7 +4288,7 @@ TEST_F(CApi, proj_as_projjson) { EXPECT_EQ(std::string(projjson), "{\n" " \"$schema\": " - "\"https://proj.org/schemas/v0.2/projjson.schema.json\",\n" + "\"https://proj.org/schemas/v0.4/projjson.schema.json\",\n" " \"type\": \"Ellipsoid\",\n" " \"name\": \"WGS 84\",\n" " \"semi_major_axis\": 6378137,\n" diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index 791a8b9e..a4fb5f6e 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -12035,12 +12035,9 @@ 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\": " - "\"https://proj.org/schemas/v0.2/projjson.schema.json\",\n" + " \"$schema\": \"foo\",\n" " \"type\": \"BoundCRS\",\n" " \"source_crs\": {\n" " \"type\": \"GeographicCRS\",\n" @@ -12134,18 +12131,17 @@ 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().get()), json); + EXPECT_EQ( + boundCRS->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + 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" + " \"$schema\": \"foo\",\n" " \"type\": \"BoundCRS\",\n" " \"name\": \"my bound crs\",\n" " \"source_crs\": {\n" @@ -12252,7 +12248,9 @@ TEST(json_import, bound_crs_with_name_and_usage) { 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); + EXPECT_EQ( + boundCRS->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- @@ -13919,6 +13917,78 @@ TEST(json_import, derived_temporal_crs) { // --------------------------------------------------------------------------- +TEST(json_import, id) { + auto json = "{\n" + " \"$schema\": \"foo\",\n" + " \"type\": \"Ellipsoid\",\n" + " \"name\": \"WGS 84\",\n" + " \"semi_major_axis\": 6378137,\n" + " \"inverse_flattening\": 298.257223563,\n" + " \"id\": {\n" + " \"authority\": \"EPSG\",\n" + " \"code\": 6326,\n" + " \"version\": 1,\n" + " \"authority_citation\": \"my citation\",\n" + " \"uri\": \"my uri\"\n" + " }\n" + "}"; + auto obj = createFromUserInput(json, nullptr); + auto ellps = nn_dynamic_pointer_cast<Ellipsoid>(obj); + ASSERT_TRUE(ellps != nullptr); + EXPECT_EQ(ellps->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); +} + +// --------------------------------------------------------------------------- + +TEST(json_import, id_code_string_version_string) { + auto json = "{\n" + " \"$schema\": \"foo\",\n" + " \"type\": \"Ellipsoid\",\n" + " \"name\": \"WGS 84\",\n" + " \"semi_major_axis\": 6378137,\n" + " \"inverse_flattening\": 298.257223563,\n" + " \"id\": {\n" + " \"authority\": \"EPSG\",\n" + " \"code\": \"abc\",\n" + " \"version\": \"def\",\n" + " \"authority_citation\": \"my citation\",\n" + " \"uri\": \"my uri\"\n" + " }\n" + "}"; + auto obj = createFromUserInput(json, nullptr); + auto ellps = nn_dynamic_pointer_cast<Ellipsoid>(obj); + ASSERT_TRUE(ellps != nullptr); + EXPECT_EQ(ellps->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); +} + +// --------------------------------------------------------------------------- + +TEST(json_import, id_code_string_version_double) { + auto json = "{\n" + " \"$schema\": \"foo\",\n" + " \"type\": \"Ellipsoid\",\n" + " \"name\": \"WGS 84\",\n" + " \"semi_major_axis\": 6378137,\n" + " \"inverse_flattening\": 298.257223563,\n" + " \"id\": {\n" + " \"authority\": \"EPSG\",\n" + " \"code\": \"abc\",\n" + " \"version\": 9.8,\n" + " \"authority_citation\": \"my citation\",\n" + " \"uri\": \"my uri\"\n" + " }\n" + "}"; + auto obj = createFromUserInput(json, nullptr); + auto ellps = nn_dynamic_pointer_cast<Ellipsoid>(obj); + ASSERT_TRUE(ellps != nullptr); + EXPECT_EQ(ellps->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); +} + +// --------------------------------------------------------------------------- + TEST(json_import, multiple_ids) { auto json = "{\n" " \"$schema\": \"foo\",\n" |
