【问题标题】:iPhone Development - Location AccuracyiPhone 开发 - 定位精度
【发布时间】:2010-04-16 05:28:49
【问题描述】:

我使用以下条件来确保我获得的位置具有足够的准确性,在我的情况下是 kCLLocationAccuracyBest。但问题是我的位置仍然不准确。

// Filter out nil locations
if(!newLocation)
    return;

// Make sure that the location returned has the desired accuracy
if(newLocation.horizontalAccuracy < manager.desiredAccuracy)
    return;

// Filter out points that are out of order    
if([newLocation.timestamp timeIntervalSinceDate:oldLocation.timestamp] < 0)
    return;

// Filter out points created before the manager was initialized
NSTimeInterval secondsSinceManagerStarted = [newLocation.timestamp timeIntervalSinceDate:locationManagerStartDate];
if(secondsSinceManagerStarted < 0)
    return;

// Also, make sure that the cached location was not returned by the CLLocationManager (it's current) - Check for 5 seconds difference
if([newLocation.timestamp timeIntervalSinceReferenceDate] < [[NSDate date] timeIntervalSinceReferenceDate] - 5)
    return;

当我激活 GPS 时,我在实际得到准确结果之前得到了不准确的结果。您使用什么方法来获取准确/精确的位置信息?

【问题讨论】:

    标签: iphone mkmapview cllocationmanager userlocation


    【解决方案1】:

    GPS 速度很慢,至少与用户的耐心相比,因此位置管理器会返回它所拥有的最佳值,直到它获得新的、有效的 GPS 读数。您可以让用户等待获得准确读数所需的时间,也可以像 google 地图那样提供某种增量反馈,用圆圈而不是点。

    【讨论】:

    • 实际上我显示的是蓝点和圆圈,但问题是我也在记录位置变化,所以前几个位置几乎总是不准确的。我怎样才能确保我现在收到的位置是最准确的!我想我已经在我的代码中放置了所有必要的条件,但不准确的位置仍然绕过我的代码。
    • newLocation.horizo​​ntalAccuracy 可以为负数。您可以根据实际的米数而不是 AccuracyBest 常数来检查它。
    • 啊,谢谢你的提示。由于 AccuracyBest 具有 -ve 值,因此不建议将其用于与 Horizo​​ntalAccuracy 进行比较。我想我还必须添加一些计时器或调度程序以使用最后一个已知位置...如果我没有获得所需的位置准确性,或者位置管理器已停止发送位置更新消息,因为用户已停止?我到处查看是否有人分享过这种逻辑,但没有人分享过。我想知道是否有更好的方法来处理这个问题。
    【解决方案2】:

    我得到不准确结果的主要原因是因为这种情况:

    if(newLocation.horizontalAccuracy &lt; manager.desiredAccuracy)

    我使用 kCLLocationAccuracyBest 作为所需的准确度,它是一个负数。你不应该用它来比较。

    解决方案: if(newLocation.horizontalAccuracy &lt; 10.0)

    【讨论】:

      猜你喜欢
      • 2011-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-29
      • 1970-01-01
      • 2011-03-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多