Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Even if you don't like the built-in velocity stuff, it's simple to roll your own.</p> <p>Speed is distance over time, right?</p> <p>If you've got two <code>CLLocation</code>s, you can do:</p> <pre><code>CLLocationDistance distance = [aLocation distanceFromLocation:bLocation]; </code></pre> <p><code>distance</code> is now a float of the distance between those two points, in meters. And those two <code>CLLocations</code> have <code>timestamp</code> properties too, right? Containing NSDate objects. Well...</p> <pre><code>NSTimeInterval timediff = [aDate timeIntervalSinceDate:bDate]; </code></pre> <p><code>timediff</code> is the difference in seconds.</p> <p>So your average speed between those points in meters per second is <code>distance</code> over <code>timediff</code>. You can now calculate instantaneous speed as accurately as the frequency with which you're getting location updates.</p> <p>I imagine this is all that's happening to get the <code>speed</code> property of the CLLocation object you're getting handed. But hey, you want to be closer to the math, go right ahead.</p> <p>From there, you can convert to whatever units you like. There are 1609.344 meters in a mile. There are 3600 seconds in an hour. </p> <p>NOW: This is as flawed as any pure GPS-based speed calculation, in that you're not going to get perfectly spaced tick-marks of location updates, and sometimes they're going to be way wrong. If you lose GPS signal and the device falls back to cell tower triangulation, it might put you WAY off the road somewhere, and it's going to look like you strapped on a rocket pack to get way <em>over there</em> that fast.</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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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