diff options
author | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2018-11-02 14:13:07 +0900 |
---|---|---|
committer | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2018-11-02 14:13:07 +0900 |
commit | 30d24cbc67ef416672a3386b10be8fe6711c65d7 (patch) | |
tree | ecc8813e6742661e1521d6399d04cc4abc54587f /app/qcheapruler.hpp | |
parent | ae47635e56c4af4d816a76e5186e945768543679 (diff) |
use mapbox as navigation
Diffstat (limited to 'app/qcheapruler.hpp')
-rw-r--r-- | app/qcheapruler.hpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/app/qcheapruler.hpp b/app/qcheapruler.hpp new file mode 100644 index 0000000..4510315 --- /dev/null +++ b/app/qcheapruler.hpp @@ -0,0 +1,50 @@ +#pragma once + +#include <QGeoCoordinate> +#include <QJSValue> +#include <QObject> + +#include <mapbox/cheap_ruler.hpp> + +namespace cr = mapbox::cheap_ruler; + +class QCheapRuler : public QObject { + Q_OBJECT + Q_PROPERTY(double distance READ distance NOTIFY distanceChanged) + Q_PROPERTY(double currentDistance READ currentDistance WRITE setCurrentDistance NOTIFY currentDistanceChanged) + Q_PROPERTY(unsigned segmentIndex READ segmentIndex NOTIFY segmentIndexChanged) + Q_PROPERTY(QGeoCoordinate currentPosition READ currentPosition NOTIFY currentPositionChanged) + Q_PROPERTY(QJSValue path READ path WRITE setPath NOTIFY pathChanged) + +public: + QCheapRuler() = default; + + double distance() const; + + double currentDistance() const; + void setCurrentDistance(double); + + unsigned segmentIndex() const; + + QGeoCoordinate currentPosition() const; + + QJSValue path() const; + void setPath(const QJSValue &value); + +signals: + void distanceChanged(); + void currentDistanceChanged(); + void currentPositionChanged(); + void segmentIndexChanged(); + void pathChanged(); + +private: + cr::CheapRuler ruler() const; + + double m_distance = 0.; + double m_currentDistance = 0.; + QGeoCoordinate m_currentPosition = QGeoCoordinate(0., 0.); + unsigned m_segmentIndex = 0; + + cr::line_string m_path; +}; |