CLLocationのアップデートを取得するたびにLatとLongを記録する非常に基本的なiPhoneアプリケーションを作成しました。これらの新しいポジションをGPXファイルに保存します。これをルートオーバーレイとしてGoogleマップにロードできます。ズームアウトすると、ルートはかなり正確に見えますが、ズームインすると、私のルートは実際に運転していた道路の横に表示されることがよくあります。これの典型的な例の1つは、私が交差点に近づくにつれて位置の更新が起こり、次に角を曲がった後に再び行われるということです。 2つのポイントが接続されていると、私は道を離れるように見えます。この精度を向上させる方法があるのか、ルートを実際の道路にスナップするのか誰にでも分かりますか?次のようにiPhoneの正確な位置コアの位置と長さ
更新のための私のコードは次のとおりです。私の問題を見ているため
- (void)locationUpdate:(CLLocation *)location
{
////////////////////////////////////////////////////////
//Write to File
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *testFile = [documentsDirectory stringByAppendingPathComponent:@"routeplots.gpx"];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:testFile];
if(fileExists) {
// get a handle to the file
NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:testFile];
// move to the end of the file
[fileHandle seekToEndOfFile];
NSString *data =[NSString stringWithFormat:@"\n<trkpt lat='%f' lon='%f'><name>%f</name></trkpt>", location.coordinate.latitude , location.coordinate.longitude , [location speed]];
// move to the end of the file
[fileHandle seekToEndOfFile];
// convert the string to an NSData object
NSData *textData = [data dataUsingEncoding:NSUTF8StringEncoding];
// write the data to the end of the file
[fileHandle writeData:textData];
// clean up
[fileHandle closeFile];
}
}
おかげで、ジェームズ
[this](http://stackoverflow.com/questions/1081219/optimizing-cllocationmanager-corelocation-to-retrieve-data-points-faster-on-the) –
desireAccuracyとdistanceFilterを設定しましたか? ?これを試していない場合: locationManager.desiredAccuracy = kCLLocationAccuracyBest; locationManager.distanceFilter = kCLDistanceFilterNone; – peko