summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2019-09-09 00:00:12 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2019-09-09 01:23:22 -0700
commit538634c916e66e47cceaee5a98131eaadd60b269 (patch)
tree2cfdc8daf7a3b8082b932dadb1ea52d298b742c2
parentfb68a3ddc7fcdf67c62fcde32914d4ed3936680a (diff)
qml: add OpenStreetMaps map engine option
To allow testing in regions without easily accessible MapBox API keys add an ENABLE_OSM build option. Bug-AGL: SPEC-2667 Change-Id: I8ba72b774ed0ab1cf740dc0ebdb3048a6f403696 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--README.md3
-rw-r--r--app/app.pro12
-rw-r--r--app/file_operation.cpp2
-rw-r--r--app/openstreetmaps/MapPlugin.qml30
-rw-r--r--app/openstreetmaps/openstreetmaps.qrc5
5 files changed, 50 insertions, 2 deletions
diff --git a/README.md b/README.md
index fb77f41..7dbe21f 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,9 @@ https://doc-snapshots.qt.io/qt5-5.9/qtlocation-mapviewer-example.html
#build step
+NOTE: To use OpenStreetMaps instead of MapBox you should replace
+the qmake step below with 'qmake ../ ENABLE_OSM=1'
+
source /SDK_PATH/environment-setup-aarch64-agl-linux
mkdir build
diff --git a/app/app.pro b/app/app.pro
index 9965675..da5d28b 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -26,8 +26,16 @@ SOURCES += main.cpp \
RESOURCES += \
navigation.qrc \
- images/images.qrc \
- mapbox/mapbox.qrc
+ images/images.qrc
+
+ENABLE_OSM = $$ENABLE_OSM
+
+equals(ENABLE_OSM, 1) {
+ DEFINES += ENABLE_OSM
+ RESOURCES += openstreetmaps/openstreetmaps.qrc
+} else {
+ RESOURCES += mapbox/mapbox.qrc
+}
LIBS += $$OUT_PWD/../dbus_interface/libdbus_interface.a
INCLUDEPATH += $$OUT_PWD/../dbus_interface
diff --git a/app/file_operation.cpp b/app/file_operation.cpp
index 09bd4d0..f3814d8 100644
--- a/app/file_operation.cpp
+++ b/app/file_operation.cpp
@@ -27,12 +27,14 @@ void File_Operation::initFileOperation(){
QJsonDocument jsonDoc(QJsonDocument::fromJson(data));
QJsonObject jsonObj(jsonDoc.object());
+#ifndef ENABLE_OSM
if(jsonObj.contains("mapAccessToken")){
m_mapAccessToken = jsonObj["mapAccessToken"].toString();
}else{
fprintf(stderr,"Failed to find mapAccessToken data \"%s\": %m", qPrintable(NAVI_CONFIG_FILEPATH));
return;
}
+#endif
if(jsonObj.contains("speed")){
m_car_speed = jsonObj["speed"].toDouble();
diff --git a/app/openstreetmaps/MapPlugin.qml b/app/openstreetmaps/MapPlugin.qml
new file mode 100644
index 0000000..785fc80
--- /dev/null
+++ b/app/openstreetmaps/MapPlugin.qml
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2016 The Qt Company Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import QtQuick 2.6
+import QtQuick.Layouts 1.1
+import QtQuick.Controls 2.0
+import QtLocation 5.9
+import QtPositioning 5.6
+
+Plugin {
+ name: "osm"
+ PluginParameter {
+ name: "osm.mapping.host";
+ value: "https://a.tile.openstreetmap.org/"
+ }
+}
+
diff --git a/app/openstreetmaps/openstreetmaps.qrc b/app/openstreetmaps/openstreetmaps.qrc
new file mode 100644
index 0000000..9052f66
--- /dev/null
+++ b/app/openstreetmaps/openstreetmaps.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>MapPlugin.qml</file>
+ </qresource>
+</RCC>