Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added heading metadata functionality

commit 6b3148a8b874219e596c5bbfbcb281745c3471bf 1 parent 956e05f
@markpmiles markpmiles authored
View
2  GusUtils/NSMutableDictionary+ImageMetadata.h
@@ -45,7 +45,9 @@
- (void)setKeywords:(NSString*)keywords;
- (void)setImageOrientarion:(UIImageOrientation)orientation;
- (void)setDigitalZoom:(CGFloat)zoom;
+- (void)setHeading:(CLHeading*)heading;
@property (nonatomic, assign) CLLocation *location;
+@property (nonatomic, assign) CLLocationDirection trueHeading;
@end
View
30 GusUtils/NSMutableDictionary+ImageMetadata.m
@@ -20,6 +20,8 @@ @implementation FIX_CATEGORY_BUG_ImageMetadataCategory @end
@implementation NSMutableDictionary (ImageMetadataCategory)
+@dynamic trueHeading;
+
- (id)initWithImageSampleBuffer:(CMSampleBufferRef) imageDataSampleBuffer {
// Dictionary of metadata is here
@@ -119,6 +121,24 @@ - (void)setLocation:(CLLocation *)location {
}
}
+// Set heading while preserving location metadata, if it exists.
+- (void)setHeading:(CLHeading *)locatioHeading {
+
+ if (locatioHeading) {
+
+ CLLocationDirection trueDirection = locatioHeading.trueHeading;
+ NSMutableDictionary *locDict = [[NSMutableDictionary alloc] init];
+ if ([self objectForKey:(NSString*)kCGImagePropertyGPSDictionary]) {
+ [locDict addEntriesFromDictionary:[self objectForKey:(NSString*)kCGImagePropertyGPSDictionary]];
+ }
+ [locDict setObject:@"T" forKey:(NSString*)kCGImagePropertyGPSImgDirectionRef];
+ [locDict setObject:[NSNumber numberWithFloat:trueDirection] forKey:(NSString*)kCGImagePropertyGPSImgDirection];
+
+ [self setObject:locDict forKey:(NSString*)kCGImagePropertyGPSDictionary];
+ [locDict release];
+ }
+}
+
- (CLLocation*)location {
NSDictionary *locDict = [self objectForKey:(NSString*)kCGImagePropertyGPSDictionary];
if (locDict) {
@@ -140,6 +160,16 @@ - (CLLocation*)location {
return nil;
}
+- (CLLocationDirection)trueHeading {
+ NSDictionary *locDict = [self objectForKey:(NSString*)kCGImagePropertyGPSDictionary];
+ CLLocationDirection heading = 0;
+ if (locDict) {
+ heading = [[locDict objectForKey:(NSString*)kCGImagePropertyGPSImgDirection] doubleValue];
+ }
+
+ return heading;
+}
+
- (NSMutableDictionary *)dictionaryForKey:(CFStringRef)key {
NSDictionary *dict = [self objectForKey:(NSString*)key];
NSMutableDictionary *mutableDict;
Please sign in to comment.
Something went wrong with that request. Please try again.