2010-05-20 59 views
1

我在散步期间记录了gps点数。下面显示每5秒钟保存一次坐标的功能。 我做了几个测试,但我不能得到我想要的正确的准确性。 (当测试天空时,谷歌地图上的测试也显示GPS信号良好)。iPhone Gps日志记录不准确

这里是代码:

-(void)viewDidAppear:(BOOL)animated{ 

if (self.locationManager == nil){ 

    self.locationManager = [[[CLLocationManager alloc] init] autorelease]; 
    locationManager.delegate = self; 
    // only notify under 100 m accuracy 
    locationManager.distanceFilter = 100.0f; 
    locationManager.desiredAccuracy= kCLLocationAccuracyBest; 
    [locationManager startUpdatingLocation]; 
} 
} 

- start logging 

[NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(getData) userInfo:nil repeats:YES]; 
</code> 

<code> 
-(void)getData{ 

int distance; 

// re-use location. 
if ([ [NSString stringWithFormat:@"%1.2f",previousLat] isEqualToString:@"0.00"]){ 
    // if previous location is not available, do nothing 
    distance = 0; 
}else{ 
    CLLocation *loc1 = [[CLLocation alloc] initWithLatitude:previousLat longitude:previousLong]; 
    CLLocation *loc2 = [[CLLocation alloc] initWithLatitude:latGlobal longitude:longGlobal]; 

    distance = [loc1 getDistanceFrom: loc2]; 
} 

// overwrite latGlobal with new variable 
previousLat = latGlobal; 
previousLong = longGlobal; 


// store location and save data to database 
// this part goes ok 
} 

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 

// track the time to get a new gps result (for gps indicator orb) 
lastPointTimestamp = [newLocation.timestamp copy]; 

// test that the horizontal accuracy does not indicate an invalid measurement 
    if (newLocation.horizontalAccuracy < 0) return; 

// test the age of the location measurement to determine if the measurement is cached 
    // don't rely on cached measurements 
    NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow]; 
    if (locationAge > 5.0) return; 

latGlobal = fabs(newLocation.coordinate.latitude); 
longGlobal= fabs(newLocation.coordinate.longitude); 
} 

我已经采取了积结果的截图(步行需30分钟),什么我'尝试acomplish一个例子: http://www.flickr.com/photos/[email protected]/4623969014/

我真的希望有人能让我走向正确的方向。

回答

1

看着你的情节 - 这正是我在我正在工作的应用中看到的。

看着你的代码。每当位置更新时,locationManager调用didUpdateToLocationFromLocation - 以5s的间隔进行轮询将在相同的位置为您提供很多分数。 (但不相关的问题)

此外,我认为你是渗出了lastPointTimestamp(的问题不相关)

右键 - 周围的跳跃 - 你可以看看点的精度:你这样做无论如何在locationManager,但只检查< 0.跳跃点上是否有水平精度的模式?对于其他点或一个特定值(由切换到手机塔三角测量引起),精度数字可能会更差。

最后,您可能需要实施过滤。卡尔曼滤波器是最重要的方法,但我正在考虑将低通滤波器与一些基本物理结合起来(步行,骑自行车,跑步,驾驶等最大加速度),以改善结果。

乐于合作。

+0

嗨Andiih,谢谢你的建议。也许反其道而行更好。根据准确度存储最佳的“didUpdateLocation”结果,并且每5秒最多保存1个点。过滤,例如基于速度的最大距离,确实会产生更清晰的结果,但是对我而言,这是一步。当我测试时,我会发布我的发现和新代码。谢谢 – Martijn 2010-05-20 11:34:07

+0

今天我花了一些时间看这个。我注意到,糟糕的“jumppoint”(对你而言)始终是同一点。我想知道你是否可以过高的相对速度和重复访问同一点。 – Andiih 2010-05-20 19:20:27

+0

这将变成讨论。如果你想通过这个联系我,请发邮件给我,并告诉我,我正在取得一些进展,但是在我们开展工作时共享数据集等是件好事:SO是针对问题和答案而不是讨论。 – Andiih 2010-05-21 12:28:13