Note that there are some explanatory texts on larger screens.

plurals
  1. POI'm getting a callback with latitude and longitude, how can I best calculate "current speed", and other derived values?
    primarykey
    data
    text
    <p>(I think this question is platform independent, but I happen to be coding for a Nexus One).</p> <p>About "current speed": I'm getting a callback every second or so telling me what my current latitude and longitude are. I can calc the distance between the current location and the previous location, so I can keep track of cumulative distance and cumulative time. With that I can say what the average speed has been for the ENTIRE trip.</p> <p>But how do I calc current speed? I suspect I need to use the most recent N samples, right? Am I thinking about this the right way? What's a good rule of thumb for N? How many samples, or how many seconds back?</p> <p>About "stop time": If I'm just standing still, I can still get slightly different latitudes and longitudes reported to me, right? So, deciding that I'm not really moving means saying something like, "the previous X locs have all been within Y meters of each other", right? Am I thinking about this the right way? What's a good rule of thumb for X and Y?</p> <p>Even about "distance": Will I be understating it because I'm literally cutting corners? Is there an algorithm or a rule of thumb, for determining when I'm "turning" and should I add in a little fudge?</p> <p>EDIT: I APOLOGIZE: I feel bad about wasting people's time and good will, but sadly, the device <em>IS</em> giving me speed. I thought it wasn't because in the emulator it wasn't, but on the real device it is. Thanks everybody. There's still some rule-of-thumb code I need to write, but speed was the biggest challenge.</p> <p>EDIT: I retract the apology. In my original question I wrote that distance too is a derived value. If I just use the raw GPS data, I will be overstating distance because of the inaccuracies. I might be walking a straight line, but the raw GPS lat/long will wobble, so if I calc total distance by measuring the distance between the points, I will be overstating it. Here's some links that are related to this problem.</p> <p><a href="https://stackoverflow.com/questions/1134579/smooth-gps-data">Smooth GPS data</a><br> <a href="http://www.cs.unc.edu/~welch/kalman/Levy1997/index.html" rel="nofollow noreferrer">http://www.cs.unc.edu/~welch/kalman/Levy1997/index.html</a><br> <a href="https://stackoverflow.com/questions/1849928/how-to-intelligently-degrade-or-smooth-gis-data-simplifying-polygons">How to intelligently degrade or smooth GIS data (simplifying polygons)?</a><br> <a href="https://stackoverflow.com/questions/204184/how-to-smooth-data-and-calculate-line-gradient">How to &#39;smooth&#39; data and calculate line gradient?</a> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload