summaryrefslogtreecommitdiffstats
path: root/app/navigation_client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'app/navigation_client.cpp')
-rw-r--r--app/navigation_client.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/app/navigation_client.cpp b/app/navigation_client.cpp
new file mode 100644
index 0000000..f07f6c7
--- /dev/null
+++ b/app/navigation_client.cpp
@@ -0,0 +1,50 @@
+#include "navigation_client.h"
+
+navigation_client::navigation_client(Navigation *navigation, QObject *parent) :
+ m_navigation(navigation)
+{
+ QObject::connect(m_navigation, &Navigation::statusEvent, this, &navigation_client::statusEvent);
+ QObject::connect(m_navigation, &Navigation::positionEvent, this, &navigation_client::positionEvent);
+}
+
+navigation_client::~navigation_client(){}
+
+void navigation_client::statusEvent(QVariantMap data)
+{
+ if (!data.contains("state"))
+ return;
+
+ QString state = data["state"].toString();
+
+ if (state == "arrived")
+ emit arrivedestQml();
+
+ if (state == "stopped" || state == "stop")
+ emit stopdemoQml();
+}
+
+void navigation_client::positionEvent(QVariantMap data)
+{
+ if (!data.contains("position"))
+ return;;
+
+ QString position = data["position"].toString();
+
+ if (position == "route") {
+ double route_Lat_s = data["latitude"].toDouble();
+ double route_Lon_s = data["longitude"].toDouble();
+ double route_Lat_e = data["route_latitude"].toDouble();
+ double route_Lon_e = data["route_longitude"].toDouble();
+
+ emit addRoutePointsQml(route_Lat_s, route_Lon_s, route_Lat_e, route_Lon_e);
+ }
+
+ if (position == "car") {
+ double cur_Lat_p = data["latitude"].toDouble();
+ double cur_Lon_p = data["longitude"].toDouble();
+ double cur_direction = data["direction"].toDouble();
+ double cur_distance = data["distance"].toDouble();
+
+ emit positionQml(cur_Lat_p, cur_Lon_p, cur_direction, cur_distance);
+ }
+}