gpstrek - Automatically search for new waypoint
parent
c1f2ca5b78
commit
aa9672c29b
|
|
@ -740,15 +740,15 @@ const compassSliceData = {
|
|||
},
|
||||
getPoints: function (){
|
||||
let points = [];
|
||||
if (WIDGETS.gpstrek.getState().currentPos && WIDGETS.gpstrek.getState().currentPos.lon && WIDGETS.gpstrek.getState().route && WIDGETS.gpstrek.getState().route.currentWaypoint){
|
||||
points.push({bearing:bearing(WIDGETS.gpstrek.getState().currentPos, WIDGETS.gpstrek.getState().route.currentWaypoint), color:"#0f0"});
|
||||
}
|
||||
if (WIDGETS.gpstrek.getState().currentPos && WIDGETS.gpstrek.getState().currentPos.lon && WIDGETS.gpstrek.getState().route){
|
||||
points.push({bearing:bearing(WIDGETS.gpstrek.getState().currentPos, getLast(WIDGETS.gpstrek.getState().route)), icon: finishIcon});
|
||||
}
|
||||
if (WIDGETS.gpstrek.getState().currentPos && WIDGETS.gpstrek.getState().currentPos.lon && WIDGETS.gpstrek.getState().waypoint){
|
||||
points.push({bearing:bearing(WIDGETS.gpstrek.getState().currentPos, WIDGETS.gpstrek.getState().waypoint), icon: finishIcon});
|
||||
}
|
||||
if (WIDGETS.gpstrek.getState().currentPos && WIDGETS.gpstrek.getState().currentPos.lon && WIDGETS.gpstrek.getState().route && WIDGETS.gpstrek.getState().route.currentWaypoint){
|
||||
points.push({bearing:bearing(WIDGETS.gpstrek.getState().currentPos, WIDGETS.gpstrek.getState().route.currentWaypoint), color:"#0f0"});
|
||||
}
|
||||
return points;
|
||||
},
|
||||
getMarkers: function (){
|
||||
|
|
@ -758,14 +758,26 @@ const compassSliceData = {
|
|||
|
||||
const waypointData = {
|
||||
icon: atob("EBCBAAAAAAAAAAAAcIB+zg/uAe4AwACAAAAAAAAAAAAAAAAA"),
|
||||
minimumDistance: Number.MAX_VALUE,
|
||||
getProgress: function() {
|
||||
return (WIDGETS.gpstrek.getState().route.index + 1) + "/" + WIDGETS.gpstrek.getState().route.count;
|
||||
},
|
||||
getTarget: function (){
|
||||
if (distance(WIDGETS.gpstrek.getState().currentPos,WIDGETS.gpstrek.getState().route.currentWaypoint) < 30 && hasNext(WIDGETS.gpstrek.getState().route)){
|
||||
next(WIDGETS.gpstrek.getState().route);
|
||||
Bangle.buzz(1000);
|
||||
let currentDistanceToTarget = distance(WIDGETS.gpstrek.getState().currentPos,WIDGETS.gpstrek.getState().route.currentWaypoint);
|
||||
if (currentDistanceToTarget < this.minimumDistance){
|
||||
this.minimumDistance = currentDistanceToTarget;
|
||||
}
|
||||
let nextAvailable = hasNext(WIDGETS.gpstrek.getState().route);
|
||||
if (currentDistanceToTarget < 30 && nextAvailable){
|
||||
next(WIDGETS.gpstrek.getState().route);
|
||||
this.minimumDistance = Number.MAX_VALUE;
|
||||
} else if (this.minimumDistance < currentDistanceToTarget - 30){
|
||||
stopDrawing();
|
||||
setClosestWaypoint(WIDGETS.gpstrek.getState().route, WIDGETS.gpstrek.getState().route.index, showProgress);
|
||||
Bangle.buzz(1000);
|
||||
removeMenu();
|
||||
}
|
||||
|
||||
return WIDGETS.gpstrek.getState().route.currentWaypoint;
|
||||
},
|
||||
getStart: function (){
|
||||
|
|
|
|||
Loading…
Reference in New Issue