title: Issue in finding the speed when using CLLocationManager
body: <p>I am developing a speedometer application in iPhone. I have used CLLocationManager(GPS based) to measure the speed of a vehicle. But i don't get accurate speed. I have tried all the filtering methods given in various stackoverflow discussions. But i don't get any improvement. At times, the speed reaches to a greater value(>400kmph).</p>
  
  <p>I dont know what goes wrong. Please suggest me any code to get the accurate speed.</p>
  
  <p>Thanks in advance,</p>
  
  <p>I have followed the below mentioned stack over flow discussions</p>
  
  <p><a href="https://stackoverflow.com/questions/1994018/measuring-velocity-via-iphone-sdk">Measuring velocity via iPhone SDK</a></p>
  
  <p><a href="https://stackoverflow.com/questions/1081219/optimizing-cllocationmanager-corelocation-to-retrieve-data-points-faster-on-the-i">Optimizing CLLocationManager/CoreLocation to retrieve data points faster on the iPhone</a></p>
  
  <p><a href="https://stackoverflow.com/questions/1391589/cllocation-speed">CLLocation speed</a></p>
  
  <p><a href="https://stackoverflow.com/questions/1180050/why-is-my-cllocation-speed-so-inaccurate">Why is my CLLocation speed so inaccurate?</a></p>
  
  <p>I have currently implemented the following code:</p>
  
  <pre><code>//locationManager declaration in ViewDidLoad
  
  locManager=[[CLLocationManager alloc]init];
  locManager.delegate =self;
  [locManager startUpdatingLocation];           
  
  
  - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
  
      NSTimeInterval locationAge = abs([newLocation.timestamp timeIntervalSinceNow]);
  
      if (locationAge &gt; 5.0) return;
      if (newLocation.speed &lt; 0 || newLocation.horizontalAccuracy &lt; 0) return;
      if ((newLocation.horizontalAccuracy &lt; (oldLocation.horizontalAccuracy - 10.0)) || (newLocation.horizontalAccuracy &lt; 50.0)|| (newLocation.horizontalAccuracy &lt;= 150.0))
      {
          if(oldLocation != nil)
          {
              CLLocationDistance distanceChange = [newLocation distanceFromLocation:oldLocation];
  
              NSTimeInterval sinceLastUpdate = [newLocation.timestamp timeIntervalSinceDate:oldLocation.timestamp];
  
  
              double calculatedSpeed;
              calculatedSpeed = (distanceChange / sinceLastUpdate)*3.6;   // to convert the speed into kmph.
  
          }       
      }
  
  }
  </code></pre>