Improve locationupdate and accurracy of CLLocation

April 11, 2009 § 1 Comment

GPS will give roughly 6-10 meters or 20-30 feet accurracy on the first generation iphone. GPS gives roughly 1.2 meters accuracy on 3G iphone. GPS won’t work indoor as it requires the line of sight to the sky.

In reality, locationupdate doesn’t release the last cached. It affects the response and accuracy of location update.

Ignoring the locationupdate if it is not accurate or it is out-dated will resolve the issue.

// Called when the location is updated
– (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSDate* newLocationDate = newLocation.timestamp;
NSTimeInterval mostUpdatedLocation = [newLocationDate timeIntervalSinceNow];

// filter cached and too old location data
if ((!currentLocation || currentLocation.horizontalAccuracy > newLocation.horizontalAccuracy) &&
(mostUpdatedLocation < -0.0 && mostUpdatedLocation > -10.0)) {
if (currentLocation)
[currentLocation release];

currentLocation = [newLocation retain];
}

}

With each GPS update you update the current location if it is more accurate than last one, and if it is newer less than 10 sec.

Advertisements

§ One Response to Improve locationupdate and accurracy of CLLocation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading Improve locationupdate and accurracy of CLLocation at Web Builders.

meta

%d bloggers like this: