aboutsummaryrefslogtreecommitdiff
path: root/src/iso19111/coordinateoperation.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-04-24 11:23:40 +0200
committerGitHub <noreply@github.com>2020-04-24 11:23:40 +0200
commit83ca01b4eadfd19b86f87751d3eaaa3351330569 (patch)
tree9435daffab783694f372b5c4a194c8cd35f90046 /src/iso19111/coordinateoperation.cpp
parent0fc46e917542c966f47539a173660359d2b49c25 (diff)
parentdd2dd6cd2eb842e7f0a4abf89681a559cbb6751e (diff)
downloadPROJ-83ca01b4eadfd19b86f87751d3eaaa3351330569.tar.gz
PROJ-83ca01b4eadfd19b86f87751d3eaaa3351330569.zip
Merge pull request #2188 from rouault/backport_6_3_pr2183
[Backport 6.3] io.hpp: avoid dependency to proj_json_streaming_writer.hpp (fixes #2182)
Diffstat (limited to 'src/iso19111/coordinateoperation.cpp')
-rw-r--r--src/iso19111/coordinateoperation.cpp98
1 files changed, 50 insertions, 48 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp
index 97d210f0..4ae67e77 100644
--- a/src/iso19111/coordinateoperation.cpp
+++ b/src/iso19111/coordinateoperation.cpp
@@ -48,6 +48,8 @@
#include "proj_internal.h" // M_PI
// clang-format on
+#include "proj_json_streaming_writer.hpp"
+
#include <algorithm>
#include <cassert>
#include <cmath>
@@ -1052,12 +1054,12 @@ void OperationMethod::_exportToWKT(io::WKTFormatter *formatter) const {
void OperationMethod::_exportToJSON(
io::JSONFormatter *formatter) const // throw(FormattingException)
{
- auto &writer = formatter->writer();
+ auto writer = formatter->writer();
auto objectContext(formatter->MakeObjectContext("OperationMethod",
!identifiers().empty()));
- writer.AddObjKey("name");
- writer.Add(nameStr());
+ writer->AddObjKey("name");
+ writer->Add(nameStr());
if (formatter->outputId()) {
formatID(formatter);
@@ -1247,29 +1249,29 @@ void OperationParameterValue::_exportToWKT(io::WKTFormatter *formatter,
//! @cond Doxygen_Suppress
void OperationParameterValue::_exportToJSON(
io::JSONFormatter *formatter) const {
- auto &writer = formatter->writer();
+ auto writer = formatter->writer();
auto objectContext(formatter->MakeObjectContext(
"ParameterValue", !parameter()->identifiers().empty()));
- writer.AddObjKey("name");
- writer.Add(parameter()->nameStr());
+ writer->AddObjKey("name");
+ writer->Add(parameter()->nameStr());
const auto &l_value(parameterValue());
if (l_value->type() == ParameterValue::Type::MEASURE) {
- writer.AddObjKey("value");
- writer.Add(l_value->value().value(), 15);
- writer.AddObjKey("unit");
+ writer->AddObjKey("value");
+ writer->Add(l_value->value().value(), 15);
+ writer->AddObjKey("unit");
const auto &l_unit(l_value->value().unit());
if (l_unit == common::UnitOfMeasure::METRE ||
l_unit == common::UnitOfMeasure::DEGREE ||
l_unit == common::UnitOfMeasure::SCALE_UNITY) {
- writer.Add(l_unit.name());
+ writer->Add(l_unit.name());
} else {
l_unit._exportToJSON(formatter);
}
} else if (l_value->type() == ParameterValue::Type::FILENAME) {
- writer.AddObjKey("value");
- writer.Add(l_value->valueFile());
+ writer->AddObjKey("value");
+ writer->Add(l_value->valueFile());
}
if (formatter->outputId()) {
@@ -5763,28 +5765,28 @@ void Conversion::_exportToWKT(io::WKTFormatter *formatter) const {
void Conversion::_exportToJSON(
io::JSONFormatter *formatter) const // throw(FormattingException)
{
- auto &writer = formatter->writer();
+ auto writer = formatter->writer();
auto objectContext(
formatter->MakeObjectContext("Conversion", !identifiers().empty()));
- writer.AddObjKey("name");
+ writer->AddObjKey("name");
auto l_name = nameStr();
if (l_name.empty()) {
- writer.Add("unnamed");
+ writer->Add("unnamed");
} else {
- writer.Add(l_name);
+ writer->Add(l_name);
}
- writer.AddObjKey("method");
+ writer->AddObjKey("method");
formatter->setOmitTypeInImmediateChild();
formatter->setAllowIDInImmediateChild();
method()->_exportToJSON(formatter);
const auto &l_parameterValues = parameterValues();
if (!l_parameterValues.empty()) {
- writer.AddObjKey("parameters");
+ writer->AddObjKey("parameters");
{
- auto parametersContext(writer.MakeArrayContext(false));
+ auto parametersContext(writer->MakeArrayContext(false));
for (const auto &genOpParamvalue : l_parameterValues) {
formatter->setAllowIDInImmediateChild();
formatter->setOmitTypeInImmediateChild();
@@ -8229,45 +8231,45 @@ void Transformation::_exportToWKT(io::WKTFormatter *formatter) const {
void Transformation::_exportToJSON(
io::JSONFormatter *formatter) const // throw(FormattingException)
{
- auto &writer = formatter->writer();
+ auto writer = formatter->writer();
auto objectContext(formatter->MakeObjectContext(
formatter->abridgedTransformation() ? "AbridgedTransformation"
: "Transformation",
!identifiers().empty()));
- writer.AddObjKey("name");
+ writer->AddObjKey("name");
auto l_name = nameStr();
if (l_name.empty()) {
- writer.Add("unnamed");
+ writer->Add("unnamed");
} else {
- writer.Add(l_name);
+ writer->Add(l_name);
}
if (!formatter->abridgedTransformation()) {
- writer.AddObjKey("source_crs");
+ writer->AddObjKey("source_crs");
formatter->setAllowIDInImmediateChild();
sourceCRS()->_exportToJSON(formatter);
- writer.AddObjKey("target_crs");
+ writer->AddObjKey("target_crs");
formatter->setAllowIDInImmediateChild();
targetCRS()->_exportToJSON(formatter);
const auto &l_interpolationCRS = interpolationCRS();
if (l_interpolationCRS) {
- writer.AddObjKey("interpolation_crs");
+ writer->AddObjKey("interpolation_crs");
formatter->setAllowIDInImmediateChild();
l_interpolationCRS->_exportToJSON(formatter);
}
}
- writer.AddObjKey("method");
+ writer->AddObjKey("method");
formatter->setOmitTypeInImmediateChild();
formatter->setAllowIDInImmediateChild();
method()->_exportToJSON(formatter);
- writer.AddObjKey("parameters");
+ writer->AddObjKey("parameters");
{
- auto parametersContext(writer.MakeArrayContext(false));
+ auto parametersContext(writer->MakeArrayContext(false));
for (const auto &genOpParamvalue : parameterValues()) {
formatter->setAllowIDInImmediateChild();
formatter->setOmitTypeInImmediateChild();
@@ -8277,8 +8279,8 @@ void Transformation::_exportToJSON(
if (!formatter->abridgedTransformation()) {
if (!coordinateOperationAccuracies().empty()) {
- writer.AddObjKey("accuracy");
- writer.Add(coordinateOperationAccuracies()[0]->value());
+ writer->AddObjKey("accuracy");
+ writer->Add(coordinateOperationAccuracies()[0]->value());
}
}
@@ -10177,29 +10179,29 @@ void ConcatenatedOperation::_exportToWKT(io::WKTFormatter *formatter) const {
void ConcatenatedOperation::_exportToJSON(
io::JSONFormatter *formatter) const // throw(FormattingException)
{
- auto &writer = formatter->writer();
+ auto writer = formatter->writer();
auto objectContext(formatter->MakeObjectContext("ConcatenatedOperation",
!identifiers().empty()));
- writer.AddObjKey("name");
+ writer->AddObjKey("name");
auto l_name = nameStr();
if (l_name.empty()) {
- writer.Add("unnamed");
+ writer->Add("unnamed");
} else {
- writer.Add(l_name);
+ writer->Add(l_name);
}
- writer.AddObjKey("source_crs");
+ writer->AddObjKey("source_crs");
formatter->setAllowIDInImmediateChild();
sourceCRS()->_exportToJSON(formatter);
- writer.AddObjKey("target_crs");
+ writer->AddObjKey("target_crs");
formatter->setAllowIDInImmediateChild();
targetCRS()->_exportToJSON(formatter);
- writer.AddObjKey("steps");
+ writer->AddObjKey("steps");
{
- auto parametersContext(writer.MakeArrayContext(false));
+ auto parametersContext(writer->MakeArrayContext(false));
for (const auto &operation : operations()) {
formatter->setAllowIDInImmediateChild();
operation->_exportToJSON(formatter);
@@ -15145,39 +15147,39 @@ void PROJBasedOperation::_exportToWKT(io::WKTFormatter *formatter) const {
void PROJBasedOperation::_exportToJSON(
io::JSONFormatter *formatter) const // throw(FormattingException)
{
- auto &writer = formatter->writer();
+ auto writer = formatter->writer();
auto objectContext(formatter->MakeObjectContext(
(sourceCRS() && targetCRS()) ? "Transformation" : "Conversion",
!identifiers().empty()));
- writer.AddObjKey("name");
+ writer->AddObjKey("name");
auto l_name = nameStr();
if (l_name.empty()) {
- writer.Add("unnamed");
+ writer->Add("unnamed");
} else {
- writer.Add(l_name);
+ writer->Add(l_name);
}
if (sourceCRS() && targetCRS()) {
- writer.AddObjKey("source_crs");
+ writer->AddObjKey("source_crs");
formatter->setAllowIDInImmediateChild();
sourceCRS()->_exportToJSON(formatter);
- writer.AddObjKey("target_crs");
+ writer->AddObjKey("target_crs");
formatter->setAllowIDInImmediateChild();
targetCRS()->_exportToJSON(formatter);
}
- writer.AddObjKey("method");
+ writer->AddObjKey("method");
formatter->setOmitTypeInImmediateChild();
formatter->setAllowIDInImmediateChild();
method()->_exportToJSON(formatter);
const auto &l_parameterValues = parameterValues();
if (!l_parameterValues.empty()) {
- writer.AddObjKey("parameters");
+ writer->AddObjKey("parameters");
{
- auto parametersContext(writer.MakeArrayContext(false));
+ auto parametersContext(writer->MakeArrayContext(false));
for (const auto &genOpParamvalue : l_parameterValues) {
formatter->setAllowIDInImmediateChild();
formatter->setOmitTypeInImmediateChild();