aboutsummaryrefslogtreecommitdiffstats
path: root/app/file_operation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'app/file_operation.cpp')
-rw-r--r--app/file_operation.cpp47
1 files changed, 29 insertions, 18 deletions
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;
+}