32

以下内容在 CLLocation.h 中列出,但根据我的经验,它们是欺骗性名称 - 最初可能被认为有两个目的,1. 测试返回位置的准确性,以及 2. 设置位置管理器的工作强度,特别是启用了什么(gps(有多少卫星频道),wifi 工作的强度,三角测量等。

extern const CLLocationAccuracy kCLLocationAccuracyBestForNavigation; // (raw value: -2)
extern const CLLocationAccuracy kCLLocationAccuracyBest; // (raw value: -1)
extern const CLLocationAccuracy kCLLocationAccuracyNearestTenMeters; // (raw value: 10)
extern const CLLocationAccuracy kCLLocationAccuracyHundredMeters; // (raw value: 100)
extern const CLLocationAccuracy kCLLocationAccuracyKilometer; // (raw value: 1000)
extern const CLLocationAccuracy kCLLocationAccuracyThreeKilometers; // (raw value: 3000)

我很想看看 CLLocation.m,但因为这不太可能很快发生 - 有没有人有任何现场测试显示他们认为这些不同模式会发生什么。

即,kCLLocationAccuracyBest = 10 颗卫星(频道/中继线?),100% 的 wifi 功率等。

我在这里有点猜测稻草-我认为这是苹果应该提供的信息类型-

我真正想知道的是,与kCLLocationAccuracyThreeKilometers电池消耗有关的实际情况是什么——gps 是否开启?1 坐式后备箱?wifi启用了吗?定时器上的wifi?谁知道?我知道我想

4

3 回答 3

57

我同意 Olie 的观点,即隐藏算法的细节是为了保护应用程序开发人员不必担心如何确定位置。话虽如此,我相信问这个问题仍然是合理的:“我的准确性选择的功率影响是什么?”。

我有一些信息可能会指导您决定使用哪个,但我不知道 Apple 实施的真正细节。

首先,假设随着读数变得更加准确,系统将需要使用更多耗电的无线电。例如,在 100 米范围内,GPS 将需要最详细的读数,并且它使用的功率最大。

这是对用于确定准确性的机制的有根据的猜测。列表按 (1) 排序,是最高的电池消耗。

  1. GPS - kCLLocationAccuracyBestForNavigation;
  2. GPS - kCLLocationAccuracyBest;
  3. GPS - kCLLocationAccuracyNearestTenMeters;
  4. WiFi(或农村地区的 GPS) - kCLLocationAccuracyHundredMeters;
  5. 蜂窝塔 - kCLLocationAccuracyKilometer;
  6. 蜂窝塔 - kCLLocationAccuracyThreeKilometers;

在选择时,Apple 建议您选择您的应用程序可以承受的最粗粒度的精度。

希望有帮助,一点点。

于 2010-08-11T16:33:08.040 回答
10

在大城市的商业区,wifi和手机信号塔三角网都很好。住宅郊区他们不是那么好。在农村地区,如果他们工作的话,他们几乎不工作。

GPS 在室内不能很好地工作,如果没有手机信号塔的帮助,可能需要很长时间才能得到任何修复(可能需要 20 分钟!!)。卫星需要很长时间才能广播足够的信息来确定您的位置,并且可能会丢失数据包(云、建筑物、树木、山脉等)。值得注意的是,一个合适的高端 GPS 会有一个篮球大小的天线,任何手持 GPS 都无法获得完美的信号。

即使在信号完美的户外,当您快速改变方向时(例如在高速公路上或有风的道路上),GPS 也不准确。BestForNavigation 设置使用加速度计和陀螺仪来抵消这一点。

目前,iOS平台使用:

  • GPS:非常准确,但耗电量大,速度慢且并非始终可用。有些硬件没有 GPS。
  • WiFi:耗电量大,仅在城市中有效。也可能完全错误(例如,将您放在错误的城市)
  • 手机信号塔:几乎没有电力消耗,在城市中运行良好。在农村地区不是很好。在某些硬件上不存在。
  • 加速度计:对其他位置修复略有改进,但耗电量很大。
  • 陀螺仪:对其他位置修复略有改进,但耗电量很大。仅限 iPhone 4。

你给它一个你需要的以米为单位的精度(常数只是米的好名字),它将使用上述的组合,以尽可能快的修复和尽可能低的功耗为你提供该级别的精度。它使用的技术会从一个用户到另一个用户发生变化,并且会根据用户当时站在世界的哪个位置而改变。

于 2011-04-11T03:59:08.923 回答
2

The whole point of using extern rather than exposing what is actually happening is so that the under-gerwerkkins can change and your code doesn't have to worry about it to pick up the improvements.

That said, CLLocationAccuracy is typedef-ed to double, so I think it's fair to guess that kCLLocationAccuracyNearestTenMeters = 10.0, kCLLocationAccuracyHundredMeters = 100.0, etc. Best is likely either 0, 1 or kCLLocationAccuracyNearestTenMeters, and BestForNavigation is probably one they tossed it to help folks like TomTom, etc.

If you REALLY want to know, you can print out the values -- they're just doubles.

I do not believe that the number of satellites or power to wifi is altered based on your desired accuracy. The way I understand the algorithms, there is an approximation calculation that, the more times through the loop, the more accurate it gets. Hence, less-accurate just bails earlier.

But, again, the more important point is: it doesn't matter. Apple specifically doesn't describe what goes on behind the scenes because that's not part of the design. The design is: if you use kCLLocationAccuracyKilometer, you'll get an answer that's within a kilometer, etc. And Apple is now free to change how they arrive at that without you caring. This sort of isolation is a basic tenet of object oriented programming.

EDIT:

CORRECTION -- I'm just now watching the WWDC session on location (Session 115) and, at about 22:00 or so, he talks about how, when using BestForNavigation, this adds in some gyroscope correction (when available.) However, he warns that, while this is power & CPU intensive, and should be only used when necessary, as with turn-by-turn navigation.

I'm not sure how much more I can talk about this publically but, if you're a registered developer, you can get the sessions from iTunes-U.

(This is WWDC-2010, btw.)

于 2010-08-11T14:52:38.877 回答