diff options
author | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2019-06-06 16:31:25 +0900 |
---|---|---|
committer | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2019-06-06 16:31:25 +0900 |
commit | 9ee98a06160ee2b234e92db70eb18e128fc76e5d (patch) | |
tree | d144be711339162d8fb8662ac868cc3677318072 /app/qcheapruler.cpp | |
parent | 61a91b68c0c895714ea8d612fc752ad4b5cf56ef (diff) |
add hubtbtsandbox/zheng_wenlong/hubtbt
Diffstat (limited to 'app/qcheapruler.cpp')
-rw-r--r-- | app/qcheapruler.cpp | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/app/qcheapruler.cpp b/app/qcheapruler.cpp deleted file mode 100644 index 6e2f59c..0000000 --- a/app/qcheapruler.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include "qcheapruler.hpp" - -#include <QString> - -QCheapRuler::QCheapRuler() -{ - //set the default current position - m_currentPosition = QGeoCoordinate(36.136261, -115.151254); - //m_currentPosition = QGeoCoordinate(35.692396, 139.691102); -} - -QCheapRuler::~QCheapRuler() -{ -} - -//get route distance -double QCheapRuler::distance() const -{ - return m_distance; -} - -//get current distance along the route -double QCheapRuler::currentDistance() const -{ - return m_currentDistance; -} - -//get the current Coordinate -void QCheapRuler::setCurrentCoordinate(QString m_latitude,QString m_longitude) -{ - double latitude = m_latitude.toDouble(); - double longitude = m_longitude.toDouble(); - setCurrentPosition(latitude,longitude); -} - -//set current position below the coordinate info from navigation service -void QCheapRuler::setCurrentPosition(double latitude, double longitude) -{ - //set coordinate info and notify the changes when latitude or longitude info has changed - if((m_currentPosition.latitude() != latitude) - ||(m_currentPosition.longitude() != longitude)) - { - m_currentPosition.setLatitude(latitude); - m_currentPosition.setLongitude(longitude); - emit currentPositionChanged(); - } -} - -void QCheapRuler::setCurrentDistance(QString strdistance) -{ - double distance = strdistance.toDouble(); - //set current distance info and notify the changes when the info has changed - //but it will not send notify when it start or stop demo - - if((m_currentDistance != distance) - &&(distance != 0.0)) - { - m_currentDistance = distance; - emit currentDistanceChanged(); - } -} - -//get current position(coordinate) -QGeoCoordinate QCheapRuler::currentPosition() const -{ - return m_currentPosition; -} - -QJSValue QCheapRuler::path() const -{ - // Should never be called. - return QJSValue(); -} - -//set route path and get the total distance -void QCheapRuler::setPath(const QJSValue &value) -{ - if (!value.isArray()) - return; - - m_path.clear(); - quint32 length = value.property(QStringLiteral("length")).toUInt(); - - //push back the coordinate info along the route - for (unsigned i = 0; i < length; ++i) { - auto property = value.property(i); - cr::point coordinate = { 0., 0. }; - - if (property.hasProperty(QStringLiteral("latitude"))) - coordinate.y = property.property(QStringLiteral("latitude")).toNumber(); - - if (property.hasProperty(QStringLiteral("longitude"))) - coordinate.x = property.property(QStringLiteral("longitude")).toNumber(); - - m_path.push_back(coordinate); - } - - //count the total distance along the route - double distance = ruler().lineDistance(m_path); - if (m_distance != distance) { - m_distance = distance; - } - - emit pathChanged(); -} - -//init the CheapRuler class -cr::CheapRuler QCheapRuler::ruler() const -{ - if (m_path.empty()) { - return cr::CheapRuler(0., cr::CheapRuler::Kilometers); - } else { - return cr::CheapRuler(m_currentPosition.latitude(), cr::CheapRuler::Kilometers); - } -} |