aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2022-03-16 00:21:00 +0100
committerGitHub <noreply@github.com>2022-03-16 00:21:00 +0100
commita2d45bb42cfabf0b5b82b8448f42dc27cf0fe76e (patch)
tree10f58ee3578d5faf6c9795f0ef76a4cc3ac263e7
parent8f614bb9e4b7628f5363ccb48a33ba771704b988 (diff)
parentefc958e953b8c4a7fe9eaa7015d94c8456968bd4 (diff)
downloadPROJ-a2d45bb42cfabf0b5b82b8448f42dc27cf0fe76e.tar.gz
PROJ-a2d45bb42cfabf0b5b82b8448f42dc27cf0fe76e.zip
Merge pull request #3110 from OSGeo/backport-3108-to-9.0
[Backport 9.0] createOperations(): fix issue in transformation northing,easting projected CRS -> +proj=longlat +lon_wrap (fixes #3095)
-rw-r--r--src/iso19111/crs.cpp3
-rw-r--r--test/unit/test_operationfactory.cpp26
2 files changed, 28 insertions, 1 deletions
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp
index 881aec0b..e4b8094f 100644
--- a/src/iso19111/crs.cpp
+++ b/src/iso19111/crs.cpp
@@ -4404,7 +4404,8 @@ void ProjectedCRS::addUnitConvertAndAxisSwap(io::PROJStringFormatter *formatter,
formatter->addParam("units", "m");
}
- if (!axisSpecFound && !formatter->getCRSExport()) {
+ if (!axisSpecFound &&
+ (!formatter->getCRSExport() || formatter->getLegacyCRSToCRSContext())) {
const auto &dir0 = axisList[0]->direction();
const auto &dir1 = axisList[1]->direction();
if (!(&dir0 == &cs::AxisDirection::EAST &&
diff --git a/test/unit/test_operationfactory.cpp b/test/unit/test_operationfactory.cpp
index 89c4e7c4..0c3ecae4 100644
--- a/test/unit/test_operationfactory.cpp
+++ b/test/unit/test_operationfactory.cpp
@@ -6569,6 +6569,32 @@ TEST(operation, createOperation_on_crs_with_bound_crs_and_wktext) {
// ---------------------------------------------------------------------------
+TEST(operation,
+ createOperation_fallback_to_proj4_strings_with_axis_inverted_projCRS) {
+ auto objSrc =
+ createFromUserInput("EPSG:2193", DatabaseContext::create(), false);
+ auto src = nn_dynamic_pointer_cast<CRS>(objSrc);
+ ASSERT_TRUE(src != nullptr);
+
+ auto objDest = PROJStringParser().createFromPROJString(
+ "+proj=longlat +ellps=WGS84 +lon_wrap=180 +type=crs");
+ auto dest = nn_dynamic_pointer_cast<GeographicCRS>(objDest);
+ ASSERT_TRUE(dest != nullptr);
+
+ auto op = CoordinateOperationFactory::create()->createOperation(
+ NN_CHECK_ASSERT(src), NN_CHECK_ASSERT(dest));
+ ASSERT_TRUE(op != nullptr);
+ EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()),
+ "+proj=pipeline "
+ "+step +proj=axisswap +order=2,1 "
+ "+step +inv +proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 "
+ "+x_0=1600000 +y_0=10000000 +ellps=GRS80 "
+ "+step +proj=longlat +ellps=WGS84 +lon_wrap=180 "
+ "+step +proj=unitconvert +xy_in=rad +xy_out=deg");
+}
+
+// ---------------------------------------------------------------------------
+
TEST(operation, compoundCRS_to_proj_string_with_non_metre_height) {
auto objSrc =
createFromUserInput("EPSG:6318+5703", DatabaseContext::create(), false);