1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-19 04:02:09 +01:00
GPXSee/src/data/poi.h

70 lines
1.5 KiB
C
Raw Normal View History

2015-10-05 01:43:48 +02:00
#ifndef POI_H
#define POI_H
2017-11-26 18:54:03 +01:00
#include <QList>
2015-10-05 01:43:48 +02:00
#include <QPointF>
#include <QString>
#include <QStringList>
2018-05-22 22:40:15 +02:00
#include "common/rtree.h"
#include "common/treenode.h"
2017-11-26 18:54:03 +01:00
#include "waypoint.h"
2015-10-05 01:43:48 +02:00
2019-01-31 01:46:53 +01:00
class Path;
class RectC;
2016-10-09 23:46:30 +02:00
class POI : public QObject
2015-10-05 01:43:48 +02:00
{
2016-10-09 23:46:30 +02:00
Q_OBJECT
2015-10-05 01:43:48 +02:00
public:
2016-10-09 23:46:30 +02:00
POI(QObject *parent = 0);
~POI();
2016-10-09 23:46:30 +02:00
bool loadFile(const QString &path);
TreeNode<QString> loadDir(const QString &path);
2016-10-23 11:09:20 +02:00
const QString &errorString() const {return _errorString;}
int errorLine() const {return _errorLine;}
2016-12-06 01:48:26 +01:00
unsigned radius() const {return _radius;}
void setRadius(unsigned radius);
2016-10-09 23:46:30 +02:00
2017-11-26 18:54:03 +01:00
QList<Waypoint> points(const Path &path) const;
QList<Waypoint> points(const Waypoint &point) const;
2020-12-02 23:58:11 +01:00
QList<Waypoint> points(const RectC &rect) const;
bool isLoaded(const QString &path) const {return _files.contains(path);}
bool enableFile(const QString &fileName, bool enable);
2015-10-05 01:43:48 +02:00
2016-10-09 23:46:30 +02:00
signals:
2016-10-11 00:19:42 +02:00
void pointsChanged();
2016-10-09 23:46:30 +02:00
2015-10-05 01:43:48 +02:00
private:
typedef RTree<size_t, qreal, 2> POITree;
class File {
public:
File(int start, int end, const QVector<Waypoint> &data);
const POITree &tree() const {return _tree;}
bool isEnabled() const {return _enabled;}
void enable(bool enable) {_enabled = enable;}
private:
bool _enabled;
POITree _tree;
2017-08-10 08:58:21 +02:00
};
typedef QHash<QString, File*>::const_iterator ConstIterator;
typedef QHash<QString, File*>::iterator Iterator;
2015-10-05 01:43:48 +02:00
2018-09-13 01:15:43 +02:00
void search(const RectC &rect, QSet<int> &set) const;
2016-02-19 21:42:54 +01:00
QVector<Waypoint> _data;
QHash<QString, File*> _files;
2016-02-19 21:34:55 +01:00
2016-12-06 01:48:26 +01:00
unsigned _radius;
2016-10-09 23:46:30 +02:00
2016-10-23 11:09:20 +02:00
QString _errorString;
int _errorLine;
2015-10-05 01:43:48 +02:00
};
#endif // POI_H