代码之家  ›  专栏  ›  技术社区  ›  Mustafa

iPhone开发-定位精度

  •  0
  • Mustafa  · 技术社区  · 16 年前

    // 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时,在我得到准确的结果之前,我得到了不准确的结果。你用什么方法获得准确的位置信息?

    2 回复  |  直到 16 年前
        1
  •  0
  •   drawnonward    16 年前

    GPS是慢的,至少与用户的耐心相比,所以位置管理器返回最好的,直到它得到一个新的,有效的GPS读数。你可以让用户等待多长时间才能得到准确的读数,或者像google地图那样,用一个圆而不是一个点来获得某种增量反馈。

        2
  •  0
  •   Mustafa    16 年前

    我得到不准确结果的主要原因是:

    if(newLocation.horizontalAccuracy < manager.desiredAccuracy)

    kCLLocationAccuracyBest 准确度要求是负数。你不应该用它来比较。

    解决方案: if(newLocation.horizontalAccuracy < 10.0)