Skip to content

Instantly share code, notes, and snippets.

@sbrocket
Created October 12, 2011 22:17
Show Gist options
  • Save sbrocket/1282818 to your computer and use it in GitHub Desktop.
Save sbrocket/1282818 to your computer and use it in GitHub Desktop.
updateLocations
- (void)updateLocations {
NSDictionary *metadata = viewControllerDelegate.stillPhotoMetadata;
[self updateLocationsWithMetadata:metadata];
}
- (void)updateLocationsWithMetadata:(NSDictionary *)metadata {
CLLocation *gpsLoc;
if (metadata != nil) {
NSString *latRef = [((NSDictionary *)[metadata objectForKey:@"{GPS}"]) valueForKey:@"LatitudeRef"];
NSString *lonRef = [((NSDictionary *)[metadata objectForKey:@"{GPS}"]) valueForKey:@"LongitudeRef"];
int latDirection = ([latRef isEqualToString:@"S"]) ? -1 : 1;
int lonDirection = ([lonRef isEqualToString:@"W"]) ? -1 : 1;
NSNumber *photoLat = [((NSDictionary *)[metadata objectForKey:@"{GPS}"]) valueForKey:@"Latitude"];
NSNumber *photoLon = [((NSDictionary *)[metadata objectForKey:@"{GPS}"]) valueForKey:@"Longitude"];
gpsLoc = [[[CLLocation alloc] initWithLatitude:[photoLat floatValue]*latDirection longitude:[photoLon floatValue]*lonDirection] autorelease];
} else {
gpsLoc = ((Panda_MobileAppDelegate *)[[UIApplication sharedApplication] delegate]).currentLocation;
}
[HPAPI cancel:_requestUpdateLocation release:true];
_requestUpdateLocation = [[[HPAPI sharedInstance] loadLocations:gpsLoc target:self onFinish:@selector(refreshLocationData:) onFail:@selector(onASIError:)] retain];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment