aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2019-10-20 11:30:15 -0400
committerScott Murray <scott.murray@konsulko.com>2019-10-20 15:27:51 -0400
commitad1ba5b56c4e14a615a566d142290977a9be0805 (patch)
treede3970303047dcca8a6bb1f3f4a6460f2c351c67
parentcad9270984244bddf59f796dfb4d7ccef2f9674f (diff)
Fixes and rework to allow using with cluster demohalibut_8.0.3halibut/8.0.38.0.3
Changes include: - Remove older libhomescreen and qlibwindowmanager detection and configuration from qmake configuration in favor of PKGCONFIG usage. - Rework main.cpp to look more like ondemandnavi, and use qlibhomescreen instead of libhomescreen. - Update file_operation.{h,cpp} with the newer versions from ondemandnavi that include OSM configuration. - Fixed typo in arrived signal name in org.agl.naviapi.xml and dbus_client.cpp. - Change some qDebug messages in dbus_client.cpp to qWarning as it seems more appropriate. - Rework QtLocation plugin configuration in MapWindow.qml to support OSM and replace mapboxgl with mapbox, as mapboxgl does not seem to work out of the box. - Tweak various things in MapWindow.qml to try to better match the look of ondemandnavi. - Many commenting and whitespace fixes in MapWindow.qml. - Update widget config.xml to add now required display permission, and add the hidden permission so the application will not show up in the launcher. - Add license files for the various header files in include/mapbox, and update README.md to indicate where they come from and what files the different licenses apply to. Bug-AGL: SPEC-2913 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: Ia42a4303f772bf9c2235c720c92af3faa2936485
-rw-r--r--LICENSE.mapbox-cheap-ruler-cpp15
-rw-r--r--LICENSE.mapbox-geometry.hpp13
-rw-r--r--LICENSE.mapbox-variant25
-rw-r--r--LICENSE_1_0.txt23
-rw-r--r--README.md82
-rw-r--r--app/app.pri17
-rw-r--r--app/app.pro7
-rw-r--r--app/dbus_client.cpp46
-rw-r--r--app/file_operation.cpp47
-rw-r--r--app/file_operation.h10
-rw-r--r--app/main.cpp191
-rw-r--r--app/org.agl.naviapi.xml4
-rw-r--r--app/qml/Main.qml4
-rw-r--r--app/qml/MapWindow.qml143
-rw-r--r--package/config.xml4
15 files changed, 362 insertions, 269 deletions
diff --git a/LICENSE.mapbox-cheap-ruler-cpp b/LICENSE.mapbox-cheap-ruler-cpp
new file mode 100644
index 0000000..6f4f868
--- /dev/null
+++ b/LICENSE.mapbox-cheap-ruler-cpp
@@ -0,0 +1,15 @@
+ISC License
+
+Copyright (c) 2017, Mapbox
+
+Permission to use, copy, modify, and/or distribute this software for any purpose
+with or without fee is hereby granted, provided that the above copyright notice
+and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
diff --git a/LICENSE.mapbox-geometry.hpp b/LICENSE.mapbox-geometry.hpp
new file mode 100644
index 0000000..8f6a86b
--- /dev/null
+++ b/LICENSE.mapbox-geometry.hpp
@@ -0,0 +1,13 @@
+Copyright (c) 2016, Mapbox
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file
diff --git a/LICENSE.mapbox-variant b/LICENSE.mapbox-variant
new file mode 100644
index 0000000..6c4ce40
--- /dev/null
+++ b/LICENSE.mapbox-variant
@@ -0,0 +1,25 @@
+Copyright (c) MapBox
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+- Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright notice, this
+ list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
+- Neither the name "MapBox" nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file
diff --git a/LICENSE_1_0.txt b/LICENSE_1_0.txt
new file mode 100644
index 0000000..36b7cd9
--- /dev/null
+++ b/LICENSE_1_0.txt
@@ -0,0 +1,23 @@
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
index 3365abb..d953318 100644
--- a/README.md
+++ b/README.md
@@ -1,36 +1,33 @@
-# tbtnavi
-
-#reference
-
+# tbtnavi
+Navigation application with turn by turn (TBT) navigation support for cluster demo remote display.
+## Reference
+The application is based on the QtLocation widget, documentation is available at:
+https://doc-snapshots.qt.io/qt5-5.9/qtlocation-index.html
+and example code used as a starting point at:
https://doc-snapshots.qt.io/qt5-5.9/qtlocation-mapviewer-example.html
-#build step
-
-source /SDK_PATH/environment-setup-aarch64-agl-linux
-
+## Build
+```
+source ${SDK_PATH}/environment-setup-aarch64-agl-linux
mkdir build
-
cd build
-
qmake ../
-
make
+```
+## Configuration
-#configuration
-
-This is the same file for navigation.
-If you have done it during install the navigation,please jump it.
+This is the same as the configuration file for the ondemandnavi navigation application. The same file will be used by both applications if present.
-Please set mapAccessToken, mapStyleUrl, speed,
-interval, latitude and longitude in JSON format
-in /etc/naviconfig.ini
+Please set mapAccessToken, mapStyleUrl, speed, interval, latitude and longitude in JSON format in `/etc/naviconfig.ini`.
-mapAccessToken sets Access token provided by Mapbox.
-speed sets vehicle speed in km / h.
-interval sets the screen update interval in milliseconds.
-latitude, longitute sets the current position at application start.
-mapStyleUrls sets Mapbox style URLs.
+- mapAccessToken sets Access token provided by Mapbox.
+- speed sets vehicle speed in km/h.
+- interval sets the screen update interval in milliseconds.
+- latitude, longitute sets the current position at application start.
+- mapStyleUrls sets Mapbox style URLs.
+### Example /etc/naviconfig.ini
+```
example
{
"mapAccessToken":"pk.***********",
@@ -40,4 +37,43 @@ example
"longitute":-115.151,
"mapStyleUrls":"mapbox://styles/mapbox/dark-v9"
}
+```
+## Licensing
+All files are Apache 2.0 licensed, except for those under include/mapbox.
+### From https://github.com/mapbox/cheap-ruler-cpp
+- include/mapbox/cheap_ruler.hpp
+
+ISC license (see LICENSE.mapbox-cheap-ruler-cpp)
+
+### From https://github.com/mapbox/geometry.hpp
+- feature.hpp
+- geometry.hpp
+- geometry_io.hpp
+- geometry/box.hpp
+- geometry/empty.hpp
+- geometry/envelope.hpp
+- geometry/for_each_point.hpp
+- geometry/geometry.hpp
+- geometry/line_string.hpp
+- geometry/multi_line_string.hpp
+- geometry/multi_point.hpp
+- geometry/multi_polygon.hpp
+- geometry/point_arithmetic.hpp
+- geometry/point.hpp
+- geometry/polygon.hpp
+
+ISC license (see LICENSE.mapbox-geometry.hpp)
+
+### From https://github.com/mapbox/variant
+- optional.hpp
+- variant_cast.hpp
+- variant.hpp
+- variant_io.hpp
+- variant_visitor.hpp
+
+BSD 3 Clause license (see LICENSE.mapbox-variant)
+
+- recursive_wrapper.hpp
+
+Boost 1.0 license per header comment (see LICENSE_1.0.txt)
diff --git a/app/app.pri b/app/app.pri
index a1f6562..5dad652 100644
--- a/app/app.pri
+++ b/app/app.pri
@@ -1,18 +1 @@
-load(configure)
-
-qtCompileTest(libhomescreen)
-qtCompileTest(qlibwindowmanager)
-
-config_libhomescreen {
- CONFIG += link_pkgconfig
- PKGCONFIG += libhomescreen
- DEFINES += HAVE_LIBHOMESCREEN
-}
-
-config_qlibwindowmanager {
- CONFIG += link_pkgconfig
- PKGCONFIG += qlibwindowmanager
- DEFINES += HAVE_QLIBWINDOWMANAGER
-}
-
DESTDIR = $${OUT_PWD}/../package/root/bin
diff --git a/app/app.pro b/app/app.pro
index 0be8cd9..af6d775 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -2,15 +2,12 @@ TARGET = tbtnavi
TEMPLATE = app
QT += qml network quick positioning location sql widgets dbus
+PKGCONFIG += qlibhomescreen qlibwindowmanager
-CONFIG += c++1z
+CONFIG += c++1z link_pkgconfig
include(app.pri)
-ios|android {
- QT -= widgets
-}
-
SOURCES += \
main.cpp \
qcheapruler.cpp \
diff --git a/app/dbus_client.cpp b/app/dbus_client.cpp
index 6b5b5fb..62dde46 100644
--- a/app/dbus_client.cpp
+++ b/app/dbus_client.cpp
@@ -8,7 +8,7 @@ dbus_client::dbus_client(const QString &pathName,
m_pathName(pathName + serverName),
m_objName(objName + serverName)
{
- //DBus & api ini
+ // DBus & api init
initDBus();
initAPIs(parent);
}
@@ -19,7 +19,7 @@ void dbus_client::initDBus(){
new NaviapiAdaptor(this);
- //make a connect session to navigation service(add route info)
+ // connect session to navigation service(add route info)
if (!QDBusConnection::sessionBus().connect(
QString(),
QString(),
@@ -27,10 +27,10 @@ void dbus_client::initDBus(){
"signalRouteInfo",
this,
SLOT(addRoutePointsSlot(double, double, double, double)))) { //slot
- qDebug() << m_serverName << "sessionBus.connect(): signalRouteInfo failed";
+ qWarning() << m_serverName << "sessionBus.connect(): signalRouteInfo failed";
}
- //make a connect session to navigation service(current postion info)
+ // connect session to navigation service(current postion info)
if (!QDBusConnection::sessionBus().connect(
QString(),
QString(),
@@ -38,10 +38,10 @@ void dbus_client::initDBus(){
"signalPosInfo",
this,
SLOT(positionSlot(double, double, double, double)))) { //slot
- qDebug() << m_serverName << "sessionBus.connect(): signalPosInfo failed";
+ qWarning() << m_serverName << "sessionBus.connect(): signalPosInfo failed";
}
- //make a connect session to navigation service(when demo stopped)
+ // connect session to navigation service(when demo stopped)
if (!QDBusConnection::sessionBus().connect(
QString(),
QString(),
@@ -49,67 +49,67 @@ void dbus_client::initDBus(){
"signalStopDemo",
this,
SLOT(stopdemoSlot()))) { //slot
- qDebug() << m_serverName << "sessionBus.connect(): signalStopDemo failed";
+ qWarning() << m_serverName << "sessionBus.connect(): signalStopDemo failed";
}
- //make a connect session to navigation service(when arrived destination)
+ // connect session to navigation service(when arrived destination)
if (!QDBusConnection::sessionBus().connect(
QString(),
QString(),
m_pathName,
- "signalArrvied",
+ "signalArrived",
this,
SLOT(arrivedestSlot()))) { //slot
- qDebug() << m_serverName << "sessionBus.connect(): signalArrvied failed";
+ qWarning() << m_serverName << "sessionBus.connect(): signalArrived failed";
}
}
void dbus_client::initAPIs(QObject *parent){
- //connect the signal to qml inside function(addRoutePointsQml -> do_addRoutePoint)
+ // connect the signal to qml inside function(addRoutePointsQml -> do_addRoutePoint)
if(!QObject::connect(this, SIGNAL(addRoutePointsQml(QVariant, QVariant, QVariant, QVariant)),
parent, SLOT(do_addRoutePoint(QVariant, QVariant, QVariant, QVariant)))) {
- qDebug() << m_serverName << "SIGNAL:addRoutePointsQml to qmlSLOT:do_addRoutePoint connect is failed";
+ qWarning() << m_serverName << "SIGNAL:addRoutePointsQml to qmlSLOT:do_addRoutePoint connect failed";
}
- //connect the signal to qml inside function(positionQml -> do_setCoordinate)
+ // connect the signal to qml inside function(positionQml -> do_setCoordinate)
if(!QObject::connect(this, SIGNAL(positionQml(QVariant, QVariant,QVariant, QVariant)),
parent, SLOT(do_setCoordinate(QVariant, QVariant,QVariant, QVariant)))) {
- qDebug() << m_serverName << "SIGNAL:positionQml to qmlSLOT:do_setCoordinate connect is failed";
+ qWarning() << m_serverName << "SIGNAL:positionQml to qmlSLOT:do_setCoordinate connect failed";
}
- //connect the signal to qml inside function(stopdemoQml -> do_stopnavidemo)
+ // connect the signal to qml inside function(stopdemoQml -> do_stopnavidemo)
if(!QObject::connect(this, SIGNAL(stopdemoQml()),
parent, SLOT(do_stopnavidemo()))) {
- qDebug() << m_serverName << "SIGNAL:stopdemoQml to qmlSLOT:do_stopnavidemo connect is failed";
+ qWarning() << m_serverName << "SIGNAL:stopdemoQml to qmlSLOT:do_stopnavidemo connect failed";
}
- //connect the signal to qml inside function(arrivedestQml -> do_arrivedest)
+ // connect the signal to qml inside function(arrivedestQml -> do_arrivedest)
if(!QObject::connect(this, SIGNAL(arrivedestQml()),
parent, SLOT(do_arrivedest()))) {
- qDebug() << m_serverName << "SIGNAL:arrivedestQml to qmlSLOT:do_arrivedest connect is failed";
+ qWarning() << m_serverName << "SIGNAL:arrivedestQml to qmlSLOT:do_arrivedest connect failed";
}
}
-//Signal&&Method
-//addRoutePointsSlot -> addRoutePointsQml(use for qml)
+// Signal&&Method
+// addRoutePointsSlot -> addRoutePointsQml(use for qml)
void dbus_client::addRoutePointsSlot(double route_Lat_s, double route_Lon_s, double route_Lat_e, double route_Lon_e)
{
emit addRoutePointsQml(route_Lat_s, route_Lon_s, route_Lat_e, route_Lon_e);
}
-//positionSlot -> positionQml(use for qml)
+// positionSlot -> positionQml(use for qml)
void dbus_client::positionSlot(double cur_Lat_p, double cur_Lon_p,double cur_direction, double cur_distance)
{
emit positionQml(cur_Lat_p, cur_Lon_p,cur_direction,cur_distance);
}
-//stopdemoSlot -> stopdemoQml(use for qml)
+// stopdemoSlot -> stopdemoQml(use for qml)
void dbus_client::stopdemoSlot()
{
emit stopdemoQml();
}
-//arrivedestSlot -> arrivedestQml(use for qml)
+// arrivedestSlot -> arrivedestQml(use for qml)
void dbus_client::arrivedestSlot()
{
emit arrivedestQml();
diff --git a/app/file_operation.cpp b/app/file_operation.cpp
index a191c76..819cce5 100644
--- a/app/file_operation.cpp
+++ b/app/file_operation.cpp
@@ -13,8 +13,10 @@ void File_Operation::initFileOperation(){
m_mapAccessToken = "";
m_car_speed = 60; // set default Km/h
m_update_interval = 100; // set default millisecond
- m_start_latitude = 35.692396; // set default coordinate Tokyo Hilton
- m_start_longitute = 139.691102;
+ m_start_latitude = 36.136261; // set default coordinate Westgate
+ m_start_longitute = -115.151254;
+ m_enable_osm = false;
+ m_mapStyleUrls = "mapbox://styles/mapbox/streets-v10"; // set default map style
QFile file(NAVI_CONFIG_FILEPATH);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
@@ -26,19 +28,6 @@ void File_Operation::initFileOperation(){
QJsonDocument jsonDoc(QJsonDocument::fromJson(data));
QJsonObject jsonObj(jsonDoc.object());
- if(jsonObj.contains("mapAccessToken")){
- m_mapAccessToken = jsonObj["mapAccessToken"].toString();
- }else{
- fprintf(stderr,"Failed to find mapAccessToken data \"%s\": %m", qPrintable(NAVI_CONFIG_FILEPATH));
- return;
- }
- if(jsonObj.contains("mapStyle")){
- m_mapStyle = jsonObj["mapStyle"].toString();
- }else{
- fprintf(stderr,"Failed to find mapStyle data \"%s\": %m", qPrintable(NAVI_CONFIG_FILEPATH));
- return;
- }
-
if(jsonObj.contains("speed")){
m_car_speed = jsonObj["speed"].toDouble();
}else{
@@ -67,6 +56,28 @@ void File_Operation::initFileOperation(){
return;
}
+ // Check if using OSM
+ if (jsonObj.contains("enableOSM")){
+ m_enable_osm = jsonObj["enableOSM"].toBool();
+ if (m_enable_osm)
+ return;
+ }
+
+ // MapBox only settings
+ if(jsonObj.contains("mapAccessToken")){
+ m_mapAccessToken = jsonObj["mapAccessToken"].toString();
+ }else{
+ fprintf(stderr,"Failed to find mapAccessToken data \"%s\": %m", qPrintable(NAVI_CONFIG_FILEPATH));
+ return;
+ }
+
+ if(jsonObj.contains("mapStyleUrls")){
+ m_mapStyleUrls = jsonObj["mapStyleUrls"].toString();
+ }else{
+ fprintf(stderr,"Failed to find mapStyleUrls data \"%s\": %m", qPrintable(NAVI_CONFIG_FILEPATH));
+ return;
+ }
+
file.close();
return;
@@ -75,9 +86,6 @@ void File_Operation::initFileOperation(){
QString File_Operation::getMapAccessToken() {
return m_mapAccessToken;
}
-QString File_Operation::getMapStyle() {
- return m_mapStyle;
-}
double File_Operation::getCarSpeed(){
return m_car_speed;
}
@@ -90,3 +98,6 @@ double File_Operation::getStartLatitude(){
double File_Operation::getStartLongitute(){
return m_start_longitute;
}
+QString File_Operation::getMapStyleUrls() {
+ return m_mapStyleUrls;
+}
diff --git a/app/file_operation.h b/app/file_operation.h
index 65df54a..962c506 100644
--- a/app/file_operation.h
+++ b/app/file_operation.h
@@ -7,7 +7,9 @@
#include <QJsonDocument>
/******************************************************
- * Write navigation config in /etc/naviconfig.ini
+ * Please set mapAccessToken, mapStyleUrl, speed,
+ * interval, latitude and longitude in JSON format
+ * in /etc/naviconfig.ini
******************************************************/
#define NAVI_CONFIG_FILEPATH "/etc/naviconfig.ini"
@@ -16,22 +18,24 @@ class File_Operation: public QObject{
Q_OBJECT
QString m_mapAccessToken;
- QString m_mapStyle;
double m_car_speed; // set Km/h
int m_update_interval; // set millisecond
double m_start_latitude;
double m_start_longitute;
+ bool m_enable_osm;
+ QString m_mapStyleUrls;
public:
File_Operation();
~File_Operation();
Q_INVOKABLE QString getMapAccessToken();
- Q_INVOKABLE QString getMapStyle();
Q_INVOKABLE double getCarSpeed();
Q_INVOKABLE int getUpdateInterval();
Q_INVOKABLE double getStartLatitude();
Q_INVOKABLE double getStartLongitute();
+ Q_INVOKABLE QString getMapStyleUrls();
+ Q_INVOKABLE bool isOSMEnabled() { return m_enable_osm; };
private:
void initFileOperation();
diff --git a/app/main.cpp b/app/main.cpp
index 6194c25..d82ca24 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -4,123 +4,96 @@
#include <QtCore/QCommandLineParser>
#include <QtCore/QUrlQuery>
#include <QtGui/QGuiApplication>
+#include <QtQml/QQmlApplicationEngine>
#include <QtQml/QQmlContext>
#include <QtQuick/QQuickWindow>
#include <QtDBus/QDBusConnection>
+#include <qlibwindowmanager.h>
+#include <qlibhomescreen.h>
#include "qcheapruler.hpp"
#include "dbus_client.h"
#include "file_operation.h"
-#ifdef HAVE_LIBHOMESCREEN
-#include <libhomescreen.hpp>
-#endif
-#ifdef HAVE_QLIBWINDOWMANAGER
-#include <qlibwindowmanager.h>
-#endif
-
int main(int argc, char *argv[])
{
- if (!QDBusConnection::sessionBus().isConnected()) {
- qWarning("Cannot connect to the D-Bus session bus.\n"
- "Please check your system settings and try again.\n");
- return 1;
- }
-
- QString myname = QString("tbtnavi");
-
- QGuiApplication app(argc, argv);
- app.setApplicationName(myname);
- app.setApplicationVersion(QStringLiteral("0.1.0"));
- app.setOrganizationDomain(QStringLiteral("automotivelinux.org"));
- app.setOrganizationName(QStringLiteral("AutomotiveGradeLinux"));
-
- QCommandLineParser parser;
- parser.addPositionalArgument("port", app.translate("main", "port for binding"));
- parser.addPositionalArgument("secret", app.translate("main", "secret for binding"));
- parser.addHelpOption();
- parser.addVersionOption();
- parser.process(app);
- QStringList positionalArguments = parser.positionalArguments();
-
- QQmlApplicationEngine engine;
- int port = 0;
- QString secret;
- if (positionalArguments.length() == 2) {
- port = positionalArguments.takeFirst().toInt();
- secret = positionalArguments.takeFirst();
- }
-
-#ifdef HAVE_QLIBWINDOWMANAGER
- // WindowManager
- QLibWindowmanager* qwm = new QLibWindowmanager();
- if(qwm->init(port,secret) != 0){
- exit(EXIT_FAILURE);
- }
- // Request a surface as described in layers.json windowmanager’s file
- if(qwm->requestSurface(myname) != 0){
- exit(EXIT_FAILURE);
- }
-#endif
-
-#ifdef HAVE_LIBHOMESCREEN
- // HomeScreen
- LibHomeScreen* hs = new LibHomeScreen();
- std::string token = secret.toStdString();
- hs->init(port, token.c_str());
- // Set the event handler for Event_TapShortcut which will activate the surface for windowmanager
- hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [qwm, myname](json_object *object){
-
- json_object *appnameJ = nullptr;
- if(json_object_object_get_ex(object, "application_name", &appnameJ))
- {
- const char *appname = json_object_get_string(appnameJ);
- if(QString::compare(myname, appname, Qt::CaseInsensitive) == 0)
- {
- qDebug("Surface %s got tapShortcut\n", appname);
- json_object *para, *area;
- json_object_object_get_ex(object, "parameter", &para);
- json_object_object_get_ex(para, "area", &area);
- const char *displayArea = json_object_get_string(area);
- qDebug("Surface %s got tapShortcut area\n", displayArea);
-// qwm->activateWindow(myname, QString(QLatin1String(displayArea)));
- qwm->activateWindow(myname, "master.split.sub");
- }
- }
- });
-#endif
- qmlRegisterType<QCheapRuler>("com.mapbox.cheap_ruler", 1, 0, "CheapRuler");
-
- File_Operation file;
- engine.rootContext()->setContextProperty("fileOperation", &file);
-
- engine.load(QUrl(QStringLiteral("qrc:qml/Main.qml")));
-
- QObject *root = engine.rootObjects().first();
- QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
-
- //make the DBus connection info
- QString pathBase = "org.agl.";
- QString objBase = "/org/agl/";
- QString serverName = "naviapi";
- QObject *mapWindow = root->findChild<QObject*>("mapwindow");
- dbus_client dbus(pathBase, objBase, serverName, mapWindow);
-
-#ifdef HAVE_QLIBWINDOWMANAGER
-// QObject::connect(window, SIGNAL(frameSwapped()), qwm, SLOT(slotActivateSurface()));
- // Create an event callback against an event type. Here a lambda is called when SyncDraw event occurs
- qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [root, qwm, myname](json_object *object) {
- fprintf(stderr, "Surface got syncDraw!\n");
- qwm->endDraw(myname);
- });
- // Create an event callback against an event type. Here a lambda is called when SyncDraw event occurs
- qwm->set_event_handler(QLibWindowmanager::Event_Active, [root](json_object *object) {
- fprintf(stderr, "Surface got Event_Active!\n");
- });
-#else
- window->resize(1024, 768);
- window->setVisible(true);
-#endif
-
- return app.exec();
+ QString graphic_role = QString("tbtnavi");
+
+ if (!QDBusConnection::sessionBus().isConnected()) {
+ qWarning("Cannot connect to the D-Bus session bus.\n"
+ "Please check your system settings and try again.\n");
+ return 1;
+ }
+
+ QGuiApplication app(argc, argv);
+ QCoreApplication::setOrganizationDomain("automotivelinux.org");
+ QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
+ QCoreApplication::setApplicationName(graphic_role);
+ QCoreApplication::setApplicationVersion("0.1.0");
+
+ QCommandLineParser parser;
+ parser.addPositionalArgument("port", app.translate("main", "port for binding"));
+ parser.addPositionalArgument("secret", app.translate("main", "secret for binding"));
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.process(app);
+ QStringList positionalArguments = parser.positionalArguments();
+
+ int port = 0;
+ QString token;
+ if (positionalArguments.length() == 2) {
+ port = positionalArguments.takeFirst().toInt();
+ token = positionalArguments.takeFirst();
+ }
+ fprintf(stderr, "[tbtnavi] app_name: %s, port: %d, token: %s.\n",
+ graphic_role.toStdString().c_str(),
+ port,
+ token.toStdString().c_str());
+
+ // QLibWM
+ QLibWindowmanager* qwmHandler = new QLibWindowmanager();
+ int res;
+ if((res = qwmHandler->init(port,token)) != 0){
+ fprintf(stderr, "[tbtnavi] init qlibwm err(%d)\n", res);
+ return -1;
+ }
+ if((res = qwmHandler->requestSurface(graphic_role)) != 0) {
+ fprintf(stderr, "[tbtnavi] request surface err(%d)\n", res);
+ return -1;
+ }
+ qwmHandler->set_event_handler(QLibWindowmanager::Event_SyncDraw,
+ [qwmHandler, &graphic_role](json_object *object) {
+ qwmHandler->endDraw(graphic_role);
+ });
+
+ // QLibHS
+ QLibHomeScreen* qhsHandler = new QLibHomeScreen();
+ qhsHandler->init(port, token.toStdString().c_str());
+ qhsHandler->set_event_handler(QLibHomeScreen::Event_ShowWindow,
+ [qwmHandler, &graphic_role](json_object *object){
+ qDebug("Surface %s got showWindow\n", graphic_role.toStdString().c_str());
+ qwmHandler->activateWindow(graphic_role);
+ });
+
+ // Load qml
+ QQmlApplicationEngine engine;
+
+ qmlRegisterType<QCheapRuler>("com.mapbox.cheap_ruler", 1, 0, "CheapRuler");
+
+ File_Operation file;
+ engine.rootContext()->setContextProperty("fileOperation", &file);
+
+ engine.load(QUrl(QStringLiteral("qrc:qml/Main.qml")));
+ QObject *root = engine.rootObjects().first();
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
+ QObject::connect(window, SIGNAL(frameSwapped()), qwmHandler, SLOT(slotActivateWindow()));
+
+ // Make the DBus connection info
+ QString pathBase = "org.agl.";
+ QString objBase = "/org/agl/";
+ QString serverName = "naviapi";
+ QObject *mapWindow = root->findChild<QObject*>("mapwindow");
+ dbus_client dbus(pathBase, objBase, serverName, mapWindow);
+
+ return app.exec();
}
diff --git a/app/org.agl.naviapi.xml b/app/org.agl.naviapi.xml
index d1538e7..5874c35 100644
--- a/app/org.agl.naviapi.xml
+++ b/app/org.agl.naviapi.xml
@@ -18,8 +18,8 @@
<!-- void signalStopDemo() -->
<signal name="signalStopDemo">
</signal>
- <!-- void signalArrvied() -->
- <signal name="signalArrvied">
+ <!-- void signalArrived() -->
+ <signal name="signalArrived">
</signal>
<!-- void getRouteInfo() -->
<signal name="getRouteInfo">
diff --git a/app/qml/Main.qml b/app/qml/Main.qml
index 4139cb9..346cded 100644
--- a/app/qml/Main.qml
+++ b/app/qml/Main.qml
@@ -17,8 +17,8 @@ ApplicationWindow {
height: parent.height
MapWindow {
- id:mapwindow
- anchors.fill: parent
+ id: mapwindow
+ anchors.fill: parent
objectName: "mapwindow"
}
}
diff --git a/app/qml/MapWindow.qml b/app/qml/MapWindow.qml
index 8a41390..4da46b3 100644
--- a/app/qml/MapWindow.qml
+++ b/app/qml/MapWindow.qml
@@ -1,6 +1,6 @@
-import QtLocation 5.9
-import QtPositioning 5.0
-import QtQuick 2.0
+import QtQuick 2.0
+import QtLocation 5.9
+import QtPositioning 5.9
import com.mapbox.cheap_ruler 1.0
@@ -12,7 +12,7 @@ Item {
property var startPoint
property var endPoint
- //turn by turn board view
+ // Turn by turn board view
TbtBoard {
id: tbt_board
z: 1
@@ -20,37 +20,42 @@ Item {
anchors.fill: parent
}
- //mapview and route views
- Map {
- id: map
- anchors.fill: parent
-
- plugin: Plugin {
- name: "mapboxgl"
-
- PluginParameter {
- name: "mapboxgl.mapping.items.insert_before"
- value: "road-label-small"
- }
+ Plugin {
+ id: mapbox
+ name: "mapbox"
+ PluginParameter {
+ name: "mapbox.mapping.items.insert_before"
+ value: "road-label-small"
+ }
- PluginParameter {
- name: "mapboxgl.mapping.additional_style_urls"
- value: "mapbox://styles/mapbox/streets-v9"
- }
+ PluginParameter {
+ name: "mapbox.mapping.additional_style_urls"
+ value: fileOperation.getMapStyleUrls()
+ }
- PluginParameter {
- name: "mapboxgl.access_token"
- value: fileOperation.getMapAccessToken()
- }
+ PluginParameter {
+ name: "mapbox.access_token"
+ value: fileOperation.getMapAccessToken()
+ }
+ }
- PluginParameter {
- name: "mapboxgl.mapping.cache.directory"
- value: "/home/0/app-data/navigation/"
- }
+ Plugin {
+ id: osm
+ name: "osm"
+ PluginParameter {
+ name: "osm.mapping.host";
+ value: "https://a.tile.openstreetmap.org/"
}
+ }
+ // Map and route views
+ Map {
+ id: map
+ anchors.fill: parent
+
+ plugin: fileOperation.isOSMEnabled() ? osm : mapbox
center: ruler.currentPosition
- zoomLevel: 20
+ zoomLevel: maximumZoomLevel < 20 ? maximumZoomLevel : 20
tilt: 60
gesture.acceptedGestures:MapGestureArea.NoGesture
copyrightsVisible: false
@@ -88,6 +93,7 @@ Item {
}
anchorPoint.x: greenMarker.width / 2
anchorPoint.y: greenMarker.height / 2
+ z: 11
}
MapQuickItem {
@@ -99,6 +105,7 @@ Item {
}
anchorPoint.x: redMarker.width / 2
anchorPoint.y: redMarker.height / 2
+ z: 11
}
MapItemView {
@@ -106,9 +113,11 @@ Item {
delegate: MapRoute {
route: routeData
- line.color: "#6b43a1"
+ line.color: "#4658da"
line.width: map.zoomLevel - 5
- opacity: (index == 0) ? 1.0 : 0.3
+ opacity: (index == 0) ? 1.0 : 0.8
+ smooth: true
+ z: 5
onRouteChanged: {
ruler.path = routeData.path;
@@ -126,12 +135,13 @@ Item {
origin.x: carMarker.width / 2;
origin.y: carMarker.height / 2;
angle: rotateAngle
- }
+ }
}
coordinate: ruler.currentPosition
anchorPoint.x: carMarker.width / 2
anchorPoint.y: carMarker.height / 2
+ z: 12
Location {
id: previousCarLocation
@@ -146,7 +156,7 @@ Item {
}
}
- //add route view in the map
+ // Add route view in the map
function updateRoute() {
routeQuery.clearWaypoints();
routeQuery.addWaypoint(startMarker.coordinate);
@@ -155,7 +165,7 @@ Item {
map.addMapItem(endMarker)
}
- //clear route view in the map
+ // Clear route view in the map
function clearRoute() {
routeQuery.clearWaypoints();
routeModel.reset();
@@ -171,8 +181,8 @@ Item {
var i = 0;
var alldistance = ruler.distance * 1000;
- if((routeModel.status === RouteModel.Ready)
- && (routeModel.count === 1))
+ if((routeModel.status === RouteModel.Ready) &&
+ (routeModel.count === 1))
{
// XXX: Use car speed in meters to pre-warn the turn instruction
while (total < ruler.currentDistance && i < routeModel.get(0).segments.length)
@@ -180,14 +190,14 @@ Item {
total += routeModel.get(0).segments[i++].maneuver.distanceToNextInstruction;
}
- //show the tbt board(it will be always show when demo start)
+ // Show the tbt board (it will be always shown when demo start)
tbt_board.visible = true
- // Set turn instruction
+ // Set turn instruction
tbt_board.do_setTurnInstructions(routeModel.get(0).segments[i].maneuver.instructionText)
tbt_board.state = routeModel.get(0).segments[i].maneuver.direction
- //when goto the last instruction,set the states to "arriveDest"
+ // When goto the last instruction, set the state to "arriveDest"
if(i >= (routeModel.get(0).segments.length-1))
{
total = alldistance;
@@ -199,15 +209,15 @@ Item {
// Set distance
tbt_board.do_setDistance(dis)
- // Set board status
+ // Set board status
if(dis < mapWindow.disOffset && i < routeModel.get(0).segments.length)
{
- //show the tbt board(the big one)
+ // Show the full-size tbt board
tbt_board.do_showTbtboard(true)
- }
+ }
else
{
- //disvisible the tbt board(the big one)
+ // Hide the full-size tbt board
tbt_board.do_showTbtboard(false)
}
}
@@ -215,22 +225,13 @@ Item {
}
}
- //the route view display by RouteModel
+ // The route view display by RouteModel
RouteModel {
id: routeModel
+ plugin: map.plugin
autoUpdate: true
query: routeQuery
-
- plugin: Plugin {
- name: "mapbox"
-
- // Development access token, do not use in production.
- PluginParameter {
- name: "mapbox.access_token"
- value: fileOperation.getMapAccessToken()
- }
- }
}
RouteQuery {
@@ -238,46 +239,56 @@ Item {
}
Component.onCompleted: {
- //request the route info when map load finish
+ // Request route info when map load finishes
if (ruler) {
ruler.initRouteInfo();
ruler.setCurrentPosition(fileOperation.getStartLatitude(), fileOperation.getStartLongitute());
}
}
- //the functions can be called by outside
- //add route signal function
+ //
+ // Externally callable functions
+ //
+
+ // Handle add route signal
function do_addRoutePoint(poi_Lat_s, poi_Lon_s, poi_Lat_e, poi_Lon_e) {
- //set the startPoint and endPoint
+ // Set the startPoint and endPoint
startPoint= QtPositioning.coordinate(poi_Lat_s,poi_Lon_s);
endPoint = QtPositioning.coordinate(poi_Lat_e,poi_Lon_e);
startMarker.coordinate = startPoint;
endMarker.coordinate = endPoint;
- //update the route view
+
+ // Update the route view
if (map) {
map.updateRoute();
}
}
- //set the current position
+ // Set the current position
function do_setCoordinate(latitude,longitude,direction,distance) {
ruler.setCurrentPosition(latitude, longitude);
ruler.setCurrentDistance(distance);
}
- //stop navidemo signal
+ // Handle stop navidemo signal
function do_stopnavidemo() {
- //disvisible the tbt board
+ // Hide the tbt board
tbt_board.visible = false
- //clear the routeview
+
+ // Clear the route view
if (map) {
map.clearRoute();
}
}
- //arrvice the destination signal
- function do_arrivedest(){
- //disvisible the tbt board
+ // Handle arrive at destination signal
+ function do_arrivedest() {
+ // Hide the tbt board
tbt_board.visible = false
+
+ // Clear the route view
+ if (map) {
+ map.clearRoute();
+ }
}
}
diff --git a/package/config.xml b/package/config.xml
index 8aaf856..ed4aafc 100644
--- a/package/config.xml
+++ b/package/config.xml
@@ -11,8 +11,10 @@
<param name="homescreen" value="ws"/>
</feature>
<feature name="urn:AGL:widget:required-permission">
- <param name="urn:AGL:permission::system:run-by-default" value="required"/>
<param name="urn:AGL:permission::public:no-htdocs" value="required" />
+ <param name="urn:AGL:permission::public:display" value="required" />
+ <param name="urn:AGL:permission::system:run-by-default" value="required"/>
+ <param name="urn:AGL:permission::public:hidden" value="required" />
<param name="http://tizen.org/privilege/internal/dbus" value="required"/>
</feature>
</widget>