How would you sample a real-time stream of coordinates to create a Speed Graph?

Posted by Andrew Johnson on Stack Overflow See other posts from Stack Overflow or by Andrew Johnson
Published on 2010-04-03T21:58:13Z Indexed on 2010/04/03 22:03 UTC
Read the original article Hit count: 309

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about graph