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>
|
2019-11-15 23:05:22 +01:00
|
|
|
#include <QVector>
|
2016-07-28 00:23:22 +02:00
|
|
|
#include <QDebug>
|
2021-01-10 13:23:43 +01:00
|
|
|
#include "common/config.h"
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "common/coordinates.h"
|
2019-03-15 19:39:52 +01:00
|
|
|
#include "imageinfo.h"
|
2019-10-14 01:16:38 +02:00
|
|
|
#include "link.h"
|
2019-11-08 21:00:59 +01:00
|
|
|
#include "address.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:
|
2020-03-25 23:08:26 +01: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;}
|
2020-04-08 00:54:35 +02:00
|
|
|
Coordinates &rcoordinates() {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;}
|
2020-03-09 20:04:13 +01:00
|
|
|
const QString &comment() const {return _comment;}
|
2019-11-08 21:00:59 +01:00
|
|
|
const Address &address() const {return _address;}
|
2019-11-15 22:10:55 +01:00
|
|
|
const QVector<ImageInfo> &images() const {return _images;}
|
2019-10-14 20:07:05 +02:00
|
|
|
const QVector<Link> &links() const {return _links;}
|
2016-07-28 00:23:22 +02:00
|
|
|
const QDateTime ×tamp() const {return _timestamp;}
|
|
|
|
qreal elevation() const {return _elevation;}
|
|
|
|
|
2020-03-25 23:08:26 +01:00
|
|
|
QPair<qreal, qreal> elevations() const;
|
|
|
|
|
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;}
|
2020-03-09 20:04:13 +01:00
|
|
|
void setComment(const QString &comment) {_comment = comment;}
|
2019-11-08 21:00:59 +01:00
|
|
|
void setAddress(const Address &address) {_address = address;}
|
2016-07-28 00:23:22 +02:00
|
|
|
void setTimestamp(const QDateTime ×tamp) {_timestamp = timestamp;}
|
|
|
|
void setElevation(qreal elevation) {_elevation = elevation;}
|
2019-11-15 22:10:55 +01:00
|
|
|
void addImage(const ImageInfo &image) {_images.append(image);}
|
2019-10-14 20:07:05 +02:00
|
|
|
void addLink(const Link &link) {_links.append(link);}
|
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;}
|
|
|
|
|
2020-03-25 23:08:26 +01:00
|
|
|
static void useDEM(bool use) {_useDEM = use;}
|
|
|
|
static void showSecondaryElevation(bool show)
|
|
|
|
{_show2ndElevation = show;}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
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;
|
2020-03-09 20:04:13 +01:00
|
|
|
QString _comment;
|
2019-11-08 21:00:59 +01:00
|
|
|
Address _address;
|
2019-11-15 22:10:55 +01:00
|
|
|
QVector<ImageInfo> _images;
|
2019-10-14 20:07:05 +02:00
|
|
|
QVector<Link> _links;
|
2016-07-28 00:23:22 +02:00
|
|
|
QDateTime _timestamp;
|
|
|
|
qreal _elevation;
|
2020-03-25 23:08:26 +01:00
|
|
|
|
|
|
|
static bool _useDEM;
|
|
|
|
static bool _show2ndElevation;
|
2016-02-11 20:58:52 +01:00
|
|
|
};
|
|
|
|
|
2021-01-10 13:23:43 +01:00
|
|
|
inline HASH_T 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() << ", "
|
2020-03-25 23:08:26 +01:00
|
|
|
<< waypoint.name() << ")";
|
2017-11-26 18:54:03 +01:00
|
|
|
return dbg.space();
|
|
|
|
}
|
2018-02-13 23:03:18 +01:00
|
|
|
#endif // QT_NO_DEBUG
|
2016-07-28 00:23:22 +02:00
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
#endif // WAYPOINT_H
|