1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-19 20:12:10 +01:00
GPXSee/src/data/waypoint.h

88 lines
2.5 KiB
C
Raw Normal View History

#ifndef WAYPOINT_H
#define WAYPOINT_H
#include <QString>
#include <QDateTime>
#include <QHash>
2019-11-15 23:05:22 +01:00
#include <QVector>
#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-10-14 01:16:38 +02:00
#include "link.h"
2016-02-19 21:42:54 +01:00
class Waypoint
{
public:
Waypoint() : _elevation(NAN) {}
Waypoint(const Coordinates &coordinates)
: _coordinates(coordinates), _elevation(NAN) {}
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;}
const QString &description() const {return _description;}
const QString &comment() const {return _comment;}
const QString &address() const {return _address;}
const QString &phone() const {return _phone;}
const QVector<QString> &images() const {return _images;}
2019-10-14 20:07:05 +02:00
const QVector<Link> &links() const {return _links;}
const QDateTime &timestamp() const {return _timestamp;}
qreal elevation() const {return _elevation;}
QPair<qreal, qreal> elevations() const;
void setCoordinates(const Coordinates &coordinates)
{_coordinates = coordinates;}
void setName(const QString &name) {_name = name;}
void setDescription(const QString &description)
{_description = description;}
void setComment(const QString &comment) {_comment = comment;}
void setAddress(const QString &address) {_address = address;}
void setPhone(const QString &phone) {_phone = phone;}
void setTimestamp(const QDateTime &timestamp) {_timestamp = timestamp;}
void setElevation(qreal elevation) {_elevation = elevation;}
void addImage(const QString &path) {_images.append(path);}
2019-10-14 20:07:05 +02:00
void addLink(const Link &link) {_links.append(link);}
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
&& this->_coordinates == other._coordinates;}
static void useDEM(bool use) {_useDEM = use;}
static void showSecondaryElevation(bool show)
{_show2ndElevation = show;}
private:
Coordinates _coordinates;
2016-07-25 19:32:36 +02:00
QString _name;
QString _description;
QString _comment;
QString _address;
QString _phone;
QVector<QString> _images;
2019-10-14 20:07:05 +02:00
QVector<Link> _links;
QDateTime _timestamp;
qreal _elevation;
static bool _useDEM;
static bool _show2ndElevation;
};
2021-01-10 13:23:43 +01:00
inline HASH_T qHash(const Waypoint &key)
{
2016-07-25 19:32:36 +02:00
return ::qHash(key.name());
}
#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() << ")";
2017-11-26 18:54:03 +01:00
return dbg.space();
}
#endif // QT_NO_DEBUG
#endif // WAYPOINT_H