From 5c86b290e2c5686cbf5100eb71e32b0362a989fc Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 22 Jan 2019 00:08:42 +0100 Subject: ISO19111: clean interface of DataEpoch class --- include/proj/common.hpp | 18 +++++++++++++++--- src/iso19111/common.cpp | 44 +++++++++++++++++++++++++++++++++++++++++--- 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(Measure())) {} + +// --------------------------------------------------------------------------- + +DataEpoch::DataEpoch(const Measure &coordinateEpochIn) + : d(internal::make_unique(coordinateEpochIn)) {} + +// --------------------------------------------------------------------------- + +DataEpoch::DataEpoch(const DataEpoch &other) + : d(internal::make_unique(*(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); +} -- cgit v1.2.3