(I think this question is platform independent, but I happen to code the Nexus One).
About "current speed": I get a callback every second or so, telling me what my current latitude and longitude are. I can calculate the distance between the current location and the previous location, so I can track the cumulative distance and cumulative time. With this, I can say that the average speed was for the whole trip.
But how can I determine the current speed? I suspect that I need to use the most recent N samples, right? Am I thinking about it right? What is a good rule for N? How many samples or how many seconds ago?
About the “second”: if I just stop, I can still get several different latitudes and longitudes, informed me, right? Therefore, deciding that I really am not moving, you say something like: "the previous X locs were all in Y meters from each other," right? Am I thinking about it right? What is a good rule of thumb for X and Y?
Even about the "distance": will I underestimate this because I literally cut corners? Is there an algorithm or rule of thumb to determine when I am “turning” and should I add a little fiction?
EDIT: I OPPOSE: I feel bad when I spend people and goodwill, but, unfortunately, the device gives me speed. I thought that this was not because in the emulator it wasn’t, but on a real device. Thanks to everyone. There is still some thumb rule code I need to write, but speed was the biggest problem.
EDIT: I cancel the apology. In my original question, I wrote that distance is also a derived value. If I just use raw GPS data, I will exaggerate the distance due to inaccuracies. I could go in a straight line, but the raw GPS lat / long will fluctuate, so if I calculate the total distance by measuring the distance between the points, I will overestimate it. Here are some links related to this issue.
GPS smooth data
http://www.cs.unc.edu/~welch/kalman/Levy1997/index.html
How to intellectually degrade or smooth out GIS data (simplifying polygons)?
How to "smooth" the data and calculate the gradient of the line?