If I set my CLLocationManager's desired accuracy to be kCLLocationAccuracyKilometer (accurate within a kilometer) will the iPhone deliver a better position eventually, when it gets it ? Or will it stop at my desired accuracy. I can't find this in the documentation.
如果我将CLLocationManager想要的精度设置为kcllocationaccuracykm(在一公里之内准确),那么当iPhone获得时,它最终会提供更好的位置吗?或者它会在我想要的精度停止。我在文件中找不到。
The idea is that I need a fast fix for the location, but then I would like to go more accurate. Will I have to code this myself, or is it done for me automatically ?
我的想法是,我需要一个快速修复的位置,但我想要更准确。我必须自己编码,还是自动完成?
3 个解决方案
#1
3
I don't know if the following is 100% correct, but I am pretty sure it works like this: the accuracy filters are primarily designed to save energy. So if you specify that kCLLocationAccuracyKilometer
is enough for you and the OS is pretty certain that it can locate you accurately within 1 km using triangulation only, it won't even power up the battery-draining GPS unit. So regarding your first question, the location manager will stop as soon as it reaches your desired accuracy.
我不知道下面的内容是否100%正确,但我很确定它是这样工作的:精确度过滤器主要是为了节省能源。所以,如果你指定kcllocationaccuracykm对你来说足够了,而且操作系统非常确定,仅通过三角定位就可以在1公里内精确定位你的位置,它甚至不会为耗尽电池的GPS设备供电。所以关于你的第一个问题,位置管理器会在它达到你想要的精度后立即停止。
Regarding the second question: I don't think the accuracy filter has any influence on the time you receive your first location update. The OS often caches your last known location and will deliver that one almost instantly even if you have specified a very high accuracy. Subsequent location updates will get more and more precise.
关于第二个问题:我认为精度过滤器不会影响您收到第一次位置更新的时间。操作系统通常会缓存你最后一个已知的位置,即使你已经指定了一个非常高的精度,它也会立即传送那个位置。后续的位置更新将变得越来越精确。
You should be able to easily test for yourself if this is indeed the real behavior.
如果这确实是真实的行为,那么您应该能够轻松地为自己测试。
#2
2
Set the best accuracy you need (but not more, because location services consume too much power). LocationManager will call didUpdateToLocation of your CLLocationManagerDelegate every time accuracy is improved. Stop updating location as soon as you can to prevent battery exhausting.
设置您需要的最佳精度(但不能设置更多,因为位置服务消耗了太多的电力)。LocationManager将在每次精度提高时调用CLLocationManagerDelegate的didUpdateToLocation。尽快停止更新位置,防止电池耗尽。
#3
1
No, it will stop at the specified accuracy. If you request only kCLLocationAccuracyKilometer
then the GPS receiver won't be powered on and it will get no better than WiFi or Cell tower triangulation. [The only exception would be if another app in the background (like TomTom nav) already has the GPS on for high accuracy fixes, then you might get the high (<300m) accuracy fixes too).
不,它将停止在指定的精度。如果你只要求kcllocationaccuracykm,那么GPS接收器就不会被打开,它不会比WiFi或蜂窝基站三角定位更好。[唯一的例外是,如果后台的另一个应用程序(比如TomTom nav)已经打开GPS进行高精度修复,那么你可能也会得到高精度(<300米)修复)。
If you want better you have to request it and you might as well request it immediately, you'll get the fast fix (1000m accuracy) fix right away and in a minute or two you'll get the high accuracy GPS fix (well, it can take 30 seconds up to 10 min depending on several things). No special coding is required, just specify the accuracy you eventually want.
如果你想要更好的请求,你不妨立即请求它,你会得到快速修复(1000准确性)修复马上在一两分钟你会得到高精度GPS解决(这可能需要30秒10分钟取决于几件事情)。不需要特殊的编码,只需指定您最终想要的精度。
#1
3
I don't know if the following is 100% correct, but I am pretty sure it works like this: the accuracy filters are primarily designed to save energy. So if you specify that kCLLocationAccuracyKilometer
is enough for you and the OS is pretty certain that it can locate you accurately within 1 km using triangulation only, it won't even power up the battery-draining GPS unit. So regarding your first question, the location manager will stop as soon as it reaches your desired accuracy.
我不知道下面的内容是否100%正确,但我很确定它是这样工作的:精确度过滤器主要是为了节省能源。所以,如果你指定kcllocationaccuracykm对你来说足够了,而且操作系统非常确定,仅通过三角定位就可以在1公里内精确定位你的位置,它甚至不会为耗尽电池的GPS设备供电。所以关于你的第一个问题,位置管理器会在它达到你想要的精度后立即停止。
Regarding the second question: I don't think the accuracy filter has any influence on the time you receive your first location update. The OS often caches your last known location and will deliver that one almost instantly even if you have specified a very high accuracy. Subsequent location updates will get more and more precise.
关于第二个问题:我认为精度过滤器不会影响您收到第一次位置更新的时间。操作系统通常会缓存你最后一个已知的位置,即使你已经指定了一个非常高的精度,它也会立即传送那个位置。后续的位置更新将变得越来越精确。
You should be able to easily test for yourself if this is indeed the real behavior.
如果这确实是真实的行为,那么您应该能够轻松地为自己测试。
#2
2
Set the best accuracy you need (but not more, because location services consume too much power). LocationManager will call didUpdateToLocation of your CLLocationManagerDelegate every time accuracy is improved. Stop updating location as soon as you can to prevent battery exhausting.
设置您需要的最佳精度(但不能设置更多,因为位置服务消耗了太多的电力)。LocationManager将在每次精度提高时调用CLLocationManagerDelegate的didUpdateToLocation。尽快停止更新位置,防止电池耗尽。
#3
1
No, it will stop at the specified accuracy. If you request only kCLLocationAccuracyKilometer
then the GPS receiver won't be powered on and it will get no better than WiFi or Cell tower triangulation. [The only exception would be if another app in the background (like TomTom nav) already has the GPS on for high accuracy fixes, then you might get the high (<300m) accuracy fixes too).
不,它将停止在指定的精度。如果你只要求kcllocationaccuracykm,那么GPS接收器就不会被打开,它不会比WiFi或蜂窝基站三角定位更好。[唯一的例外是,如果后台的另一个应用程序(比如TomTom nav)已经打开GPS进行高精度修复,那么你可能也会得到高精度(<300米)修复)。
If you want better you have to request it and you might as well request it immediately, you'll get the fast fix (1000m accuracy) fix right away and in a minute or two you'll get the high accuracy GPS fix (well, it can take 30 seconds up to 10 min depending on several things). No special coding is required, just specify the accuracy you eventually want.
如果你想要更好的请求,你不妨立即请求它,你会得到快速修复(1000准确性)修复马上在一两分钟你会得到高精度GPS解决(这可能需要30秒10分钟取决于几件事情)。不需要特殊的编码,只需指定您最终想要的精度。