Created
February 20, 2013 17:05
-
-
Save fmundaca/4997124 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)isValidLocation:(CLLocation *)newLocation | |
withOldLocation:(CLLocation *)oldLocation | |
{ | |
// Filter out nil locations | |
if (!newLocation) | |
{ | |
NSLog(@"No es valido newLocation is Nil"); | |
return NO; | |
} | |
// Filter out points by invalid accuracy | |
if (newLocation.horizontalAccuracy < 0) | |
{ | |
NSLog(@"No es valido horizontalAccuracy < 0"); | |
return NO; | |
} | |
// Filter out points that are out of order | |
NSTimeInterval secondsSinceLastPoint = | |
[newLocation.timestamp timeIntervalSinceDate:oldLocation.timestamp]; | |
if (secondsSinceLastPoint < 0) | |
{ | |
NSLog(@"No es valido secondsSinceLastPoint = %f ",secondsSinceLastPoint); | |
return NO; | |
} | |
// Filter out points created before the manager was initialized | |
NSTimeInterval secondsSinceManagerStarted = | |
[newLocation.timestamp timeIntervalSinceDate:startTime]; | |
if (secondsSinceManagerStarted < 0) | |
{ | |
NSLog(@"No es valido secondsSinceManagerStarted < 0 => %f",secondsSinceManagerStarted); | |
return NO; | |
} | |
NSLog(@"ES VALIDO"); | |
// The newLocation is good to use | |
return YES; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment