From 2b7d0cd6316570a3d8a5906cd18c304e3abe4e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 30 Jun 2017 18:38:16 +0200 Subject: [PATCH] Unified isNull() and isValid() logic with other (QT) classes --- src/coordinates.h | 6 +++--- src/tcxparser.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/coordinates.h b/src/coordinates.h index 7ea64c29..02221f38 100644 --- a/src/coordinates.h +++ b/src/coordinates.h @@ -20,10 +20,10 @@ public: qreal lat() const {return _lat;} bool isNull() const - {return (std::isnan(_lon) || std::isnan(_lat)) ? true : false;} + {return std::isnan(_lon) && std::isnan(_lat);} bool isValid() const - {return (_lon >= -180.0 && _lon <= 180.0 && _lat >= -90.0 - && _lat <= 90.0) ? true : false;} + {return (!std::isnan(_lon) && !std::isnan(_lat) + && _lon >= -180.0 && _lon <= 180.0 && _lat >= -90.0 && _lat <= 90.0);} qreal distanceTo(const Coordinates &c) const; QPair boundingRect(qreal distance) const; diff --git a/src/tcxparser.cpp b/src/tcxparser.cpp index b68297ac..238c78b9 100644 --- a/src/tcxparser.cpp +++ b/src/tcxparser.cpp @@ -112,7 +112,7 @@ void TCXParser::trackpoints(TrackData &track) if (_reader.name() == "Trackpoint") { Trackpoint t; trackpointData(t); - if (!t.coordinates().isNull()) + if (t.coordinates().isValid()) track.append(t); else warning("Missing Trackpoint coordinates"); @@ -143,7 +143,7 @@ void TCXParser::course(TrackData &track) else if (_reader.name() == "CoursePoint") { Waypoint w; waypointData(w); - if (!w.coordinates().isNull()) + if (w.coordinates().isValid()) _waypoints.append(w); else warning("Missing Trackpoint coordinates");