2011-11-28 92 views
3

我正在研究一個簡單的應用程序,它具有以下要求:任務將在給定位置開始,並且在用戶漫遊一定距離後,該任務應自動結束。啓動監視重要位置更改缺乏準確性

我目前正在使用CLLocationManager的startUpdatingLocation獲取初始GPS位置,精度在100米以內。這工作正常。

然後我使用CLLocationManager的startMonitoringSignificantLocationChanges來確定用戶是否已經走得夠遠。我使用這種方法,因爲它在電池壽命上更好,可以在後臺運行等。

現在,我遇到的問題是使用startMonitoringSignificantLocationChanges返回的位置的準確性。如果我只是讓手機坐在我的桌子上等待10-20分鐘,由於startMonitoringSignificantLocationChanges返回的位置準確(或缺少),它會自動結束任務。例如:

2011-11-27 20:21:44.653 MyApp[2692:707] Location manager wants 100.000000 meter accuracy 
2011-11-27 20:21:44.655 MyApp[2692:707] Location manager got 99.260482 meter accuracy 
2011-11-27 20:27:52.975 MyApp[2692:707] visit location: lat 43.619912 long -70.237781 
2011-11-27 20:27:52.977 MyApp[2692:707] current location: lat 43.619808 long -70.237561 
2011-11-27 20:27:52.981 MyApp[2692:707] moved 21.155182 meters from visit origin 
2011-11-27 20:37:53.205 MyApp[2692:707] visit location: lat 43.619912 long -70.237781 
2011-11-27 20:37:53.207 MyApp[2692:707] current location: lat 43.628081 long -70.231727 
2011-11-27 20:37:53.211 MyApp[2692:707] moved 1030.822457 meters from visit origin 

以上所有都發生在沒有我移動設備一英寸的情況下。我的直覺是,啓動監視重要位置更改不夠準確,無法完成此要求。是這樣嗎?或者我可能忽略了一些東西?

任何反饋將不勝感激。我沒有發佈任何代碼,但它都是非常基本的CLLocationManager。讓我知道是否需要更多信息或代碼片段。

在此先感謝!

回答

5

the CLLocationManager docs

此接口[e.g,startMonitoringSignificantLocationChanges]提供了新的事件,只有當它檢測到更改設備的相關信號發射塔,從而減少頻繁的更新和顯著降低功耗。

因此,它是不可能的,startMonitoringSignificantLocationChanges可用於檢查的準確度等級你要找的地方 - 這是罕見的,手機發射塔可以本地化你那麼好。您可能需要嘗試使用startMonitoringForRegion:desiredAccuracy:代替;它也在後臺運行,並且會爲你測試該區域的很多骯髒工作。

+0

謝謝 - 我意識到,手機塔更改觸發事件與startMonitoringSignificantLocationChanges,但不是該蜂窩被用來檢測位置而不是GPS。是否有文件記錄GPS不能用於startMonitoringSignificantLocationChanges? –

+0

另一個小小的評論 - 如果手機信號塔的變化觸發事件,爲什麼在手機從未移動時發生這種情況? –

+0

不明確,但我看不到任何'startMonitoringSignificantLocationChanges'會使用GPS的原因。 sMSLC的重點在於節能;自動啓動GPS,並在每次改變位置時等待修復將消耗不必要的功率。關於手機不動 - 手機可以並且會自動切換塔,可能是因爲信號強度的變化。 – duskwuff