首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iPhone开发-定位精度

iPhone开发-定位精度
EN

Stack Overflow用户
提问于 2010-04-16 13:28:50
回答 2查看 2.1K关注 0票数 0

我使用以下条件来确保我得到的位置有足够的精度,在我的例子中是kCLLocationAccuracyBest。但问题是,我仍然得到不准确的位置。

代码语言:javascript
复制
// 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时,在我真正得到一个准确的结果之前,我得到了不准确的结果。您使用哪些方法来获取准确/精确的位置信息?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-05-04 13:24:44

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

if(newLocation.horizontalAccuracy < manager.desiredAccuracy)

我使用kCLLocationAccuracyBest作为desiredAccuracy,它是一个负数。你不应该用它来做比较。

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

票数 0
EN

Stack Overflow用户

发布于 2010-04-16 13:49:28

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2650818

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档