aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-07-06 17:06:23 +0200
committerEven Rouault <even.rouault@spatialys.com>2019-07-08 00:05:00 +0200
commitece151aed1b4bf2634de5759f37fd7bc005e8313 (patch)
tree8e2e38daaffc878cc3ba673857e66274555e3dcc /include
parent17f0b0b3bc65ffba39bf6f22a12b2cc7fcb9bafd (diff)
downloadPROJ-ece151aed1b4bf2634de5759f37fd7bc005e8313.tar.gz
PROJ-ece151aed1b4bf2634de5759f37fd7bc005e8313.zip
CRS JSON: export GeographicCRS and Projected CRS
Diffstat (limited to 'include')
-rw-r--r--include/proj/common.hpp11
-rw-r--r--include/proj/coordinateoperation.hpp19
-rw-r--r--include/proj/coordinatesystem.hpp13
-rw-r--r--include/proj/crs.hpp21
-rw-r--r--include/proj/datum.hpp12
-rw-r--r--include/proj/io.hpp21
6 files changed, 86 insertions, 11 deletions
diff --git a/include/proj/common.hpp b/include/proj/common.hpp
index d857dafd..0a1f5d19 100644
--- a/include/proj/common.hpp
+++ b/include/proj/common.hpp
@@ -330,10 +330,13 @@ class PROJ_GCC_DLL IdentifiedObject : public util::BaseObject,
//! @cond Doxygen_Suppress
void
formatID(io::WKTFormatter *formatter) const;
- PROJ_INTERNAL void formatRemarks(io::WKTFormatter *formatter) const;
PROJ_INTERNAL void formatID(io::JSONFormatter *formatter) const;
+ PROJ_INTERNAL void formatRemarks(io::WKTFormatter *formatter) const;
+
+ PROJ_INTERNAL void formatRemarks(io::JSONFormatter *formatter) const;
+
PROJ_INTERNAL bool
_isEquivalentTo(const util::IComparable *other,
util::IComparable::Criterion criterion =
@@ -394,6 +397,9 @@ class PROJ_GCC_DLL ObjectDomain : public util::BaseObject,
_exportToWKT(io::WKTFormatter *formatter)
const; // throw(io::FormattingException)
+ PROJ_INTERNAL void _exportToJSON(
+ io::JSONFormatter *formatter) const; // throw(FormattingException)
+
bool
_isEquivalentTo(const util::IComparable *other,
util::IComparable::Criterion criterion =
@@ -455,6 +461,9 @@ class PROJ_GCC_DLL ObjectUsage : public IdentifiedObject {
void baseExportToWKT(
io::WKTFormatter *formatter) const; // throw(io::FormattingException)
+ void baseExportToJSON(
+ io::JSONFormatter *formatter) const; // throw(io::FormattingException)
+
private:
PROJ_OPAQUE_PRIVATE_DATA
ObjectUsage &operator=(const ObjectUsage &other) = delete;
diff --git a/include/proj/coordinateoperation.hpp b/include/proj/coordinateoperation.hpp
index 7ade26f2..9b2dfe64 100644
--- a/include/proj/coordinateoperation.hpp
+++ b/include/proj/coordinateoperation.hpp
@@ -291,6 +291,7 @@ struct MethodMapping;
*/
class PROJ_GCC_DLL GeneralParameterValue : public util::BaseObject,
public io::IWKTExportable,
+ public io::IJSONExportable,
public util::IComparable {
public:
//! @cond Doxygen_Suppress
@@ -299,6 +300,9 @@ class PROJ_GCC_DLL GeneralParameterValue : public util::BaseObject,
PROJ_INTERNAL void _exportToWKT(io::WKTFormatter *formatter)
const override = 0; // throw(io::FormattingException)
+ PROJ_INTERNAL void _exportToJSON(io::JSONFormatter *formatter)
+ const override = 0; // throw(FormattingException)
+
PROJ_INTERNAL bool _isEquivalentTo(
const util::IComparable *other,
util::IComparable::Criterion criterion =
@@ -442,6 +446,9 @@ class PROJ_GCC_DLL OperationParameterValue final
PROJ_INTERNAL void _exportToWKT(io::WKTFormatter *formatter)
const override; // throw(io::FormattingException)
+ PROJ_INTERNAL void _exportToJSON(io::JSONFormatter *formatter)
+ const override; // throw(FormattingException)
+
PROJ_INTERNAL bool
_isEquivalentTo(const util::IComparable *other,
util::IComparable::Criterion criterion =
@@ -481,7 +488,8 @@ using OperationMethodNNPtr = util::nn<OperationMethodPtr>;
*
* \remark Implements OperationMethod from \ref ISO_19111_2019
*/
-class PROJ_GCC_DLL OperationMethod : public common::IdentifiedObject {
+class PROJ_GCC_DLL OperationMethod : public common::IdentifiedObject,
+ public io::IJSONExportable {
public:
//! @cond Doxygen_Suppress
PROJ_DLL ~OperationMethod() override;
@@ -507,6 +515,9 @@ class PROJ_GCC_DLL OperationMethod : public common::IdentifiedObject {
PROJ_INTERNAL void _exportToWKT(io::WKTFormatter *formatter)
const override; // throw(io::FormattingException)
+ PROJ_INTERNAL void _exportToJSON(io::JSONFormatter *formatter)
+ const override; // throw(FormattingException)
+
PROJ_INTERNAL bool
_isEquivalentTo(const util::IComparable *other,
util::IComparable::Criterion criterion =
@@ -838,7 +849,8 @@ EPSG:8833
*/
-class PROJ_GCC_DLL Conversion : public SingleOperation {
+class PROJ_GCC_DLL Conversion : public SingleOperation,
+ public io::IJSONExportable {
public:
//! @cond Doxygen_Suppress
PROJ_DLL ~Conversion() override;
@@ -1315,6 +1327,9 @@ class PROJ_GCC_DLL Conversion : public SingleOperation {
_exportToPROJString(io::PROJStringFormatter *formatter)
const override; // throw(FormattingException)
+ PROJ_INTERNAL void _exportToJSON(io::JSONFormatter *formatter)
+ const override; // throw(FormattingException)
+
PROJ_INTERNAL const char *getESRIMethodName() const;
PROJ_INTERNAL const char *getWKT1GDALMethodName() const;
diff --git a/include/proj/coordinatesystem.hpp b/include/proj/coordinatesystem.hpp
index ea1c1f99..ffb908fc 100644
--- a/include/proj/coordinatesystem.hpp
+++ b/include/proj/coordinatesystem.hpp
@@ -165,8 +165,8 @@ using CoordinateSystemAxisNNPtr = util::nn<CoordinateSystemAxisPtr>;
*
* \remark Implements CoordinateSystemAxis from \ref ISO_19111_2019
*/
-class PROJ_GCC_DLL CoordinateSystemAxis final
- : public common::IdentifiedObject {
+class PROJ_GCC_DLL CoordinateSystemAxis final : public common::IdentifiedObject,
+ public io::IJSONExportable {
public:
//! @cond Doxygen_Suppress
PROJ_DLL ~CoordinateSystemAxis() override;
@@ -201,6 +201,9 @@ class PROJ_GCC_DLL CoordinateSystemAxis final
PROJ_INTERNAL void _exportToWKT(io::WKTFormatter *formatter)
const override; // throw(io::FormattingException)
+ PROJ_INTERNAL void _exportToJSON(io::JSONFormatter *formatter)
+ const override; // throw(FormattingException)
+
PROJ_INTERNAL static std::string normalizeAxisName(const std::string &str);
PROJ_INTERNAL static CoordinateSystemAxisNNPtr
@@ -235,7 +238,8 @@ class PROJ_GCC_DLL CoordinateSystemAxis final
*
* \remark Implements CoordinateSystem from \ref ISO_19111_2019
*/
-class PROJ_GCC_DLL CoordinateSystem : public common::IdentifiedObject {
+class PROJ_GCC_DLL CoordinateSystem : public common::IdentifiedObject,
+ public io::IJSONExportable {
public:
//! @cond Doxygen_Suppress
PROJ_DLL ~CoordinateSystem() override;
@@ -251,6 +255,9 @@ class PROJ_GCC_DLL CoordinateSystem : public common::IdentifiedObject {
_exportToWKT(io::WKTFormatter *formatter)
const override; // throw(io::FormattingException)
+ PROJ_INTERNAL void _exportToJSON(io::JSONFormatter *formatter)
+ const override; // throw(FormattingException)
+
PROJ_INTERNAL virtual std::string getWKT2Type(bool) const = 0;
PROJ_INTERNAL bool
diff --git a/include/proj/crs.hpp b/include/proj/crs.hpp
index 33bf3b61..702b2d36 100644
--- a/include/proj/crs.hpp
+++ b/include/proj/crs.hpp
@@ -211,7 +211,8 @@ using GeodeticCRSNNPtr = util::nn<GeodeticCRSPtr>;
* \remark Implements GeodeticCRS from \ref ISO_19111_2019
*/
class PROJ_GCC_DLL GeodeticCRS : virtual public SingleCRS,
- public io::IPROJStringExportable {
+ public io::IPROJStringExportable,
+ public io::IJSONExportable {
public:
//! @cond Doxygen_Suppress
PROJ_DLL ~GeodeticCRS() override;
@@ -273,6 +274,9 @@ class PROJ_GCC_DLL GeodeticCRS : virtual public SingleCRS,
PROJ_INTERNAL void _exportToPROJString(io::PROJStringFormatter *formatter)
const override; // throw(FormattingException)
+ PROJ_INTERNAL void _exportToJSON(io::JSONFormatter *formatter)
+ const override; // throw(FormattingException)
+
PROJ_INTERNAL bool
_isEquivalentTo(const util::IComparable *other,
util::IComparable::Criterion criterion =
@@ -353,6 +357,9 @@ class PROJ_GCC_DLL GeographicCRS : public GeodeticCRS {
PROJ_INTERNAL void _exportToPROJString(io::PROJStringFormatter *formatter)
const override; // throw(FormattingException)
+ PROJ_INTERNAL void _exportToJSON(io::JSONFormatter *formatter)
+ const override; // throw(FormattingException)
+
PROJ_DLL bool
is2DPartOf3D(util::nn<const GeographicCRS *> other) PROJ_PURE_DECL;
@@ -546,7 +553,8 @@ using ProjectedCRSNNPtr = util::nn<ProjectedCRSPtr>;
* \remark Implements ProjectedCRS from \ref ISO_19111_2019
*/
class PROJ_GCC_DLL ProjectedCRS final : public DerivedCRS,
- public io::IPROJStringExportable {
+ public io::IPROJStringExportable,
+ public io::IJSONExportable {
public:
//! @cond Doxygen_Suppress
PROJ_DLL ~ProjectedCRS() override;
@@ -573,6 +581,9 @@ class PROJ_GCC_DLL ProjectedCRS final : public DerivedCRS,
PROJ_INTERNAL void _exportToWKT(io::WKTFormatter *formatter)
const override; // throw(io::FormattingException)
+ PROJ_INTERNAL void _exportToJSON(io::JSONFormatter *formatter)
+ const override; // throw(FormattingException)
+
PROJ_FOR_TEST ProjectedCRSNNPtr alterParametersLinearUnit(
const common::UnitOfMeasure &unit, bool convertToNewUnit) const;
@@ -965,6 +976,9 @@ class PROJ_GCC_DLL DerivedGeodeticCRS final : public GeodeticCRS,
//! @cond Doxygen_Suppress
void _exportToWKT(io::WKTFormatter *formatter)
const override; // throw(io::FormattingException)
+
+ PROJ_INTERNAL void _exportToJSON(io::JSONFormatter *formatter)
+ const override; // throw(FormattingException)
//! @endcond
protected:
@@ -1034,6 +1048,9 @@ class PROJ_GCC_DLL DerivedGeographicCRS final : public GeographicCRS,
//! @cond Doxygen_Suppress
PROJ_INTERNAL void _exportToWKT(io::WKTFormatter *formatter)
const override; // throw(io::FormattingException)
+
+ PROJ_INTERNAL void _exportToJSON(io::JSONFormatter *formatter)
+ const override; // throw(FormattingException)
//! @endcond
protected:
diff --git a/include/proj/datum.hpp b/include/proj/datum.hpp
index 47bab4a0..00e56a1c 100644
--- a/include/proj/datum.hpp
+++ b/include/proj/datum.hpp
@@ -247,7 +247,8 @@ using EllipsoidNNPtr = util::nn<EllipsoidPtr>;
* \remark Implements Ellipsoid from \ref ISO_19111_2019
*/
class PROJ_GCC_DLL Ellipsoid final : public common::IdentifiedObject,
- public io::IPROJStringExportable {
+ public io::IPROJStringExportable,
+ public io::IJSONExportable {
public:
//! @cond Doxygen_Suppress
PROJ_DLL ~Ellipsoid() override;
@@ -304,6 +305,9 @@ class PROJ_GCC_DLL Ellipsoid final : public common::IdentifiedObject,
_exportToWKT(io::WKTFormatter *formatter)
const override; // throw(io::FormattingException)
+ PROJ_INTERNAL void _exportToJSON(io::JSONFormatter *formatter)
+ const override; // throw(io::FormattingException)
+
PROJ_INTERNAL bool
_isEquivalentTo(const util::IComparable *other,
util::IComparable::Criterion criterion =
@@ -375,7 +379,8 @@ using GeodeticReferenceFrameNNPtr = util::nn<GeodeticReferenceFramePtr>;
*
* \remark Implements GeodeticReferenceFrame from \ref ISO_19111_2019
*/
-class PROJ_GCC_DLL GeodeticReferenceFrame : public Datum {
+class PROJ_GCC_DLL GeodeticReferenceFrame : public Datum,
+ public io::IJSONExportable {
public:
//! @cond Doxygen_Suppress
PROJ_DLL ~GeodeticReferenceFrame() override;
@@ -403,6 +408,9 @@ class PROJ_GCC_DLL GeodeticReferenceFrame : public Datum {
PROJ_INTERNAL void _exportToWKT(io::WKTFormatter *formatter)
const override; // throw(io::FormattingException)
+ PROJ_INTERNAL void _exportToJSON(io::JSONFormatter *formatter)
+ const override; // throw(FormattingException)
+
PROJ_INTERNAL bool
_isEquivalentTo(const util::IComparable *other,
util::IComparable::Criterion criterion =
diff --git a/include/proj/io.hpp b/include/proj/io.hpp
index 71a6430d..cfb4b3f7 100644
--- a/include/proj/io.hpp
+++ b/include/proj/io.hpp
@@ -483,12 +483,31 @@ class PROJ_GCC_DLL JSONFormatter {
PROJ_PRIVATE :
//! @cond Doxygen_Suppress
- PROJ_INTERNAL PROJ::CPLJSonStreamingWriter &
+ PROJ_INTERNAL CPLJSonStreamingWriter &
writer() const;
+ struct ObjectContext {
+ JSONFormatter &m_formatter;
+
+ ObjectContext(const ObjectContext &) = delete;
+ ObjectContext(ObjectContext &&) = default;
+
+ explicit ObjectContext(JSONFormatter &formatter, const char *objectType,
+ bool hasId);
+ ~ObjectContext();
+ };
+ PROJ_INTERNAL inline ObjectContext MakeObjectContext(const char *objectType,
+ bool hasId) {
+ return ObjectContext(*this, objectType, hasId);
+ }
+
+ PROJ_INTERNAL void setAllowIDInImmediateChild();
+
// cppcheck-suppress functionStatic
PROJ_INTERNAL bool outputId() const;
+ PROJ_INTERNAL bool outputUsage() const;
+
//! @endcond
protected: