How would you sample a real-time stream of coordinates to create a Speed Graph?
- by Andrew Johnson
I have a GPS device, and I am receiving continuous points, which I store in an array. These points are time stamped.
I would like to graph distance/time (speed) vs. distance in real-time; however, I can only plot 50 of the points because of hardware constraints.
How would you select points from the array to graph?
For example, one algorithm might be to select every Nth point from the array, where N results in 50 points total. Code:
float indexModifier = 1;
if (MIN(50,track.lastPointIndex) == 50) {
indexModifier = track.lastPointIndex/50.0f;
}
index = ceil(index*indexModifier);
Another algorithm might be to keep an array of 50 points, and throw out the point with the least speed change each time you get a new point.