diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-03-24 20:01:45 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-03-24 20:40:09 +0100 |
| commit | 8763ea7f01bd349df29c5c4ce3b4edd6252eff37 (patch) | |
| tree | a105baa2bb96e9474d618af3e4dba54f05338f7d /src/iso19111 | |
| parent | 3e37b354194b4d42acd247c32ca97e45ac40af1e (diff) | |
| download | PROJ-8763ea7f01bd349df29c5c4ce3b4edd6252eff37.tar.gz PROJ-8763ea7f01bd349df29c5c4ce3b4edd6252eff37.zip | |
WKT2 parser: update to OGC 18-010r6
- Allow ID[] in base CRS of Derived CRS
- Allow VERSION[] in non-conversion coordinate operations
- Use VERSION[] to set operationVersion member of CoordinateOperation
- Export operationVersion in WKT2:2018
Diffstat (limited to 'src/iso19111')
| -rw-r--r-- | src/iso19111/coordinateoperation.cpp | 37 | ||||
| -rw-r--r-- | src/iso19111/io.cpp | 11 | ||||
| -rw-r--r-- | src/iso19111/static.cpp | 12 |
3 files changed, 55 insertions, 5 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp index 57cf9832..80c1a572 100644 --- a/src/iso19111/coordinateoperation.cpp +++ b/src/iso19111/coordinateoperation.cpp @@ -756,6 +756,15 @@ void CoordinateOperation::setHasBallparkTransformation(bool b) { // --------------------------------------------------------------------------- +void CoordinateOperation::setProperties( + const util::PropertyMap &properties) // throw(InvalidValueTypeException) +{ + ObjectUsage::setProperties(properties); + properties.getStringValue(OPERATION_VERSION_KEY, d->operationVersion_); +} + +// --------------------------------------------------------------------------- + //! @cond Doxygen_Suppress struct OperationMethod::Private { util::optional<std::string> formula_{}; @@ -6175,17 +6184,17 @@ TransformationNNPtr Transformation::create( throw InvalidOperation( "Inconsistent number of parameters and parameter values"); } - auto conv = Transformation::nn_make_shared<Transformation>( + auto transf = Transformation::nn_make_shared<Transformation>( sourceCRSIn, targetCRSIn, interpolationCRSIn, methodIn, values, accuracies); - conv->assignSelf(conv); - conv->setProperties(properties); + transf->assignSelf(transf); + transf->setProperties(properties); std::string name; if (properties.getStringValue(common::IdentifiedObject::NAME_KEY, name) && ci_find(name, "ballpark") != std::string::npos) { - conv->setHasBallparkTransformation(true); + transf->setHasBallparkTransformation(true); } - return conv; + return transf; } // --------------------------------------------------------------------------- @@ -7653,6 +7662,15 @@ void SingleOperation::exportTransformationToWKT( formatter->addQuotedString(nameStr()); + if (isWKT2 && formatter->use2018Keywords()) { + const auto &version = operationVersion(); + if (version.has_value()) { + formatter->startNode(io::WKTConstants::VERSION, false); + formatter->addQuotedString(*version); + formatter->endNode(); + } + } + if (!formatter->abridgedTransformation()) { formatter->startNode(io::WKTConstants::SOURCECRS, false); l_sourceCRS->_exportToWKT(formatter); @@ -9310,6 +9328,15 @@ void ConcatenatedOperation::_exportToWKT(io::WKTFormatter *formatter) const { !identifiers().empty()); formatter->addQuotedString(nameStr()); + if (isWKT2 && formatter->use2018Keywords()) { + const auto &version = operationVersion(); + if (version.has_value()) { + formatter->startNode(io::WKTConstants::VERSION, false); + formatter->addQuotedString(*version); + formatter->endNode(); + } + } + formatter->startNode(io::WKTConstants::SOURCECRS, false); sourceCRS()->_exportToWKT(formatter); formatter->endNode(); diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index a160a4e3..220ee967 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -1581,6 +1581,17 @@ PropertyMap &WKTParser::Private::buildProperties(const WKTNodeNNPtr &node, } } + auto &versionNode = nodeP->lookForChild(WKTConstants::VERSION); + if (!isNull(versionNode)) { + const auto &versionChildren = versionNode->GP()->children(); + if (versionChildren.size() == 1) { + properties->set(CoordinateOperation::OPERATION_VERSION_KEY, + stripQuotes(versionChildren[0])); + } else { + ThrowNotRequiredNumberOfChildren(versionNode->GP()->value()); + } + } + return *properties; } diff --git a/src/iso19111/static.cpp b/src/iso19111/static.cpp index ef2635b5..824047f0 100644 --- a/src/iso19111/static.cpp +++ b/src/iso19111/static.cpp @@ -31,6 +31,7 @@ #endif #include "proj/common.hpp" +#include "proj/coordinateoperation.hpp" #include "proj/coordinatesystem.hpp" #include "proj/crs.hpp" #include "proj/datum.hpp" @@ -57,6 +58,7 @@ using namespace NS_PROJ::crs; using namespace NS_PROJ::datum; using namespace NS_PROJ::io; using namespace NS_PROJ::metadata; +using namespace NS_PROJ::operation; using namespace NS_PROJ::util; NS_PROJ_START @@ -271,6 +273,7 @@ DEFINE_WKT_CONSTANT(BASEVERTCRS); DEFINE_WKT_CONSTANT(BASEENGCRS); DEFINE_WKT_CONSTANT(BASEPARAMCRS); DEFINE_WKT_CONSTANT(BASETIMECRS); +DEFINE_WKT_CONSTANT(VERSION); DEFINE_WKT_CONSTANT(GEODETICCRS); DEFINE_WKT_CONSTANT(GEODETICDATUM); @@ -641,4 +644,13 @@ const GeographicCRSNNPtr // --------------------------------------------------------------------------- +/** \brief Key to set the operation version of a operation::CoordinateOperation + * + * The value is to be provided as a string. + */ +const std::string + operation::CoordinateOperation::OPERATION_VERSION_KEY("operationVersion"); + +// --------------------------------------------------------------------------- + NS_PROJ_END |
