xcode requiredAccuracy 和 distanceFilter 之间的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6979319/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
difference between desiredAccuracy and distanceFilter
提问by Neelesh
Sorry for being a noob here. I am not able to clearly differentiate between CLLocationManager's properties distanceFilterand desiredAccuracy.
很抱歉在这里成为菜鸟。我无法清楚地区分 CLLocationManager 的属性distanceFilter和desiredAccuracy。
If I want my application to give different coordinates for even small distances (say 100-200 metres) what values should i set for these properties.
如果我希望我的应用程序为小距离(比如 100-200 米)提供不同的坐标,我应该为这些属性设置什么值。
Help would be greatly appreciated.
帮助将不胜感激。
回答by Vlad
According to developer.apple.com
根据 developer.apple.com
distanceFilter
The minimum distance (measured in meters) a device must move laterally before an update event is generated.
距离过滤器
在生成更新事件之前,设备必须横向移动的最小距离(以米为单位)。
That means, based on previous location event, another location update will only be received after exceeding distanceFilter value distance.
这意味着,基于之前的位置事件,只有在超过 distanceFilter 值距离后才会收到另一个位置更新。
desiredAccuracy refers to how accurate your location data should be. For example if you wish to see the exact street you're on you a high accuracy value for this parameter. (kCLLocationAccuracyBest) If you only wish to see the approximate area (such as in which neighbourhood you're in) you'd set a lower accuracy value for this param. (kCLLocationAccuracyThreeKilometers)
requiredAccuracy 是指您的位置数据应该有多准确。例如,如果您希望查看您所在的确切街道,则此参数的准确度值很高。(kCLLocationAccuracyBest) 如果您只想查看近似区域(例如您所在的社区),您可以为此参数设置一个较低的准确度值。(kCLLocationAccuracyThreeKilometers)
Choose this to suit your needs, however be aware that the more precise you wish to be and the more often you request updates, the more power it will drain from your device.
选择它以满足您的需求,但请注意,您希望的精度越高,请求更新的频率越高,设备消耗的电量就越多。
Hope this helps, Vlad
希望这会有所帮助,弗拉德
回答by Serhii Mamontov
distanceFilter- this is minimal distance which device should pass from previous location which was passed to delegate with ...didUpdateToLocation:...method. And as soon as distance reached location service will invoke ...didUpdateToLocation...again and so on.
distanceFilter- 这是设备应该从先前位置传递的最小距离,该位置通过...didUpdateToLocation:...方法传递给委托。一旦到达距离,定位服务将再次调用...didUpdateToLocation...,依此类推。
desiredAccuracy- tells to location service how accurate coordinate you want and this is minimal location error radius. If value is very low (ex. 5) radio will try to use GPS hardware and will keep powering it up hardly to make it give most accurate location. If value is large,than system may decide to use data which was retrieved from WiFi hotspots location triangulation.
requiredAccuracy- 告诉定位服务你想要的坐标有多精确,这是最小的定位误差半径。如果值非常低(例如 5),无线电将尝试使用 GPS 硬件,并几乎不给它加电以使其提供最准确的位置。如果值很大,则系统可能会决定使用从 WiFi 热点位置三角测量中检索到的数据。