iphone - Saving Geotag info with photo on iOS4.1 -


i having major issues trying save photo camera roll geotag info on ios4.1. using following alassetslibrary api:

- (void)writeimagedatatosavedphotosalbum:(nsdata *)imagedata                                  metadata:(nsdictionary *)metadata                           completionblock:(alassetslibrarywriteimagecompletionblock)completionblock 

i have gps coordinates wish save photo input. unfortunately, there no documentation or sample code describes how form metadata nsdictionary encapsulates gps coordinates. can post sample code known work ?

i have tried using iphone exif library save geo info in imagedata rather using metadata, unfortunately iphone exif library crashing. appreciated.

here code copy available information cllocation object proper format gps metadata dictionary:

- (nsdictionary *)getgpsdictionaryforlocation:(cllocation *)location {     nsmutabledictionary *gps = [nsmutabledictionary dictionary];      // gps tag version     [gps setobject:@"2.2.0.0" forkey:(nsstring *)kcgimagepropertygpsversion];      // time , date must provided strings, not nsdate object     nsdateformatter *formatter = [[nsdateformatter alloc] init];     [formatter setdateformat:@"hh:mm:ss.ssssss"];     [formatter settimezone:[nstimezone timezonewithabbreviation:@"utc"]];     [gps setobject:[formatter stringfromdate:location.timestamp] forkey:(nsstring *)kcgimagepropertygpstimestamp];     [formatter setdateformat:@"yyyy:mm:dd"];     [gps setobject:[formatter stringfromdate:location.timestamp] forkey:(nsstring *)kcgimagepropertygpsdatestamp];     [formatter release];      // latitude     cgfloat latitude = location.coordinate.latitude;     if (latitude < 0) {         latitude = -latitude;         [gps setobject:@"s" forkey:(nsstring *)kcgimagepropertygpslatituderef];     } else {         [gps setobject:@"n" forkey:(nsstring *)kcgimagepropertygpslatituderef];     }     [gps setobject:[nsnumber numberwithfloat:latitude] forkey:(nsstring *)kcgimagepropertygpslatitude];      // longitude     cgfloat longitude = location.coordinate.longitude;     if (longitude < 0) {         longitude = -longitude;         [gps setobject:@"w" forkey:(nsstring *)kcgimagepropertygpslongituderef];     } else {         [gps setobject:@"e" forkey:(nsstring *)kcgimagepropertygpslongituderef];     }     [gps setobject:[nsnumber numberwithfloat:longitude] forkey:(nsstring *)kcgimagepropertygpslongitude];      // altitude     cgfloat altitude = location.altitude;     if (!isnan(altitude)){         if (altitude < 0) {             altitude = -altitude;             [gps setobject:@"1" forkey:(nsstring *)kcgimagepropertygpsaltituderef];         } else {             [gps setobject:@"0" forkey:(nsstring *)kcgimagepropertygpsaltituderef];         }         [gps setobject:[nsnumber numberwithfloat:altitude] forkey:(nsstring *)kcgimagepropertygpsaltitude];     }      // speed, must converted m/s km/h     if (location.speed >= 0){         [gps setobject:@"k" forkey:(nsstring *)kcgimagepropertygpsspeedref];         [gps setobject:[nsnumber numberwithfloat:location.speed*3.6] forkey:(nsstring *)kcgimagepropertygpsspeed];     }      // heading     if (location.course >= 0){         [gps setobject:@"t" forkey:(nsstring *)kcgimagepropertygpstrackref];         [gps setobject:[nsnumber numberwithfloat:location.course] forkey:(nsstring *)kcgimagepropertygpstrack];     }      return gps; } 

assign dictionary returned method value kcgimagepropertygpsdictionary key in metadata dictionary pass writeimagedatatosavedphotosalbum:metadata:completionblock: or cgimagedestinationaddimage().


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -