aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-10-03 15:10:23 +0200
committerEven Rouault <even.rouault@spatialys.com>2019-10-03 15:10:57 +0200
commitc45855b38f701a66a96cbd3fe4534f6a52c393b1 (patch)
tree53b289953383caa461f925ff4a068ca819e304c9
parent1a0bb3c0f144219d5881783c4b807888add3092b (diff)
downloadPROJ-c45855b38f701a66a96cbd3fe4534f6a52c393b1.tar.gz
PROJ-c45855b38f701a66a96cbd3fe4534f6a52c393b1.zip
DerivedGeographicCRS: allow exporting +proj=ob_tran +o_proj=longlat to PROJ string
-rw-r--r--src/iso19111/crs.cpp12
-rw-r--r--test/unit/test_crs.cpp5
2 files changed, 16 insertions, 1 deletions
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp
index e4e05166..d0e23f95 100644
--- a/src/iso19111/crs.cpp
+++ b/src/iso19111/crs.cpp
@@ -4736,8 +4736,18 @@ void DerivedGeographicCRS::_exportToWKT(io::WKTFormatter *formatter) const {
// ---------------------------------------------------------------------------
void DerivedGeographicCRS::_exportToPROJString(
- io::PROJStringFormatter *) const // throw(io::FormattingException)
+ io::PROJStringFormatter *formatter) const // throw(io::FormattingException)
{
+ const auto &l_conv = derivingConversionRef();
+ const auto &methodName = l_conv->method()->nameStr();
+ if (methodName == "PROJ ob_tran o_proj=longlat" ||
+ methodName == "PROJ ob_tran o_proj=lonlat" ||
+ methodName == "PROJ ob_tran o_proj=latlong" ||
+ methodName == "PROJ ob_tran o_proj=latlon") {
+ l_conv->_exportToPROJString(formatter);
+ return;
+ }
+
throw io::FormattingException(
"DerivedGeographicCRS cannot be exported to PROJ string");
}
diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp
index 605df714..aee4dd73 100644
--- a/test/unit/test_crs.cpp
+++ b/test/unit/test_crs.cpp
@@ -4093,6 +4093,11 @@ TEST(crs, derivedGeographicCRS_to_PROJ) {
auto obj = WKTParser().createFromWKT(wkt);
auto crs = nn_dynamic_pointer_cast<DerivedGeographicCRS>(obj);
ASSERT_TRUE(crs != nullptr);
+ EXPECT_EQ(
+ crs->exportToPROJString(PROJStringFormatter::create().get()),
+ "+proj=ob_tran +o_proj=longlat +o_lat_p=52 +o_lon_p=-30 +lon_0=-25 "
+ "+datum=WGS84 +no_defs +type=crs");
+
auto op = CoordinateOperationFactory::create()->createOperation(
crs->baseCRS(), NN_NO_CHECK(crs));
ASSERT_TRUE(op != nullptr);