Created
October 12, 2011 22:17
-
-
Save sbrocket/1282818 to your computer and use it in GitHub Desktop.
updateLocations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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