diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-12-13 17:49:11 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-12-13 18:13:29 +0100 |
| commit | 17b8566f303e0585d7cd775afd5d39da8058fdc3 (patch) | |
| tree | e55e002b2c711b5f62214ec42852a81c3deb170d | |
| parent | 8a2938026575305298624bce924fee1b5a361576 (diff) | |
| download | PROJ-17b8566f303e0585d7cd775afd5d39da8058fdc3.tar.gz PROJ-17b8566f303e0585d7cd775afd5d39da8058fdc3.zip | |
Prime meridian equivalence: increase tolerance
| -rw-r--r-- | include/proj/common.hpp | 6 | ||||
| -rw-r--r-- | src/common.cpp | 6 | ||||
| -rw-r--r-- | src/datum.cpp | 5 |
3 files changed, 13 insertions, 4 deletions
diff --git a/include/proj/common.hpp b/include/proj/common.hpp index 91756c62..29d2c774 100644 --- a/include/proj/common.hpp +++ b/include/proj/common.hpp @@ -158,10 +158,14 @@ class Measure : public util::BaseObject { PROJ_DLL bool operator==(const Measure &other) PROJ_CONST_DECL; + /** Default maximum resulative error. */ + static constexpr double DEFAULT_MAX_REL_ERROR = 1e-10; + PROJ_INTERNAL bool _isEquivalentTo(const Measure &other, util::IComparable::Criterion criterion = - util::IComparable::Criterion::STRICT) const; + util::IComparable::Criterion::STRICT, + double maxRelativeError = DEFAULT_MAX_REL_ERROR) const; private: PROJ_OPAQUE_PRIVATE_DATA diff --git a/src/common.cpp b/src/common.cpp index 2a9d17c7..bd690924 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -370,15 +370,17 @@ bool Measure::operator==(const Measure &other) PROJ_CONST_DEFN { /** \brief Returns whether an object is equivalent to another one. * @param other other object to compare to * @param criterion comparaison criterion. + * @param maxRelativeError Maximum relative error allowed. * @return true if objects are equivalent. */ bool Measure::_isEquivalentTo(const Measure &other, - util::IComparable::Criterion criterion) const { + util::IComparable::Criterion criterion, + double maxRelativeError) const { if (criterion == util::IComparable::Criterion::STRICT) { return operator==(other); } return std::fabs(getSIValue() - other.getSIValue()) <= - 1e-10 * std::fabs(getSIValue()); + maxRelativeError * std::fabs(getSIValue()); } // --------------------------------------------------------------------------- diff --git a/src/datum.cpp b/src/datum.cpp index 9f9fb4ec..975a870a 100644 --- a/src/datum.cpp +++ b/src/datum.cpp @@ -388,7 +388,10 @@ bool PrimeMeridian::_isEquivalentTo( !IdentifiedObject::_isEquivalentTo(other, criterion)) { return false; } - return longitude()._isEquivalentTo(otherPM->longitude(), criterion); + // In MapInfo, the Paris prime meridian is returned as 2.3372291666667 + // instead of the official value of 2.33722917, which is a relative + // error in the 1e-9 range. + return longitude()._isEquivalentTo(otherPM->longitude(), criterion, 1e-8); } //! @endcond |
