aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-01-02 13:28:57 +0100
committerGitHub <noreply@github.com>2020-01-02 13:28:57 +0100
commit1f8073ac6c82868e813a8ec8d05e403050e33c5e (patch)
treedb349195de4915f06a05e6133ecb5990732bea11 /test
parent2da4b6f5027938cc1d3331351455bfdeabd40ad3 (diff)
parentea311993551f0019f38de361a5bc47fc630ee871 (diff)
downloadPROJ-1f8073ac6c82868e813a8ec8d05e403050e33c5e.tar.gz
PROJ-1f8073ac6c82868e813a8ec8d05e403050e33c5e.zip
Merge pull request #1820 from snowman2/cs_projjson
fix exporting CoordinateSystem to PROJ JSON with ID
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_io.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp
index 4242a15c..05ec01e3 100644
--- a/test/unit/test_io.cpp
+++ b/test/unit/test_io.cpp
@@ -11915,3 +11915,41 @@ TEST(json_import, multiple_ids) {
EXPECT_EQ(ellps->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))),
json);
}
+
+// ---------------------------------------------------------------------------
+
+TEST(json_export, coordinate_system_id) {
+ auto json = "{\n"
+ " \"$schema\": \"foo\",\n"
+ " \"type\": \"CoordinateSystem\",\n"
+ " \"subtype\": \"ellipsoidal\",\n"
+ " \"axis\": [\n"
+ " {\n"
+ " \"name\": \"Geodetic latitude\",\n"
+ " \"abbreviation\": \"Lat\",\n"
+ " \"direction\": \"north\",\n"
+ " \"unit\": \"degree\"\n"
+ " },\n"
+ " {\n"
+ " \"name\": \"Geodetic longitude\",\n"
+ " \"abbreviation\": \"Lon\",\n"
+ " \"direction\": \"east\",\n"
+ " \"unit\": \"degree\"\n"
+ " }\n"
+ " ],\n"
+ " \"id\": {\n"
+ " \"authority\": \"EPSG\",\n"
+ " \"code\": 6422\n"
+ " }\n"
+ "}";
+
+ auto dbContext = DatabaseContext::create();
+ auto obj = createFromUserInput("EPSG:4326", dbContext);
+ auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj);
+ ASSERT_TRUE(crs != nullptr);
+ auto cs = crs->coordinateSystem();
+ ASSERT_TRUE(cs != nullptr);
+ EXPECT_EQ(
+ cs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))),
+ json);
+}