ximmyxiao
ximmyxiao

Reputation: 2811

why did didupdatelocation be called when device is not moved

i use CLLocation for a app that record people's trace in map view when they are running or walking ,but i found when my device is still (not moved) ,the - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations is also get called frequently ? currently ,my locationmanager's desiredAccuracy is 10 meters and distanceFilter is 10.

how to deal with this situation? I have tried use big distancefilter value(like 150) ,but I found if i do this, then i can't record exactly when people is running or walking

Upvotes: 4

Views: 1159

Answers (3)

mfaani
mfaani

Reputation: 36297

How does system know whether or not you have actually moved? It MUST fetch your location to find out. The more accurate your desired accuracy is, the more vigorously and frequently it would look. By vigorous I mean if it's suppose to use cell-tower information then it would look into more cell-towers to better triangulate. Or simply put it, the interval between its fetches would be smaller. Concluding: OS would fetch data even if you don't move.

Additionally to triangulate your position the OS (depending on your desiredAccuracy and previous movements) would use a mix of GPS, wifi, Cell-tower. And because someone may all of sudden turn off/on their wifi, or satellite that you were using to get your location has moved a bit or the satellites have changed, or a cell-tower signal may become more or less accurate due to its bandwidth limitations then your calculated location may change which triggers a callback if it's more than your distanceFilter. ( I don't believe you get callbacks for less than your distanceFilter, but I may be wrong) This likely means your distanceFilter is set to very small number which depending on your business requirements may or may not be a good choice. Concluding: your location is never ever 100% accurate

The result of periodical fetching, possibility of error and small distanceFilters lead to possible incorrect locationChanges.

Upvotes: 1

rmaddy
rmaddy

Reputation: 318824

GPS is not exact. You can move around a few feet and get the same location. Or you can sit still and get told you have moved a few feet.

You might be able to combine measurements from the accelerometer to determine if you have really moved but this would only work if the device was sitting on a table not moving.

Upvotes: 6

Tommy Devoy
Tommy Devoy

Reputation: 13549

Have you called stopUpdatingLocation after the initial startUpdatingLocation? It will keep updating location if you do not call it.

Upvotes: 3

Related Questions