diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-01-22 00:08:42 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-01-22 00:08:42 +0100 |
| commit | 5c86b290e2c5686cbf5100eb71e32b0362a989fc (patch) | |
| tree | 512b64e121df7e8a672613d707c0deaa98af711b | |
| parent | 6a541b3a3926282ffc2e4bb20d2f6d78549572b5 (diff) | |
| download | PROJ-5c86b290e2c5686cbf5100eb71e32b0362a989fc.tar.gz PROJ-5c86b290e2c5686cbf5100eb71e32b0362a989fc.zip | |
ISO19111: clean interface of DataEpoch class
| -rw-r--r-- | include/proj/common.hpp | 18 | ||||
| -rw-r--r-- | src/iso19111/common.cpp | 44 | ||||
| -rw-r--r-- | test/unit/test_common.cpp | 9 |
3 files changed, 65 insertions, 6 deletions
diff --git a/include/proj/common.hpp b/include/proj/common.hpp index 6a4d479e..ad8893f7 100644 --- a/include/proj/common.hpp +++ b/include/proj/common.hpp @@ -262,10 +262,22 @@ class DateTime { /** \brief Data epoch */ class DataEpoch { - // FIXME public: - /** FIXME */ - Measure coordinateEpoch{}; + //! @cond Doxygen_Suppress + PROJ_DLL explicit DataEpoch(const Measure &coordinateEpochIn); + PROJ_DLL DataEpoch(const DataEpoch &other); + PROJ_DLL ~DataEpoch(); + //! @endcond + + PROJ_DLL const Measure &coordinateEpoch() const; + + protected: + DataEpoch(); + PROJ_FRIEND_OPTIONAL(DataEpoch); + + private: + DataEpoch &operator=(const DataEpoch &other) = delete; + PROJ_OPAQUE_PRIVATE_DATA }; // --------------------------------------------------------------------------- diff --git a/src/iso19111/common.cpp b/src/iso19111/common.cpp index ad816275..ca9d3b3e 100644 --- a/src/iso19111/common.cpp +++ b/src/iso19111/common.cpp @@ -642,9 +642,7 @@ const std::string &IdentifiedObject::remarks() PROJ_PURE_DEFN { * * \remark Extension of \ref ISO_19111_2018 */ -bool IdentifiedObject::isDeprecated() PROJ_PURE_DEFN { - return d->isDeprecated; -} +bool IdentifiedObject::isDeprecated() PROJ_PURE_DEFN { return d->isDeprecated; } // --------------------------------------------------------------------------- //! @cond Doxygen_Suppress @@ -1111,5 +1109,45 @@ bool ObjectUsage::_isEquivalentTo( } //! @endcond +// --------------------------------------------------------------------------- + +//! @cond Doxygen_Suppress +struct DataEpoch::Private { + Measure coordinateEpoch_{}; + + explicit Private(const Measure &coordinateEpochIn) + : coordinateEpoch_(coordinateEpochIn) {} +}; +//! @endcond + +// --------------------------------------------------------------------------- + +DataEpoch::DataEpoch() + : d(internal::make_unique<Private>(Measure())) {} + +// --------------------------------------------------------------------------- + +DataEpoch::DataEpoch(const Measure &coordinateEpochIn) + : d(internal::make_unique<Private>(coordinateEpochIn)) {} + +// --------------------------------------------------------------------------- + +DataEpoch::DataEpoch(const DataEpoch &other) + : d(internal::make_unique<Private>(*(other.d))) {} + +// --------------------------------------------------------------------------- + +//! @cond Doxygen_Suppress +DataEpoch::~DataEpoch() = default; +//! @endcond + +// --------------------------------------------------------------------------- + +/** \brief Return the coordinate epoch, as a measure in decimal year. + */ +const Measure &DataEpoch::coordinateEpoch() const { + return d->coordinateEpoch_; +} + } // namespace common NS_PROJ_END diff --git a/test/unit/test_common.cpp b/test/unit/test_common.cpp index 4de4654d..56fcaa27 100644 --- a/test/unit/test_common.cpp +++ b/test/unit/test_common.cpp @@ -189,3 +189,12 @@ TEST(common, identifiedobject_alias_array_of_invalid_type) { ASSERT_THROW(OperationParameter::create(properties), InvalidValueTypeException); } + +// --------------------------------------------------------------------------- + +TEST(common, DataEpoch) { + DataEpoch epochSrc(Measure(2010.5, UnitOfMeasure::YEAR)); + DataEpoch epoch(epochSrc); + EXPECT_EQ(epoch.coordinateEpoch().value(), 2010.5); + EXPECT_EQ(epoch.coordinateEpoch().unit(), UnitOfMeasure::YEAR); +} |
