gpstrek - Automatically search for new waypoint
parent
c1f2ca5b78
commit
aa9672c29b
|
|
@ -740,15 +740,15 @@ const compassSliceData = {
|
||||||
},
|
},
|
||||||
getPoints: function (){
|
getPoints: function (){
|
||||||
let points = [];
|
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){
|
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});
|
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){
|
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});
|
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;
|
return points;
|
||||||
},
|
},
|
||||||
getMarkers: function (){
|
getMarkers: function (){
|
||||||
|
|
@ -758,14 +758,26 @@ const compassSliceData = {
|
||||||
|
|
||||||
const waypointData = {
|
const waypointData = {
|
||||||
icon: atob("EBCBAAAAAAAAAAAAcIB+zg/uAe4AwACAAAAAAAAAAAAAAAAA"),
|
icon: atob("EBCBAAAAAAAAAAAAcIB+zg/uAe4AwACAAAAAAAAAAAAAAAAA"),
|
||||||
|
minimumDistance: Number.MAX_VALUE,
|
||||||
getProgress: function() {
|
getProgress: function() {
|
||||||
return (WIDGETS.gpstrek.getState().route.index + 1) + "/" + WIDGETS.gpstrek.getState().route.count;
|
return (WIDGETS.gpstrek.getState().route.index + 1) + "/" + WIDGETS.gpstrek.getState().route.count;
|
||||||
},
|
},
|
||||||
getTarget: function (){
|
getTarget: function (){
|
||||||
if (distance(WIDGETS.gpstrek.getState().currentPos,WIDGETS.gpstrek.getState().route.currentWaypoint) < 30 && hasNext(WIDGETS.gpstrek.getState().route)){
|
let currentDistanceToTarget = distance(WIDGETS.gpstrek.getState().currentPos,WIDGETS.gpstrek.getState().route.currentWaypoint);
|
||||||
next(WIDGETS.gpstrek.getState().route);
|
if (currentDistanceToTarget < this.minimumDistance){
|
||||||
Bangle.buzz(1000);
|
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;
|
return WIDGETS.gpstrek.getState().route.currentWaypoint;
|
||||||
},
|
},
|
||||||
getStart: function (){
|
getStart: function (){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue