I have written a very basic iPhone app which records my Lat and Long everytime I get a CLLocation update. It stores these new positions in a GPX file, which I can then load up into a google map as a route overlay. When zoomed out the route looks fairly accurate, but when zoomed in, my route appears often to the side of the road I was actually driving on. One typical example of this might be that the location update happens as I approach a junction, and then again after I have turned the corner. When the two points are connected it appears that I have driven off road. Does anyone know if there is a way of improving this accuracy, or snapping my routes to the actual roads themselves?
My code for the update is as follows:
- (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];
}
}
Thanks for looking at my issue, James