I wonder if this should be done with the "Recording GPS Tracks" option?
Ideally I would like a Journey function to be called once the GPS has locked?
I wonder if this should be done with the "Recording GPS Tracks" option?
Ideally I would like a Journey function to be called once the GPS has locked?
The easiest way to do this is to inspect the horizontal_accuracy
attribute of the GPS coordinate set, and when it is within a certain user defined limit you can consider it ‘locked’ and then only persist the value to the DB.
Something like this.
function hasLocked() {
var threshold = 50; // numerical value in meters
// return true if the horizontal accuracy is less or equal to the threshold, else return false
return view.gps_coordinates && view.gps_coordinates.horizontal_accuracy <= threshold;
}
To be clear, the concept of locked is a ‘fluid’ thing and will depend on the required accuracy of the GPS coordinates for the use case at hand.
Also note, accuracy and ‘time to become more accurate’ will depend on the quality of the device’s GPS unit, current device connections (cellular, mobile data and wifi) as well as time since last known GPS location for the device.