diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-01-04 19:25:04 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-01-04 19:25:04 +0100 |
| commit | b62fdee0f34d960527af8fb0a8bf6344fcf78d4b (patch) | |
| tree | 0341b02ba45f0a3d1761adde97d3c58a220e73ac /src/iso19111 | |
| parent | d89a6ab2f3f26d1451971369b0ccfc4eb322729d (diff) | |
| download | PROJ-b62fdee0f34d960527af8fb0a8bf6344fcf78d4b.tar.gz PROJ-b62fdee0f34d960527af8fb0a8bf6344fcf78d4b.zip | |
WKT export: no longer export Geographic 3D CRS in WKT1, unless strict mode is disabled
Diffstat (limited to 'src/iso19111')
| -rw-r--r-- | src/iso19111/c_api.cpp | 2 | ||||
| -rw-r--r-- | src/iso19111/crs.cpp | 23 | ||||
| -rw-r--r-- | src/iso19111/io.cpp | 3 |
3 files changed, 20 insertions, 8 deletions
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index c3c2fa39..70488de4 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -1245,6 +1245,8 @@ const char *proj_as_wkt(PJ_CONTEXT *ctx, const PJ *obj, PJ_WKT_TYPE type, ? WKTFormatter::OutputAxisRule::YES : WKTFormatter::OutputAxisRule::NO); } + } else if ((value = getOptionValue(*iter, "STRICT="))) { + formatter->setStrict(ci_equal(value, "YES")); } else { std::string msg("Unknown option :"); msg += *iter; diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp index eec36fee..190291de 100644 --- a/src/iso19111/crs.cpp +++ b/src/iso19111/crs.cpp @@ -1046,17 +1046,21 @@ GeodeticCRS::create(const util::PropertyMap &properties, //! @cond Doxygen_Suppress void GeodeticCRS::_exportToWKT(io::WKTFormatter *formatter) const { const bool isWKT2 = formatter->version() == io::WKTFormatter::Version::WKT2; - formatter->startNode(isWKT2 ? ((formatter->use2018Keywords() && - dynamic_cast<const GeographicCRS *>(this)) - ? io::WKTConstants::GEOGCRS - : io::WKTConstants::GEODCRS) - : isGeocentric() ? io::WKTConstants::GEOCCS - : io::WKTConstants::GEOGCS, + const bool isGeographic = + dynamic_cast<const GeographicCRS *>(this) != nullptr; + formatter->startNode(isWKT2 + ? ((formatter->use2018Keywords() && isGeographic) + ? io::WKTConstants::GEOGCRS + : io::WKTConstants::GEODCRS) + : isGeocentric() ? io::WKTConstants::GEOCCS + : io::WKTConstants::GEOGCS, !identifiers().empty()); auto l_name = nameStr(); const auto &cs = coordinateSystem(); const auto &axisList = cs->axisList(); + const auto oldAxisOutputRule = formatter->outputAxis(); + if (formatter->useESRIDialect()) { if (axisList.size() != 2) { io::FormattingException::Throw( @@ -1083,7 +1087,13 @@ void GeodeticCRS::_exportToWKT(io::WKTFormatter *formatter) const { } } } + } else if (!isWKT2 && formatter->isStrict() && isGeographic && + axisList.size() != 2 && + oldAxisOutputRule != io::WKTFormatter::OutputAxisRule::NO) { + io::FormattingException::Throw( + "WKT1 does not support Geographic 3D CRS."); } + if (!isWKT2 && !formatter->useESRIDialect() && isDeprecated()) { l_name += " (deprecated)"; } @@ -1098,7 +1108,6 @@ void GeodeticCRS::_exportToWKT(io::WKTFormatter *formatter) const { unit._exportToWKT(formatter); } - const auto oldAxisOutputRule = formatter->outputAxis(); if (oldAxisOutputRule == io::WKTFormatter::OutputAxisRule::WKT1_GDAL_EPSG_STYLE && isGeocentric()) { diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index 6a2c3e1a..cfccd70f 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -239,7 +239,8 @@ WKTFormatter::setOutputAxis(OutputAxisRule outputAxisIn) noexcept { /** \brief Set whether the formatter should operate on strict more or not. * - * The default is strit mode, in which case a FormattingException can be thrown. + * The default is strict mode, in which case a FormattingException can be + * thrown. */ WKTFormatter &WKTFormatter::setStrict(bool strictIn) noexcept { d->params_.strict_ = strictIn; |
