aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>2019-06-14 12:58:15 +0900
committerzheng_wenlong <wenlong_zheng@nexty-ele.com>2019-06-14 12:58:15 +0900
commit9a7c493a0b43643f9a6dfe6fbc414219c06b9f4f (patch)
tree9f905f8b8f25a88f308926943de5ffce4550869e
parente90b4cf9358a39d6cde661e769e592800effef0c (diff)
fix bug for 0614
-rw-r--r--app/BtnGuidance.qml30
-rw-r--r--app/BtnMapDirection.qml2
-rwxr-xr-xapp/BtnPresentPosition.qml5
-rw-r--r--app/file_operation.cpp17
-rw-r--r--app/file_operation.h3
-rwxr-xr-xapp/navigation.qml399
-rw-r--r--naviconfig.ini1
7 files changed, 388 insertions, 69 deletions
diff --git a/app/BtnGuidance.qml b/app/BtnGuidance.qml
index 4860050..0e66a12 100644
--- a/app/BtnGuidance.qml
+++ b/app/BtnGuidance.qml
@@ -15,12 +15,16 @@ Item {
console.log("onSts_guideChanged")
switch(btn_guidance.sts_guide){
case 0:
-// positionTimer.stop();
+ if (root.st_demo_state === true){
+ positionTimer.stop();
+ }
break
case 1:
break
case 2:
-// positionTimer.start();
+ if (root.st_demo_state === true){
+ positionTimer.start();
+ }
break
default:
break
@@ -32,7 +36,9 @@ Item {
btn_guidance.sts_guide = 2
btn_guidance.state = "onGuide"
map.addStartPoint()
- root.do_startguidance()
+ if (root.st_demo_state === false){
+ root.do_startguidance()
+ }
}
function stopGuidance() {
@@ -65,16 +71,18 @@ Item {
btn_guidance.sts_guide = 0
btn_guidance.state = "Idle"
- root.do_cancelguidance()
+ if (root.st_demo_state === false){
+ root.do_cancelguidance()
+ }
}
-// Timer {
-// id: positionTimer
-// interval: fileOperation.getUpdateInterval();
-// running: false;
-// repeat: true
-// onTriggered: map.updatePositon()
-// }
+ Timer {
+ id: positionTimer
+ interval: fileOperation.getUpdateInterval();
+ running: false;
+ repeat: true
+ onTriggered: map.updateDemoPositon()
+ }
Button {
id: discard
diff --git a/app/BtnMapDirection.qml b/app/BtnMapDirection.qml
index 80f16ce..f3bcf19 100644
--- a/app/BtnMapDirection.qml
+++ b/app/BtnMapDirection.qml
@@ -12,10 +12,12 @@ Item {
btn_map_direction.state = "NorthUp"
car_position_mapitem.state = "NorthUp"
root.st_heading_up = false
+ btn_present_position.setbuttonclickedstate()
} else {
btn_map_direction.state = "HeadingUp"
car_position_mapitem.state = "HeadingUp"
root.st_heading_up = true
+ btn_present_position.setbuttonclickedstate()
}
map.rotateMapSmooth()
}
diff --git a/app/BtnPresentPosition.qml b/app/BtnPresentPosition.qml
index 496847e..365176a 100755
--- a/app/BtnPresentPosition.qml
+++ b/app/BtnPresentPosition.qml
@@ -25,6 +25,11 @@ Item {
source: "images/207px-Car_icon_top.svg.png"
}
}
+ function setbuttonclickedstate(){
+ if (btn_present_position.state === "Optional"){
+ btn_present_position_.present_position_clicked()
+ }
+ }
states: [
State{
name: "Flowing"
diff --git a/app/file_operation.cpp b/app/file_operation.cpp
index 5cb75e0..133cba4 100644
--- a/app/file_operation.cpp
+++ b/app/file_operation.cpp
@@ -16,6 +16,8 @@ void File_Operation::initFileOperation(){
m_start_latitude = 36.136261; // set default coordinate Westgate
m_start_longitute = -115.151254;
m_mapStyleUrls = "mapbox://styles/mapbox/streets-v10"; // set default map style
+ m_demo_state = 0;
+ m_demo_boolstate = false;
QFile file(NAVI_CONFIG_FILEPATH);
if(!file.open(QIODevice::ReadOnly)){
@@ -69,6 +71,13 @@ void File_Operation::initFileOperation(){
return;
}
+ if(jsonObj.contains("demostate")){
+ m_demo_state = jsonObj["demostate"].toInt();
+ }else{
+ fprintf(stderr,"Failed to find mapStyleUrls data \"%s\": %m", qPrintable(NAVI_CONFIG_FILEPATH));
+ return;
+ }
+
file.close();
return;
@@ -92,3 +101,11 @@ double File_Operation::getStartLongitute(){
QString File_Operation::getMapStyleUrls() {
return m_mapStyleUrls;
}
+bool File_Operation::getDemoState(){
+ if(m_demo_state == 0){
+ m_demo_boolstate = false;
+ } else{
+ m_demo_boolstate = true;
+ }
+ return m_demo_boolstate;
+}
diff --git a/app/file_operation.h b/app/file_operation.h
index 411cc25..0c7e921 100644
--- a/app/file_operation.h
+++ b/app/file_operation.h
@@ -23,6 +23,8 @@ class File_Operation: public QObject{
double m_start_latitude;
double m_start_longitute;
QString m_mapStyleUrls;
+ int m_demo_state;
+ bool m_demo_boolstate;
public:
File_Operation();
@@ -34,6 +36,7 @@ public:
Q_INVOKABLE double getStartLatitude();
Q_INVOKABLE double getStartLongitute();
Q_INVOKABLE QString getMapStyleUrls();
+ Q_INVOKABLE bool getDemoState();
private:
void initFileOperation();
diff --git a/app/navigation.qml b/app/navigation.qml
index c1404e3..ac74468 100755
--- a/app/navigation.qml
+++ b/app/navigation.qml
@@ -41,6 +41,11 @@ ApplicationWindow {
property real last_car_pos_lat: fileOperation.getStartLatitude()
property real last_car_pos_lon: fileOperation.getStartLongitute()
property real car_driving_distance : 0
+ property real carheading: 0
+ property real currentheading: 0
+ property real present_direction: 0 //North
+ property bool st_demo_state: fileOperation.getDemoState()
+ property string imgdestinationstate: ""
property string navigation_request_str: ""
@@ -58,10 +63,15 @@ ApplicationWindow {
property string verb_startguidance: "navicore_startguidance"
property string verb_cancelguidance: "navicore_cancelguidance"
property string verb_setdestinationdirection: "navicore_setdestdir"
+ property string verb_setdemostate: "navicore_demostate"
property string event_setwaypoints: "naviapi/navicore_setwaypoints"
+// property string event_canceldestpos: "naviapi/navicore_canceldestpos" // not clear
property string event_pausesimulation: "naviapi/navicore_pausesimulation"
property string event_gps: "naviapi/navicore_gps"
property string event_heading: "naviapi/navicore_heading"
+// property string event_vuisetdest: "naviapi/navicore_setdestpos"
+// property string event_vuistartdemo: "naviapi/navicore_startnavigation"
+// property string event_vuicanceldemo: "naviapi/navicore_cancelnavigation"
property var msgid_enu: { "call":2, "retok":3, "reterr":4, "event":5 }
WebSocket {
@@ -75,15 +85,24 @@ ApplicationWindow {
countdown.start()
}else if (websocket.status === WebSocket.Open){
console.log ("Socket Open")
- do_subscribe("gps")
- do_setallsessions()
- //do_setcurrentpos()
- do_getcurrentpos()
- do_setallroutes(0)
- do_subscribe("setwaypoints")
- do_subscribe("pausesimulation")
-// do_subscribe("gps")
-// do_subscribe("heading")
+ do_demostate(st_demo_state)
+ if (st_demo_state === false){
+ do_setallsessions()
+ //do_setcurrentpos()
+ do_getcurrentpos()
+ do_setallroutes(0)
+ do_subscribe("setwaypoints")
+ do_subscribe("pausesimulation")
+ do_subscribe("gps")
+ do_subscribe("heading")
+ do_subscribe("adddest")
+ } else {
+ do_setcurrentpos()
+ do_setallroutes(0)
+ do_subscribe("setwaypoints")
+ do_subscribe("pausesimulation")
+ }
+
}else if (websocket.status === WebSocket.Closed){
console.log ("Socket closed")
}
@@ -95,51 +114,115 @@ ApplicationWindow {
if (message_json[0] === msgid_enu.event){
//add destination from poi app
if(message_json[2].event === event_setwaypoints){
- var latitude = message_json[2].data[0].latitude
- var longitude = message_json[2].data[0].longitude
- var startFromCurrentPos = message_json[2].data[0].startFromCurrentPosition
+// var latitude = message_json[2].data[0].latitude
+// var longitude = message_json[2].data[0].longitude
+// var startFromCurrentPos = message_json[2].data[0].startFromCurrentPosition
// map.doSetWaypointsSlot(latitude,longitude,startFromCurrentPos);
- map.initDestination()
- map.center = map.currentpostion
- map.addDestination(QtPositioning.coordinate(35.6585580781371,139.745503664017))
- vui_startguidance()
+ root.do_cancelguidance()
+ map.initDestination()
+ map.center = map.currentpostion
+ map.addDestination(QtPositioning.coordinate(35.6585580781371,139.745503664017))
+ vui_startguidance()
}
//Pause Simulation from poi app
else if(message_json[2].event === event_pausesimulation){
map.doPauseSimulationSlot()
}
else if(message_json[2].event === event_gps){
- //console.log ("navi:Receive Event======event_gps")
- var lat = message_json[2].data.latitude
- var lon = message_json[2].data.longitude
- //console.log ("navi:Receive Event lat====== " + lat+" "+"lon======"+lon)
- map.currentpostion = QtPositioning.coordinate(lat, lon);
- //console.log ("navi:last_car_pos_lat====== " + last_car_pos_lat+" "+"last_car_pos_lon======"+last_car_pos_lon)
- car_driving_distance = map.calculateDistance(last_car_pos_lat,last_car_pos_lon,lat,lon)
- //console.log("navi:car_driving_distance ====== "+car_driving_distance)
- last_car_pos_lat = lat
- last_car_pos_lon = lon
-
- if(btn_guidance.sts_guide === 2){
- map.updatePositon()
+ if (st_demo_state === false){
+ console.log ("navi:Receive Event======event_gps")
+ var lat = message_json[2].data.latitude
+ var lon = message_json[2].data.longitude
+ console.log ("navi:Receive Event lat====== " + lat+" "+"lon======"+lon)
+ map.currentpostion = QtPositioning.coordinate(lat, lon);
+ console.log ("navi:last_car_pos_lat====== " + last_car_pos_lat+" "+"last_car_pos_lon======"+last_car_pos_lon)
+ car_driving_distance = map.calculateDistance(last_car_pos_lat,last_car_pos_lon,lat,lon)
+ console.log("navi:car_driving_distance ====== "+car_driving_distance)
+ last_car_pos_lat = lat
+ last_car_pos_lon = lon
+
+ if(btn_guidance.sts_guide === 2){
+ map.updatePositon()
+ }
}
}
+ else if(message_json[2].event === event_heading){
+ if (st_demo_state === false) {
+ console.log("navi:Receive event====== event_heading")
+ carheading = message_json[2].data.heading
+ console.log("navi: heading======"+carheading)
+ if (map.state === "smooth_rotate_north"){
+ if(carheading>=0){
+ car_direction = carheading+265-map.bearing
+ }
+ else {
+ car_direction = carheading+360+265-map.bearing
+ }
+ }
+ else if (map.state === "smooth_rotate_present"){
+ if(carheading>=0){
+ car_direction = carheading+265-map.bearing
+ }
+ else {
+ car_direction = carheading+360+265-map.bearing
+ }
+ }
+ else {
+ if(carheading>=0){
+ car_direction = carheading+265
+ }
+ else {
+ car_direction = carheading+360+265
+ }
+ }
+ }
+ }
+// else if(message_json[2].event === event_vuisetdest){
+// console.log("navi:Receive event====== event_vuisetdest")
+// var deslat = message_json[2].data[0].DestinationLatitude
+// var deslon = message_json[2].data[0].DestinationLongitude
+// console.log ("navi:deslat====== " + deslat+" "+"deslon======"+deslon)
+// map.addDestination(QtPositioning.coordinate(deslat,deslon))
+// }
+// else if(message_json[2].event === event_vuistartdemo){
+//// var demostate = message_json[2].data.demostate
+// console.log("navi:Receive event====== event_vuistartdemo")
+// vui_startguidance()
+
+// }
+// else if(message_json[2].event === event_vuicanceldemo){
+// console.log("navi:Receive event====== event_vuicanceldemo")
+// vui_cancelguidance()
+// }
+// else if(message_json[2].event === event_canceldestpos){
+// console.log("navi:Receive event====== event_canceldestpos")
+// vui_cancelguidance()
+// }
}
else if(message_json[0] === msgid_enu.retok){
if (message_json[2].request.info === verb_getcurretpos){
- //console.log("navi:Callback Response ====== verb_getcurretpos")
- var currentlat = message_json[2].response[0].CurrentLatitude
- var currentlon = message_json[2].response[0].CurrentLongitude
-// var currentheading = message_json[2].response[0].CurrentHeading
- console.log ("navi:Response verb_getcurretpos currentlat====== " + currentlat+" currentlon======"+currentlon)
- car_position_lat = currentlat
- car_position_lon = currentlon
-// car_direction = currentheading
- last_car_pos_lat = currentlat
- last_car_pos_lon = currentlon
+ if (st_demo_state === false){
+ console.log("navi:Callback Response ====== verb_getcurretpos")
+ var currentlat = message_json[2].response[0].CurrentLatitude
+ var currentlon = message_json[2].response[0].CurrentLongitude
+ currentheading = message_json[2].response[0].CurrentHeading
+ console.log ("navi:Response verb_getcurretpos currentlat====== " + currentlat+" currentlon======"+currentlon)
+ car_position_lat = currentlat
+ car_position_lon = currentlon
+// map.currentpostion = QtPositioning.coordinate(car_position_lat, car_position_lon)
+ if(currentheading>=0){
+ car_direction = currentheading+265
+ }
+ else {
+ car_direction = currentheading+360+265
+ }
+
+ last_car_pos_lat = currentlat
+ last_car_pos_lon = currentlon
+ }
}
}
}
@@ -262,6 +345,12 @@ ApplicationWindow {
console.log("navi:do_setdestinationdirection = " + navigation_request_str)
}
+ //start demo
+ function do_demostate(state) {
+ navigation_request_str = '[' + msgid_enu.call + ',"99999","' + api_str+'/'+verb_setdemostate + '", {"DemoState":"'+state+ '"} ]'
+ websocket.sendTextMessage (navigation_request_str)
+ console.log("navi:do_demostate = " + navigation_request_str)
+ }
function vui_startguidance(){
btn_guidance.startGuidance()
@@ -394,6 +483,10 @@ ApplicationWindow {
State {
name: "NorthUp"
PropertyChanges { target: car_position_mapitem_image_rotate; angle: root.car_direction }
+ },
+ State {
+ name: "HeadingUpPresent"
+ PropertyChanges { target: car_position_mapitem_image_rotate; angle: root.car_direction }
}
]
transitions: Transition {
@@ -593,6 +686,7 @@ ApplicationWindow {
console.log("initWaypoint")
// reset currentpostion
+// root.do_getcurrentpos()
map.currentpostion = QtPositioning.coordinate(car_position_lat, car_position_lon)
car_accumulated_distance = 0
do_setdemorouteinfo(car_position_lat, car_position_lon,car_direction,car_accumulated_distance)
@@ -713,11 +807,15 @@ ApplicationWindow {
{
if (Math.abs(map.pressX - mouse.x ) < map.jitterThreshold
&& Math.abs(map.pressY - mouse.y ) < map.jitterThreshold) {
-// map.addDestination(lastCoordinate)
- map.initDestination()
- map.center = map.currentpostion
- map.addDestination(QtPositioning.coordinate(35.6585580781371,139.745503664017))
-// root.vui_startguidance()
+ if (st_demo_state === true){
+ map.addDestination(lastCoordinate)
+ }
+ else {
+ root.do_cancelguidance()
+ map.initDestination()
+ map.center = map.currentpostion
+ map.addDestination(QtPositioning.coordinate(35.6585580781371,139.745503664017))
+ }
// btn_guidance.sts_guide = 2;
}
}
@@ -732,8 +830,8 @@ ApplicationWindow {
}
function updatePositon()
{
- //console.log("navi: pathcounter = "+pathcounter+" path.length = "+routeModel.get(0).path.length)
- //console.log("navi: segmentcounter = "+segmentcounter+" segments.length = "+routeModel.get(0).segments.length)
+ console.log("navi: pathcounter = "+pathcounter+" path.length = "+routeModel.get(0).path.length)
+ console.log("navi: segmentcounter = "+segmentcounter+" segments.length = "+routeModel.get(0).segments.length)
if(pathcounter <= routeModel.get(0).path.length - 1){
// calculate distance
var next_distance = calculateDistance(map.currentpostion.latitude,
@@ -754,7 +852,7 @@ ApplicationWindow {
routeModel.get(0).segments[segmentcounter].path[0].latitude,
routeModel.get(0).segments[segmentcounter].path[0].longitude);
- //console.log("navi:next_distance="+next_distance+" next_direction"+next_direction+" next_cross_distance"+next_cross_distance)
+ console.log("navi:next_distance="+next_distance+" next_direction"+next_direction+" next_cross_distance"+next_cross_distance)
// map rotateAnimation cntrol
if(root.st_heading_up) {
@@ -772,7 +870,7 @@ ApplicationWindow {
is_rotating = 360 - is_rotating;
}
- //console.log("navi:is_rotating========= "+ is_rotating)
+ console.log("navi:is_rotating========= "+ is_rotating)
// rotation angle case
if(is_rotating > 180){
@@ -808,14 +906,14 @@ ApplicationWindow {
rot_anim.easing.type = Easing.OutQuad;
}
- root.car_direction = next_direction;
+// root.car_direction = next_direction;
// set next coordidnate
- if(next_distance < 3)
+ if(next_distance < 10)
{
// car_accumulated_distance += next_distance
// do_setdemorouteinfo(map.currentpostion.latitude, map.currentpostion.longitude,next_direction,car_accumulated_distance)
- //("lqy:pathcounter ======" + pathcounter)
+ console.log("lqy:pathcounter ======" + pathcounter)
// console.log("lqy:routeModel.get(0).path.length - 1 ======" + routeModel.get(0).path.length - 1)
if(pathcounter < routeModel.get(0).path.length - 1){
pathcounter++
@@ -836,7 +934,7 @@ ApplicationWindow {
// do_setdemorouteinfo(map.currentpostion.latitude, map.currentpostion.longitude,next_direction,car_accumulated_distance)
}
- //console.log("navi:car_accumulated_distance======" + car_accumulated_distance)
+ console.log("navi:car_accumulated_distance======" + car_accumulated_distance)
car_accumulated_distance += car_driving_distance
do_setdemorouteinfo(map.currentpostion.latitude,map.currentpostion.longitude,next_direction,next_cross_distance)
@@ -849,25 +947,194 @@ ApplicationWindow {
// report a new instruction if current position matches with the head position of the segment
if(segmentcounter <= routeModel.get(0).segments.length - 1){
- if(next_cross_distance < 2){
+ if(next_cross_distance < 8){
progress_next_cross.setProgress(0)
if(segmentcounter < routeModel.get(0).segments.length - 1){
segmentcounter++
}
if(segmentcounter === routeModel.get(0).segments.length - 1){
- img_destination_direction.state = "12"
+// img_destination_direction.state = "12"
+ imgdestinationstate = "12"
map.removeMapItem(icon_segment_point)
- root.do_setdestinationdirection(img_destination_direction.state)
+// root.do_setdestinationdirection(img_destination_direction.state)
}else{
- img_destination_direction.state = routeModel.get(0).segments[segmentcounter].maneuver.direction
+// img_destination_direction.state = routeModel.get(0).segments[segmentcounter].maneuver.direction
+ imgdestinationstate = routeModel.get(0).segments[segmentcounter].maneuver.direction
icon_segment_point.coordinate = routeModel.get(0).segments[segmentcounter].path[0]
map.addMapItem(icon_segment_point)
+// root.do_setdestinationdirection(img_destination_direction.state)
+ }
+ }else{
+ if(next_cross_distance <= 330 && last_segmentcounter != segmentcounter) {
+ last_segmentcounter = segmentcounter
+ guidanceModule.guidance(routeModel.get(0).segments[segmentcounter].maneuver.instructionText)
+ img_destination_direction.state = imgdestinationstate
root.do_setdestinationdirection(img_destination_direction.state)
+ if (routeModel.get(0).segments[segmentcounter].maneuver.instructionText === "Head southeast"){
+ img_destination_direction.state = "1"
+ root.do_setdestinationdirection(img_destination_direction.state)
+ }
+ }
+ else{
+ if (next_cross_distance > 330){
+ img_destination_direction.state = "1"
+ root.do_setdestinationdirection(img_destination_direction.state)
+ }
+ }
+ // update progress_next_cross
+ progress_next_cross.setProgress(next_cross_distance)
+ }
+ }
+ }
+ }
+
+ function updateDemoPositon()
+ {
+ if(pathcounter <= routeModel.get(0).path.length - 1){
+ // calculate distance
+ var next_distance = calculateDistance(map.currentpostion.latitude,
+ map.currentpostion.longitude,
+ routeModel.get(0).path[pathcounter].latitude,
+ routeModel.get(0).path[pathcounter].longitude);
+
+ // calculate direction
+ var next_direction = calculateDirection(map.currentpostion.latitude,
+ map.currentpostion.longitude,
+ routeModel.get(0).path[pathcounter].latitude,
+ routeModel.get(0).path[pathcounter].longitude);
+
+ // calculate next cross distance
+ var next_cross_distance = calculateDistance(map.currentpostion.latitude,
+ map.currentpostion.longitude,
+ routeModel.get(0).segments[segmentcounter].path[0].latitude,
+ routeModel.get(0).segments[segmentcounter].path[0].longitude);
+
+ // map rotateAnimation cntrol
+ if(root.st_heading_up) {
+ var is_rotating = 0;
+ var cur_direction = Math.floor(map.bearing);
+
+ // check is_rorating
+ if(cur_direction > Math.floor(next_direction)){
+ is_rotating = Math.floor(cur_direction - next_direction);
+ }else{
+ is_rotating = Math.floor(next_direction - cur_direction);
+ }
+
+ if(is_rotating > 180){
+ is_rotating = 360 - is_rotating;
+ }
+
+ // rotation angle case
+ if(is_rotating > 180){
+ // driving stop hard turn
+ root.car_moving_distance = 0;
+ rot_anim.duration = 1600;
+ rot_anim.easing.type = Easing.OutQuint;
+ } else if(is_rotating > 90){
+ // driving stop normal turn
+ root.car_moving_distance = 0;
+ rot_anim.duration = 800;
+ rot_anim.easing.type = Easing.OutQuart;
+ } else if(is_rotating > 60){
+ // driving slow speed normal turn
+ root.car_moving_distance = ((car_driving_speed / 3.6) / (1000/positionTimer_interval)) * 0.3;
+ rot_anim.duration = 400;
+ rot_anim.easing.type = Easing.OutCubic;
+ } else if(is_rotating > 30){
+ // driving half speed soft turn
+ root.car_moving_distance = ((car_driving_speed / 3.6) / (1000/positionTimer_interval)) * 0.5;
+ rot_anim.duration = 300;
+ rot_anim.easing.type = Easing.OutQuad;
+ } else {
+ // driving nomal speed soft turn
+ root.car_moving_distance = (car_driving_speed / 3.6) / (1000/positionTimer_interval);
+ rot_anim.duration = 200;
+ rot_anim.easing.type = Easing.OutQuad;
+ }
+ }else{
+ // NorthUp
+ root.car_moving_distance = (car_driving_speed / 3.6) / (1000/positionTimer_interval);
+ rot_anim.duration = 200;
+ rot_anim.easing.type = Easing.OutQuad;
+ }
+
+// root.car_direction = next_direction;
+ if (map.state === "smooth_rotate_north"){
+ root.car_direction = next_direction-map.bearing;
+ }
+ else if (map.state === "smooth_rotate_present"){
+ root.car_direction = next_direction-map.bearing;
+ }
+ else {
+ root.car_direction = next_direction;
+ }
+
+ // set next coordidnate
+ if(next_distance < (root.car_moving_distance * 1.5))
+ {
+ map.currentpostion = routeModel.get(0).path[pathcounter]
+ car_accumulated_distance += next_distance
+ do_setdemorouteinfo(map.currentpostion.latitude, map.currentpostion.longitude,next_direction,car_accumulated_distance)
+ if(pathcounter < routeModel.get(0).path.length - 1){
+ pathcounter++
+ }
+ else
+ {
+ // Arrive at your destination
+ btn_guidance.sts_guide = 0
+ do_arrivedest()
+ }
+ }else{
+ setNextCoordinate(map.currentpostion.latitude, map.currentpostion.longitude,next_direction,root.car_moving_distance)
+ if(pathcounter != 0){
+ car_accumulated_distance += root.car_moving_distance
+ }
+ do_setdemorouteinfo(map.currentpostion.latitude, map.currentpostion.longitude,next_direction,car_accumulated_distance)
+ }
+
+ if(btn_present_position.state === "Flowing")
+ {
+ // update map.center
+ map.center = map.currentpostion
+ }
+ rotateMapSmooth()
+
+ // report a new instruction if current position matches with the head position of the segment
+ if(segmentcounter <= routeModel.get(0).segments.length - 1){
+ if(next_cross_distance < 2){
+ progress_next_cross.setProgress(0)
+ if(segmentcounter < routeModel.get(0).segments.length - 1){
+ segmentcounter++
+ }
+ if(segmentcounter === routeModel.get(0).segments.length - 1){
+// img_destination_direction.state = "12"
+ imgdestinationstate = "12"
+ map.removeMapItem(icon_segment_point)
+// root.do_setdestinationdirection(img_destination_direction.state)
+ }else{
+// img_destination_direction.state = routeModel.get(0).segments[segmentcounter].maneuver.direction
+ imgdestinationstate = routeModel.get(0).segments[segmentcounter].maneuver.direction
+ icon_segment_point.coordinate = routeModel.get(0).segments[segmentcounter].path[0]
+ map.addMapItem(icon_segment_point)
+// root.do_setdestinationdirection(img_destination_direction.state)
}
}else{
if(next_cross_distance <= 330 && last_segmentcounter != segmentcounter) {
last_segmentcounter = segmentcounter
guidanceModule.guidance(routeModel.get(0).segments[segmentcounter].maneuver.instructionText)
+ img_destination_direction.state = imgdestinationstate
+ root.do_setdestinationdirection(img_destination_direction.state)
+ if (routeModel.get(0).segments[segmentcounter].maneuver.instructionText === "Head southeast"){
+ img_destination_direction.state = "1"
+ root.do_setdestinationdirection(img_destination_direction.state)
+ }
+ }
+ else{
+ if (next_cross_distance > 330){
+ img_destination_direction.state = "1"
+ root.do_setdestinationdirection(img_destination_direction.state)
+ }
}
// update progress_next_cross
progress_next_cross.setProgress(next_cross_distance)
@@ -879,8 +1146,20 @@ ApplicationWindow {
function rotateMapSmooth(){
if(root.st_heading_up){
- map.state = "none"
- map.state = "smooth_rotate"
+// map.state = "none"
+// map.state = "smooth_rotate"
+ if (btn_present_position.state === "Optional"){
+
+ map.state = "smooth_rotate_present"
+ car_position_mapitem.state = "HeadingUpPresent"
+
+ }
+ else if(btn_present_position.state === "Flowing"){
+ map.state = "none"
+ map.state = "smooth_rotate"
+ car_position_mapitem.state = "HeadingUp"
+ root.present_direction = root.car_direction
+ }
}else{
map.state = "smooth_rotate_north"
}
@@ -924,6 +1203,10 @@ ApplicationWindow {
State {
name: "smooth_rotate_north"
PropertyChanges { target: map; bearing: 0 }
+ },
+ State {
+ name: "smooth_rotate_present"
+ PropertyChanges { target: map; bearing: root.present_direction }
}
]
diff --git a/naviconfig.ini b/naviconfig.ini
index 349cc6d..5f72fcb 100644
--- a/naviconfig.ini
+++ b/naviconfig.ini
@@ -4,5 +4,6 @@
"interval": 100,
"latitude": 35.66730,
"longitute": 139.7498775,
+ "demostate": 0,
"mapStyleUrls": "mapbox://styles/mapbox/streets-v10"
}