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>
|
2016-03-05 18:01:13 +01:00
|
|
|
#include <QStringList>
|
2018-05-22 22:40:15 +02:00
|
|
|
#include "common/rtree.h"
|
2021-03-21 20:23:20 +01:00
|
|
|
#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-07-28 00:23:22 +02:00
|
|
|
|
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);
|
2021-03-21 20:23:20 +01:00
|
|
|
~POI();
|
2016-10-09 23:46:30 +02:00
|
|
|
|
2018-01-30 00:30:26 +01:00
|
|
|
bool loadFile(const QString &path);
|
2021-03-21 20:23:20 +01:00
|
|
|
TreeNode<QString> loadDir(const QString &path);
|
2016-10-23 11:09:20 +02:00
|
|
|
const QString &errorString() const {return _errorString;}
|
2015-11-26 19:13:59 +01:00
|
|
|
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;
|
2016-07-28 00:23:22 +02:00
|
|
|
|
2021-03-21 20:23:20 +01:00
|
|
|
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:
|
2015-11-26 19:13:59 +01:00
|
|
|
typedef RTree<size_t, qreal, 2> POITree;
|
2021-03-21 20:23:20 +01:00
|
|
|
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
|
|
|
};
|
2021-03-21 20:23:20 +01: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;
|
2018-01-30 00:30:26 +01:00
|
|
|
|
2016-02-19 21:42:54 +01:00
|
|
|
QVector<Waypoint> _data;
|
2021-03-21 20:23:20 +01:00
|
|
|
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;
|
2015-11-26 19:13:59 +01:00
|
|
|
int _errorLine;
|
2015-10-05 01:43:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // POI_H
|