aboutsummaryrefslogtreecommitdiff
path: root/src/iso19111/crs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/iso19111/crs.cpp')
-rw-r--r--src/iso19111/crs.cpp275
1 files changed, 211 insertions, 64 deletions
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp
index 670d0c1a..4f2ab7c6 100644
--- a/src/iso19111/crs.cpp
+++ b/src/iso19111/crs.cpp
@@ -2265,6 +2265,7 @@ void VerticalCRS::_exportToWKT(io::WKTFormatter *formatter) const {
// ---------------------------------------------------------------------------
+//! @cond Doxygen_Suppress
void VerticalCRS::_exportToPROJString(
io::PROJStringFormatter *formatter) const // throw(io::FormattingException)
{
@@ -2284,6 +2285,36 @@ void VerticalCRS::_exportToPROJString(
}
}
}
+//! @endcond
+
+// ---------------------------------------------------------------------------
+
+//! @cond Doxygen_Suppress
+void VerticalCRS::_exportToJSON(
+ io::JSONFormatter *formatter) const // throw(io::FormattingException)
+{
+ auto &writer = formatter->writer();
+ auto objectContext(
+ formatter->MakeObjectContext("VerticalCRS", !identifiers().empty()));
+
+ writer.AddObjKey("name");
+ auto l_name = nameStr();
+ if (l_name.empty()) {
+ writer.Add("unnamed");
+ } else {
+ writer.Add(l_name);
+ }
+
+ writer.AddObjKey("datum");
+ datum()->_exportToJSON(formatter);
+
+ writer.AddObjKey("coordinate_system");
+ formatter->setOmitTypeInImmediateChild();
+ coordinateSystem()->_exportToJSON(formatter);
+
+ ObjectUsage::baseExportToJSON(formatter);
+}
+//! @endcond
// ---------------------------------------------------------------------------
@@ -2650,6 +2681,38 @@ void DerivedCRS::baseExportToWKT(io::WKTFormatter *formatter,
// ---------------------------------------------------------------------------
//! @cond Doxygen_Suppress
+void DerivedCRS::_exportToJSON(
+ io::JSONFormatter *formatter) const // throw(io::FormattingException)
+{
+ auto &writer = formatter->writer();
+ auto objectContext(
+ formatter->MakeObjectContext(className(), !identifiers().empty()));
+
+ writer.AddObjKey("name");
+ auto l_name = nameStr();
+ if (l_name.empty()) {
+ writer.Add("unnamed");
+ } else {
+ writer.Add(l_name);
+ }
+
+ writer.AddObjKey("base_crs");
+ baseCRS()->_exportToJSON(formatter);
+
+ writer.AddObjKey("conversion");
+ derivingConversionRef()->_exportToJSON(formatter);
+
+ writer.AddObjKey("coordinate_system");
+ formatter->setOmitTypeInImmediateChild();
+ coordinateSystem()->_exportToJSON(formatter);
+
+ ObjectUsage::baseExportToJSON(formatter);
+}
+//! @endcond
+
+// ---------------------------------------------------------------------------
+
+//! @cond Doxygen_Suppress
struct ProjectedCRS::Private {
GeodeticCRSNNPtr baseCRS_;
cs::CartesianCSNNPtr cs_;
@@ -3514,6 +3577,36 @@ void CompoundCRS::_exportToWKT(io::WKTFormatter *formatter) const {
// ---------------------------------------------------------------------------
+//! @cond Doxygen_Suppress
+void CompoundCRS::_exportToJSON(
+ io::JSONFormatter *formatter) const // throw(io::FormattingException)
+{
+ auto &writer = formatter->writer();
+ auto objectContext(
+ formatter->MakeObjectContext("CompoundCRS", !identifiers().empty()));
+
+ writer.AddObjKey("name");
+ auto l_name = nameStr();
+ if (l_name.empty()) {
+ writer.Add("unnamed");
+ } else {
+ writer.Add(l_name);
+ }
+
+ writer.AddObjKey("components");
+ {
+ auto componentsContext(writer.MakeArrayContext(false));
+ for (const auto &crs : componentReferenceSystems()) {
+ crs->_exportToJSON(formatter);
+ }
+ }
+
+ ObjectUsage::baseExportToJSON(formatter);
+}
+//! @endcond
+
+// ---------------------------------------------------------------------------
+
void CompoundCRS::_exportToPROJString(
io::PROJStringFormatter *formatter) const // throw(io::FormattingException)
{
@@ -4004,6 +4097,30 @@ void BoundCRS::_exportToWKT(io::WKTFormatter *formatter) const {
// ---------------------------------------------------------------------------
+//! @cond Doxygen_Suppress
+void BoundCRS::_exportToJSON(
+ io::JSONFormatter *formatter) const // throw(io::FormattingException)
+{
+ auto &writer = formatter->writer();
+ auto objectContext(
+ formatter->MakeObjectContext("BoundCRS", !identifiers().empty()));
+
+ writer.AddObjKey("source_crs");
+ d->baseCRS()->_exportToJSON(formatter);
+
+ writer.AddObjKey("target_crs");
+ d->hubCRS()->_exportToJSON(formatter);
+
+ writer.AddObjKey("transformation");
+ formatter->setOmitTypeInImmediateChild();
+ formatter->setAbridgedTransformation(true);
+ d->transformation()->_exportToJSON(formatter);
+ formatter->setAbridgedTransformation(false);
+}
+//! @endcond
+
+// ---------------------------------------------------------------------------
+
void BoundCRS::_exportToPROJString(
io::PROJStringFormatter *formatter) const // throw(io::FormattingException)
{
@@ -4298,38 +4415,6 @@ void DerivedGeodeticCRS::_exportToWKT(io::WKTFormatter *formatter) const {
// ---------------------------------------------------------------------------
-//! @cond Doxygen_Suppress
-void DerivedGeodeticCRS::_exportToJSON(
- io::JSONFormatter *formatter) const // throw(io::FormattingException)
-{
- auto &writer = formatter->writer();
- auto objectContext(formatter->MakeObjectContext("DerivedGeodeticCRS",
- !identifiers().empty()));
-
- writer.AddObjKey("name");
- auto l_name = nameStr();
- if (l_name.empty()) {
- writer.Add("unnamed");
- } else {
- writer.Add(l_name);
- }
-
- writer.AddObjKey("base_crs");
- baseCRS()->_exportToJSON(formatter);
-
- writer.AddObjKey("conversion");
- derivingConversionRef()->_exportToJSON(formatter);
-
- writer.AddObjKey("coordinate_system");
- formatter->setOmitTypeInImmediateChild();
- coordinateSystem()->_exportToJSON(formatter);
-
- ObjectUsage::baseExportToJSON(formatter);
-}
-//! @endcond
-
-// ---------------------------------------------------------------------------
-
void DerivedGeodeticCRS::_exportToPROJString(
io::PROJStringFormatter *) const // throw(io::FormattingException)
{
@@ -4468,38 +4553,6 @@ void DerivedGeographicCRS::_exportToWKT(io::WKTFormatter *formatter) const {
// ---------------------------------------------------------------------------
-//! @cond Doxygen_Suppress
-void DerivedGeographicCRS::_exportToJSON(
- io::JSONFormatter *formatter) const // throw(io::FormattingException)
-{
- auto &writer = formatter->writer();
- auto objectContext(formatter->MakeObjectContext("DerivedGeographicCRS",
- !identifiers().empty()));
-
- writer.AddObjKey("name");
- auto l_name = nameStr();
- if (l_name.empty()) {
- writer.Add("unnamed");
- } else {
- writer.Add(l_name);
- }
-
- writer.AddObjKey("base_crs");
- baseCRS()->_exportToJSON(formatter);
-
- writer.AddObjKey("conversion");
- derivingConversionRef()->_exportToJSON(formatter);
-
- writer.AddObjKey("coordinate_system");
- formatter->setOmitTypeInImmediateChild();
- coordinateSystem()->_exportToJSON(formatter);
-
- ObjectUsage::baseExportToJSON(formatter);
-}
-//! @endcond
-
-// ---------------------------------------------------------------------------
-
void DerivedGeographicCRS::_exportToPROJString(
io::PROJStringFormatter *) const // throw(io::FormattingException)
{
@@ -4756,6 +4809,35 @@ void TemporalCRS::_exportToWKT(io::WKTFormatter *formatter) const {
// ---------------------------------------------------------------------------
+//! @cond Doxygen_Suppress
+void TemporalCRS::_exportToJSON(
+ io::JSONFormatter *formatter) const // throw(io::FormattingException)
+{
+ auto &writer = formatter->writer();
+ auto objectContext(
+ formatter->MakeObjectContext("TemporalCRS", !identifiers().empty()));
+
+ writer.AddObjKey("name");
+ auto l_name = nameStr();
+ if (l_name.empty()) {
+ writer.Add("unnamed");
+ } else {
+ writer.Add(l_name);
+ }
+
+ writer.AddObjKey("datum");
+ datum()->_exportToJSON(formatter);
+
+ writer.AddObjKey("coordinate_system");
+ formatter->setOmitTypeInImmediateChild();
+ coordinateSystem()->_exportToJSON(formatter);
+
+ ObjectUsage::baseExportToJSON(formatter);
+}
+//! @endcond
+
+// ---------------------------------------------------------------------------
+
bool TemporalCRS::_isEquivalentTo(
const util::IComparable *other,
util::IComparable::Criterion criterion) const {
@@ -4864,6 +4946,35 @@ void EngineeringCRS::_exportToWKT(io::WKTFormatter *formatter) const {
// ---------------------------------------------------------------------------
+//! @cond Doxygen_Suppress
+void EngineeringCRS::_exportToJSON(
+ io::JSONFormatter *formatter) const // throw(io::FormattingException)
+{
+ auto &writer = formatter->writer();
+ auto objectContext(
+ formatter->MakeObjectContext("EngineeringCRS", !identifiers().empty()));
+
+ writer.AddObjKey("name");
+ auto l_name = nameStr();
+ if (l_name.empty()) {
+ writer.Add("unnamed");
+ } else {
+ writer.Add(l_name);
+ }
+
+ writer.AddObjKey("datum");
+ datum()->_exportToJSON(formatter);
+
+ writer.AddObjKey("coordinate_system");
+ formatter->setOmitTypeInImmediateChild();
+ coordinateSystem()->_exportToJSON(formatter);
+
+ ObjectUsage::baseExportToJSON(formatter);
+}
+//! @endcond
+
+// ---------------------------------------------------------------------------
+
bool EngineeringCRS::_isEquivalentTo(
const util::IComparable *other,
util::IComparable::Criterion criterion) const {
@@ -4966,6 +5077,35 @@ void ParametricCRS::_exportToWKT(io::WKTFormatter *formatter) const {
// ---------------------------------------------------------------------------
+//! @cond Doxygen_Suppress
+void ParametricCRS::_exportToJSON(
+ io::JSONFormatter *formatter) const // throw(io::FormattingException)
+{
+ auto &writer = formatter->writer();
+ auto objectContext(
+ formatter->MakeObjectContext("ParametricCRS", !identifiers().empty()));
+
+ writer.AddObjKey("name");
+ auto l_name = nameStr();
+ if (l_name.empty()) {
+ writer.Add("unnamed");
+ } else {
+ writer.Add(l_name);
+ }
+
+ writer.AddObjKey("datum");
+ datum()->_exportToJSON(formatter);
+
+ writer.AddObjKey("coordinate_system");
+ formatter->setOmitTypeInImmediateChild();
+ coordinateSystem()->_exportToJSON(formatter);
+
+ ObjectUsage::baseExportToJSON(formatter);
+}
+//! @endcond
+
+// ---------------------------------------------------------------------------
+
bool ParametricCRS::_isEquivalentTo(
const util::IComparable *other,
util::IComparable::Criterion criterion) const {
@@ -5160,6 +5300,13 @@ DerivedCRSTemplate<DerivedCRSTraits>::create(
// ---------------------------------------------------------------------------
+template <class DerivedCRSTraits>
+const char *DerivedCRSTemplate<DerivedCRSTraits>::className() const {
+ return DerivedCRSTraits::CRSName().c_str();
+}
+
+// ---------------------------------------------------------------------------
+
static void DerivedCRSTemplateCheckExportToWKT(io::WKTFormatter *formatter,
const std::string &crsName,
bool wkt2_2018_only) {