aboutsummaryrefslogtreecommitdiff
path: root/test/unit/test_io.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-09-08 12:50:37 +0200
committerEven Rouault <even.rouault@spatialys.com>2021-09-08 17:05:45 +0200
commit85733181ee7c2777139f5d1db94f2beabb737e96 (patch)
tree2936c5f142c390bae34388925fbed74d0ad520a6 /test/unit/test_io.cpp
parent5527b10ed140e20fac8e183317514fd59e4c8b99 (diff)
downloadPROJ-85733181ee7c2777139f5d1db94f2beabb737e96.tar.gz
PROJ-85733181ee7c2777139f5d1db94f2beabb737e96.zip
createOperations(): deal with spherical planetocentric geodetic CRS
This also fixes conversion between geocentric latlong and geodetic latlong with cs2cs. This was dealt with in PR 1093, but in the wrong direction (the geocentric latitude must be <= in absolute value to the geodetic one) The issue here was linked to the semantics of the +geoc specifier, which affects the semantics of the input coordinates in the forward direction (+geoc means that the input coordinate is is a geocentric latitude), which defeats the logic of doing A to B by using the inverse path of A and the forward path of B.
Diffstat (limited to 'test/unit/test_io.cpp')
-rw-r--r--test/unit/test_io.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp
index 96e3a849..791a8b9e 100644
--- a/test/unit/test_io.cpp
+++ b/test/unit/test_io.cpp
@@ -10063,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);
@@ -10209,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");
}
{