title: iOS Location Services Method for Filtering out invalid/inaccurate locations
body: <p>I am using <code>Location Services</code> in a few of my apps.  I have a method that I use in my <code>locationManager:didUpdateToLocation:fromLocation:</code> method to filter out bad, inaccurate or too far away locations.  And to minimize gps "jitter".  Here is what I use:</p>
  
  <pre><code>/**
   * Check if we have a valid location
   *
   * @version $Revision: 0.1
   */
  + (BOOL)isValidLocation:(CLLocation *)newLocation withOldLocation:(CLLocation *)oldLocation {
  
      // Filter out nil locations
      if (!newLocation) return NO;
  
      // Filter out points by invalid accuracy
      if (newLocation.horizontalAccuracy &lt; 0) return NO;
      if (newLocation.horizontalAccuracy &gt; 66) return NO;
  
      // Filter out points by invalid accuracy
      #if !TARGET_IPHONE_SIMULATOR
      if (newLocation.verticalAccuracy &lt; 0) return NO;
      #endif
  
      // Filter out points that are out of order
      NSTimeInterval secondsSinceLastPoint = [newLocation.timestamp timeIntervalSinceDate:oldLocation.timestamp];
      if (secondsSinceLastPoint &lt; 0) return NO;
  
      // Make sure the update is new not cached
      NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow];
      if (locationAge &gt; 5.0) return NO;
  
      // Check to see if old and new are the same
      if ((oldLocation.coordinate.latitude == newLocation.coordinate.latitude) &amp;&amp; (oldLocation.coordinate.longitude == newLocation.coordinate.longitude)) 
          return NO;
  
      return YES;
  
  }//end
  </code></pre>
  
  <p>Does anyone have any improvements on this method to make it more accurate?  Is <strong>66</strong> too high of a <code>horizontalAccuracy</code> and will receive lots of invalid locations?  Should I lower this?</p>
  
  <p>Is there a way to get rid of the "jitter" that gps on the iPhone gives?</p>