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");