2016-02-11 20:58:52 +01:00
|
|
|
#ifndef WAYPOINT_H
|
|
|
|
#define WAYPOINT_H
|
|
|
|
|
|
|
|
#include <QString>
|
2016-07-28 00:23:22 +02:00
|
|
|
#include <QDateTime>
|
2016-02-11 20:58:52 +01:00
|
|
|
#include <QHash>
|
2016-07-28 00:23:22 +02:00
|
|
|
#include <QDebug>
|
|
|
|
#include <cmath>
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "common/coordinates.h"
|
2016-02-11 20:58:52 +01:00
|
|
|
|
2016-02-19 21:42:54 +01:00
|
|
|
class Waypoint
|
2016-02-11 20:58:52 +01:00
|
|
|
{
|
|
|
|
public:
|
2016-10-27 00:20:00 +02:00
|
|
|
Waypoint() {_elevation = NAN;}
|
|
|
|
Waypoint(const Coordinates &coordinates) : _coordinates(coordinates)
|
|
|
|
{_elevation = NAN;}
|
2016-02-11 20:58:52 +01:00
|
|
|
|
2016-10-24 00:21:40 +02:00
|
|
|
const Coordinates &coordinates() const {return _coordinates;}
|
2016-07-25 19:32:36 +02:00
|
|
|
const QString &name() const {return _name;}
|
2016-02-11 20:58:52 +01:00
|
|
|
const QString &description() const {return _description;}
|
2016-07-28 00:23:22 +02:00
|
|
|
const QDateTime ×tamp() const {return _timestamp;}
|
|
|
|
qreal elevation() const {return _elevation;}
|
|
|
|
|
2016-10-24 00:21:40 +02:00
|
|
|
void setCoordinates(const Coordinates &coordinates)
|
2016-02-11 20:58:52 +01:00
|
|
|
{_coordinates = coordinates;}
|
2016-07-28 00:23:22 +02:00
|
|
|
void setName(const QString &name) {_name = name;}
|
2016-02-11 20:58:52 +01:00
|
|
|
void setDescription(const QString &description)
|
|
|
|
{_description = description;}
|
2016-07-28 00:23:22 +02:00
|
|
|
void setTimestamp(const QDateTime ×tamp) {_timestamp = timestamp;}
|
|
|
|
void setElevation(qreal elevation) {_elevation = elevation;}
|
2016-02-11 20:58:52 +01:00
|
|
|
|
2016-08-09 01:16:19 +02:00
|
|
|
bool hasElevation() const {return !std::isnan(_elevation);}
|
|
|
|
|
2016-02-19 21:42:54 +01:00
|
|
|
bool operator==(const Waypoint &other) const
|
2016-07-25 19:32:36 +02:00
|
|
|
{return this->_name == other._name
|
2016-02-11 20:58:52 +01:00
|
|
|
&& this->_coordinates == other._coordinates;}
|
|
|
|
|
|
|
|
private:
|
2016-10-24 00:21:40 +02:00
|
|
|
Coordinates _coordinates;
|
2016-07-25 19:32:36 +02:00
|
|
|
QString _name;
|
2016-02-11 20:58:52 +01:00
|
|
|
QString _description;
|
2016-07-28 00:23:22 +02:00
|
|
|
QDateTime _timestamp;
|
|
|
|
qreal _elevation;
|
2016-02-11 20:58:52 +01:00
|
|
|
};
|
|
|
|
|
2016-02-19 21:42:54 +01:00
|
|
|
inline uint qHash(const Waypoint &key)
|
2016-02-11 20:58:52 +01:00
|
|
|
{
|
2016-07-25 19:32:36 +02:00
|
|
|
return ::qHash(key.name());
|
2016-02-11 20:58:52 +01:00
|
|
|
}
|
|
|
|
|
2018-02-13 23:03:18 +01:00
|
|
|
#ifndef QT_NO_DEBUG
|
2017-11-26 18:54:03 +01:00
|
|
|
inline QDebug operator<<(QDebug dbg, const Waypoint &waypoint)
|
|
|
|
{
|
|
|
|
dbg.nospace() << "Waypoint(" << waypoint.coordinates() << ", "
|
|
|
|
<< waypoint.name() << ", " << waypoint.description() << ")";
|
|
|
|
return dbg.space();
|
|
|
|
}
|
2018-02-13 23:03:18 +01:00
|
|
|
#endif // QT_NO_DEBUG
|
2016-07-28 00:23:22 +02:00
|
|
|
|
2016-10-28 00:48:49 +02:00
|
|
|
Q_DECLARE_TYPEINFO(Waypoint, Q_MOVABLE_TYPE);
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
#endif // WAYPOINT_H
|