Given GPS data that consists of:
- Latitude
- Longitude
- Bearing (degrees)
- Speed (meters per second)
- Accuracy (radius of the circle around the coordinate where true position can be found with 68% chance, the radius is in meters)
- Bearing accuracy (degrees)
- Speed accuracy (meters) (All accuracies are absolute)
I want to calculate the next possible coordinate where I supposedly be if I continue traveling in the same direction with the same speed.
In addition I want to know the accuracy of the calculated position.
Here is the code of the next coordinate calculation.
function calcNextPosRad(
currentLatRad: number,
currentLonRad: number,
bearingRad: number,
speed: number,
): { latRad: number; longRad: number } {
// Constants for WGS84 ellipsoid
const a = 6378137; // Semi-major axis
const f = 1 / 298.257223563; // Flattening
const b = a * (1 - f);
// Calculate the reduced latitude
const reducedLatRad = Math.atan((1 - f) * Math.tan(currentLatRad));
const meterLatRad = Math.cos(bearingRad) / (b + reducedLatRad);
const meterLonRad = Math.sin(bearingRad) / (a * Math.cos(reducedLatRad));
return {
latRad: currentLatRad + speed * meterLatRad,
longRad: currentLonRad + speed * meterLonRad,
};
}
This code seems to be accurate and the reason for that is that I have a set of coordinates taken with interval of 1 second.
On this picture start of each green arrow is the measured coordinate, and the end is the calculated next possible position, so it kinda shows where I truly could be. (reddish circles are the accuracy of the coordinate given by GPS).
So the task I'm having troubles with is how do I calculate the accuracy of a calculated coordinate? There's accuracy of the original coordinate, accuracy of the bearing and speed, and it looks like all these accuracies should be taken into consideration during final accuracy calculations.
Here are some questions I have:
- The original latitude, longitude and bearing are in degrees, and I translate them into radians before feeding to the function. Do I need to propagate respective accuracies through these conversions?
- Since a coordinate consists of two values in degrees, but its accuracy is in meters (as given by GPS), do I need to convert the accuracy to propagate it? If so, what's the algorithm?
- Do I need to propagate the accuracy through every calculation? Including calculation of the
reducedLatRad
?