Skip to content

Commit

Permalink
Merge 8763ea7 into 3e37b35
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Mar 24, 2019
2 parents 3e37b35 + 8763ea7 commit eb423bc
Show file tree
Hide file tree
Showing 10 changed files with 1,635 additions and 1,368 deletions.
6 changes: 6 additions & 0 deletions include/proj/coordinateoperation.hpp
Expand Up @@ -150,6 +150,8 @@ class PROJ_GCC_DLL CoordinateOperation : public common::ObjectUsage,

PROJ_DLL bool hasBallparkTransformation() const;

PROJ_DLL static const std::string OPERATION_VERSION_KEY;

protected:
PROJ_INTERNAL CoordinateOperation();
PROJ_INTERNAL CoordinateOperation(const CoordinateOperation &other);
Expand All @@ -171,6 +173,10 @@ class PROJ_GCC_DLL CoordinateOperation : public common::ObjectUsage,
const std::vector<metadata::PositionalAccuracyNNPtr> &accuracies);
PROJ_INTERNAL void setHasBallparkTransformation(bool b);

PROJ_INTERNAL void
setProperties(const util::PropertyMap
&properties); // throw(InvalidValueTypeException)

private:
PROJ_OPAQUE_PRIVATE_DATA
CoordinateOperation &operator=(const CoordinateOperation &other) = delete;
Expand Down
1 change: 1 addition & 0 deletions include/proj/internal/io_internal.hpp
Expand Up @@ -133,6 +133,7 @@ class WKTConstants {
static const std::string BASEENGCRS;
static const std::string BASEPARAMCRS;
static const std::string BASETIMECRS;
static const std::string VERSION;

// WKT2 alternate (longer or shorter)
static const std::string GEODETICCRS;
Expand Down
37 changes: 32 additions & 5 deletions src/iso19111/coordinateoperation.cpp
Expand Up @@ -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_{};
Expand Down Expand Up @@ -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;
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
11 changes: 11 additions & 0 deletions src/iso19111/io.cpp
Expand Up @@ -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;
}

Expand Down
12 changes: 12 additions & 0 deletions src/iso19111/static.cpp
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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

0 comments on commit eb423bc

Please sign in to comment.