2010-05-20 62 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