4

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

ximmyxiao
  • 2,622
  • 3
  • 20
  • 35

3 Answers3

6

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.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • 1
    i found another solution to solve this problem : use speed ivar of CLLocation,in fact ,i found that all the locations you get when your device is not moved has a speed that is negative ,so we can filt all the locations which has the negative speed . – ximmyxiao Mar 04 '13 at 03:38
  • "Or you can sit still and get told you have moved a few feet." I think this isn't really because it **detects actual movement**, rather because it just needs to check your location frequently and obviously GPS tracking is not 100% accurate. In doing so it may get a different result. The frequency it checks is likely based on a number of factors, your desiredAccuracy, your recent movements and your distanceFilter – mfaani Aug 03 '17 at 10:27
3

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

Tommy Devoy
  • 13,441
  • 3
  • 48
  • 75
  • but i can't call stopUpdatingLocation immediatly ,because i have to get ready to trace when people is moving:( – ximmyxiao Feb 20 '13 at 02:29
1

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.

mfaani
  • 33,269
  • 19
  • 164
  • 293