aboutsummaryrefslogtreecommitdiff
path: root/test/unit/test_io.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-09-14 16:13:05 +0200
committerGitHub <noreply@github.com>2021-09-14 16:13:05 +0200
commit92ca1a9455cdd136aaaeb1dbb0d8d867020e70c6 (patch)
tree4afffd03c77810e455aae0265419ad136cfa32a9 /test/unit/test_io.cpp
parent884cff477ed084a242bf31cdafe2045c915a4a06 (diff)
parent078952e7f078e029d66ab6ca1ed594dfecadd1fc (diff)
downloadPROJ-92ca1a9455cdd136aaaeb1dbb0d8d867020e70c6.tar.gz
PROJ-92ca1a9455cdd136aaaeb1dbb0d8d867020e70c6.zip
Merge pull request #2847 from rouault/spherical_ocentric
Add support for GeodeticCRS using a Spherical ocentric coordinate system
Diffstat (limited to 'test/unit/test_io.cpp')
-rw-r--r--test/unit/test_io.cpp111
1 files changed, 109 insertions, 2 deletions
diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp
index 72ac1868..791a8b9e 100644
--- a/test/unit/test_io.cpp
+++ b/test/unit/test_io.cpp
@@ -894,6 +894,37 @@ TEST(wkt_parse, wkt2_EPSG_4979) {
// ---------------------------------------------------------------------------
+TEST(wkt_parse, wkt2_spherical_planetocentric) {
+ const auto wkt =
+ "GEODCRS[\"Mercury (2015) / Ocentric\",\n"
+ " DATUM[\"Mercury (2015)\",\n"
+ " ELLIPSOID[\"Mercury (2015)\",2440530,1075.12334801762,\n"
+ " LENGTHUNIT[\"metre\",1]],\n"
+ " ANCHOR[\"Hun Kal: 20.0\"]],\n"
+ " PRIMEM[\"Reference Meridian\",0,\n"
+ " ANGLEUNIT[\"degree\",0.0174532925199433]],\n"
+ " CS[spherical,2],\n"
+ " AXIS[\"planetocentric latitude (U)\",north,\n"
+ " ORDER[1],\n"
+ " ANGLEUNIT[\"degree\",0.0174532925199433]],\n"
+ " AXIS[\"planetocentric longitude (V)\",east,\n"
+ " ORDER[2],\n"
+ " ANGLEUNIT[\"degree\",0.0174532925199433]],\n"
+ " ID[\"IAU\",19902,2015],\n"
+ " REMARK[\"Source of IAU Coordinate systems: "
+ "doi://10.1007/s10569-017-9805-5\"]]";
+ auto obj = WKTParser().createFromWKT(wkt);
+ auto crs = nn_dynamic_pointer_cast<GeodeticCRS>(obj);
+ ASSERT_TRUE(crs != nullptr);
+ EXPECT_TRUE(crs->isSphericalPlanetocentric());
+ EXPECT_EQ(
+ crs->exportToWKT(
+ WKTFormatter::create(WKTFormatter::Convention::WKT2_2019).get()),
+ wkt);
+}
+
+// ---------------------------------------------------------------------------
+
static void checkGeocentric(GeodeticCRSPtr crs) {
// Explicitly check this is NOT a GeographicCRS
EXPECT_TRUE(!dynamic_cast<GeographicCRS *>(crs.get()));
@@ -10032,6 +10063,29 @@ TEST(io, projparse_geocent_wktext) {
// ---------------------------------------------------------------------------
+TEST(io, projparse_geoc) {
+ std::string input("+proj=longlat +geoc +datum=WGS84 +no_defs +type=crs");
+ auto obj = PROJStringParser().createFromPROJString(input);
+ auto crs = nn_dynamic_pointer_cast<GeodeticCRS>(obj);
+ ASSERT_TRUE(crs != nullptr);
+ EXPECT_TRUE(crs->isSphericalPlanetocentric());
+#if 1
+ EXPECT_THROW(
+ crs->exportToPROJString(
+ PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4)
+ .get()),
+ FormattingException);
+#else
+ EXPECT_EQ(
+ crs->exportToPROJString(
+ PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4)
+ .get()),
+ input);
+#endif
+}
+
+// ---------------------------------------------------------------------------
+
TEST(io, projparse_projected_wktext) {
std::string input("+proj=merc +foo +wktext +type=crs");
auto obj = PROJStringParser().createFromPROJString(input);
@@ -10178,13 +10232,13 @@ TEST(io, projparse_init) {
}
{
- auto obj = createFromUserInput("+title=mytitle +geoc +init=epsg:4326",
+ auto obj = createFromUserInput("+title=mytitle +over +init=epsg:4326",
dbContext, true);
auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj);
ASSERT_TRUE(crs != nullptr);
EXPECT_EQ(crs->nameStr(), "mytitle");
EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()),
- "+proj=longlat +geoc +datum=WGS84 +no_defs +type=crs");
+ "+proj=longlat +over +datum=WGS84 +no_defs +type=crs");
}
{
@@ -11476,6 +11530,59 @@ TEST(json_import, geographic_crs) {
// ---------------------------------------------------------------------------
+TEST(json_import, spherical_planetocentric) {
+ const auto json = "{\n"
+ " \"$schema\": \"foo\",\n"
+ " \"type\": \"GeodeticCRS\",\n"
+ " \"name\": \"Mercury (2015) / Ocentric\",\n"
+ " \"datum\": {\n"
+ " \"type\": \"GeodeticReferenceFrame\",\n"
+ " \"name\": \"Mercury (2015)\",\n"
+ " \"anchor\": \"Hun Kal: 20.0\",\n"
+ " \"ellipsoid\": {\n"
+ " \"name\": \"Mercury (2015)\",\n"
+ " \"semi_major_axis\": 2440530,\n"
+ " \"inverse_flattening\": 1075.12334801762\n"
+ " },\n"
+ " \"prime_meridian\": {\n"
+ " \"name\": \"Reference Meridian\",\n"
+ " \"longitude\": 0\n"
+ " }\n"
+ " },\n"
+ " \"coordinate_system\": {\n"
+ " \"subtype\": \"spherical\",\n"
+ " \"axis\": [\n"
+ " {\n"
+ " \"name\": \"Planetocentric latitude\",\n"
+ " \"abbreviation\": \"U\",\n"
+ " \"direction\": \"north\",\n"
+ " \"unit\": \"degree\"\n"
+ " },\n"
+ " {\n"
+ " \"name\": \"Planetocentric longitude\",\n"
+ " \"abbreviation\": \"V\",\n"
+ " \"direction\": \"east\",\n"
+ " \"unit\": \"degree\"\n"
+ " }\n"
+ " ]\n"
+ " },\n"
+ " \"id\": {\n"
+ " \"authority\": \"IAU\",\n"
+ " \"code\": 19902\n"
+ " },\n"
+ " \"remarks\": \"Source of IAU Coordinate systems: "
+ "doi://10.1007/s10569-017-9805-5\"\n"
+ "}";
+ auto obj = createFromUserInput(json, nullptr);
+ auto gcrs = nn_dynamic_pointer_cast<GeodeticCRS>(obj);
+ ASSERT_TRUE(gcrs != nullptr);
+ EXPECT_TRUE(gcrs->isSphericalPlanetocentric());
+ EXPECT_EQ(gcrs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))),
+ json);
+}
+
+// ---------------------------------------------------------------------------
+
TEST(json_import, geographic_crs_errors) {
EXPECT_THROW(
createFromUserInput(