aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-07-09 15:45:28 +0200
committerEven Rouault <even.rouault@spatialys.com>2020-07-09 15:45:28 +0200
commit062c7f160f4b1d41f82730fa6eb6653e78ade74a (patch)
tree333112fdc326bd2318e87e77b697e66020e6192f
parent668fb0aacd46db2c4aaadb557b14443eee028405 (diff)
downloadPROJ-062c7f160f4b1d41f82730fa6eb6653e78ade74a.tar.gz
PROJ-062c7f160f4b1d41f82730fa6eb6653e78ade74a.zip
Transverse Mercator South Orientated: restrict export to PROJ string to cases where false_easting and false_northing are 0
-rw-r--r--src/iso19111/coordinateoperation.cpp19
-rw-r--r--test/unit/test_operation.cpp5
2 files changed, 22 insertions, 2 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp
index dd8658fb..3d5287a3 100644
--- a/src/iso19111/coordinateoperation.cpp
+++ b/src/iso19111/coordinateoperation.cpp
@@ -6165,6 +6165,25 @@ void Conversion::_exportToPROJString(
std::string("Unsupported value for ") +
EPSG_NAME_PARAMETER_LATITUDE_OF_NATURAL_ORIGIN);
}
+ } else if (methodEPSGCode ==
+ EPSG_CODE_METHOD_TRANSVERSE_MERCATOR_SOUTH_ORIENTATED) {
+ // We map TMSO to tmerc with axis=wsu. This only works if false easting
+ // and northings are zero, which is the case in practice for South
+ // African and Namibian EPSG CRS
+ const auto falseEasting = parameterValueNumeric(
+ EPSG_CODE_PARAMETER_FALSE_EASTING, common::UnitOfMeasure::METRE);
+ if (falseEasting != 0) {
+ throw io::FormattingException(
+ std::string("Unsupported value for ") +
+ EPSG_NAME_PARAMETER_FALSE_EASTING);
+ }
+ const auto falseNorthing = parameterValueNumeric(
+ EPSG_CODE_PARAMETER_FALSE_NORTHING, common::UnitOfMeasure::METRE);
+ if (falseNorthing != 0) {
+ throw io::FormattingException(
+ std::string("Unsupported value for ") +
+ EPSG_NAME_PARAMETER_FALSE_NORTHING);
+ }
// PROJ.4 specific hack for webmercator
} else if (formatter->getCRSExport() &&
methodEPSGCode ==
diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp
index 6a39879a..0238638d 100644
--- a/test/unit/test_operation.cpp
+++ b/test/unit/test_operation.cpp
@@ -1342,8 +1342,9 @@ TEST(operation, tmerc_south_oriented_export) {
PropertyMap(), Angle(1), Angle(2), Scale(3), Length(4), Length(5));
EXPECT_TRUE(conv->validateParameters().empty());
- EXPECT_EQ(conv->exportToPROJString(PROJStringFormatter::create().get()),
- "+proj=tmerc +axis=wsu +lat_0=1 +lon_0=2 +k=3 +x_0=4 +y_0=5");
+ // False easting/northing != 0 not supported
+ EXPECT_THROW(conv->exportToPROJString(PROJStringFormatter::create().get()),
+ FormattingException);
EXPECT_EQ(conv->exportToWKT(WKTFormatter::create().get()),
"CONVERSION[\"Transverse Mercator (South Orientated)\",\n"