From 9a5c5eaf6118572cdf1309c903eb2a5ed504c2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Wed, 12 Jul 2017 21:23:56 +0200 Subject: [PATCH] Unified isNull() logic --- src/datum.h | 5 +++-- src/ellipsoid.h | 4 ++-- src/offlinemap.cpp | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/datum.h b/src/datum.h index a49b5674..0a787633 100644 --- a/src/datum.h +++ b/src/datum.h @@ -8,7 +8,7 @@ class Datum { public: - Datum() : _ellipsoid(Ellipsoid()), _dx(0), _dy(0), _dz(0) {} + Datum() : _ellipsoid(Ellipsoid()), _dx(0.0), _dy(0.0), _dz(0.0) {} Datum(const Ellipsoid &ellipsoid, double dx, double dy, double dz) : _ellipsoid(ellipsoid), _dx(dx), _dy(dy), _dz(dz) {} @@ -17,7 +17,8 @@ public: double dy() const {return _dy;} double dz() const {return _dz;} - bool isNull() const {return _ellipsoid.isNull();} + bool isNull() const + {return (_ellipsoid.isNull() && _dx == 0.0 && _dy == 0.0 && _dz == 0.0);} Coordinates toWGS84(const Coordinates &c) const; diff --git a/src/ellipsoid.h b/src/ellipsoid.h index dbdb680e..cb6f0baa 100644 --- a/src/ellipsoid.h +++ b/src/ellipsoid.h @@ -7,14 +7,14 @@ class Ellipsoid { public: - Ellipsoid() : _radius(-1.0), _flattening(-1.0) {} + Ellipsoid() : _radius(0.0), _flattening(0.0) {} Ellipsoid(double radius, double flattening) : _radius(radius), _flattening(flattening) {} double radius() const {return _radius;} double flattening() const {return _flattening;} - bool isNull() const {return _radius < 0 || _flattening < 0;} + bool isNull() const {return (_radius == 0.0 && _flattening == 0.0);} static bool loadList(const QString &path); static const QString &errorString() {return _errorString;} diff --git a/src/offlinemap.cpp b/src/offlinemap.cpp index 974954a8..8dc8392a 100644 --- a/src/offlinemap.cpp +++ b/src/offlinemap.cpp @@ -180,8 +180,8 @@ bool OfflineMap::createProjection(const QString &datum, if (setup.latitudeOrigin < -90.0 || setup.latitudeOrigin > 90.0 || setup.longitudeOrigin < -180.0 || setup.longitudeOrigin > 180.0 - || setup.standardParallel1 < -90 || setup.standardParallel1 > 90 - || setup.standardParallel2 < -90 || setup.standardParallel2 > 90) { + || setup.standardParallel1 < -90.0 || setup.standardParallel1 > 90.0 + || setup.standardParallel2 < -90.0 || setup.standardParallel2 > 90.0) { _errorString = "Invalid projection setup"; return false; }