Permalink
Browse files

Modified Extension files to add heartRate, cadence and Distance exten…

…sions to the track point extensions.
  • Loading branch information...
1 parent bcafbd2 commit 9c3b091a541882a69badeb6080bf076bbf7b5c99 @jmachuca77 committed Apr 10, 2013
Showing with 55 additions and 1 deletion.
  1. +4 −0 GPX/GPXExtensions.h
  2. +51 −1 GPX/GPXExtensions.m
View
@@ -13,4 +13,8 @@
*/
@interface GPXExtensions : GPXElement
+@property (nonatomic, assign) NSNumber *heartRate;
+@property (nonatomic, assign) NSNumber *cadence;
+@property (nonatomic, assign) NSNumber *distance;
+
@end
View
@@ -9,14 +9,61 @@
#import "GPXExtensions.h"
#import "GPXElementSubclass.h"
+
+@interface GPXExtensions()
+@property (nonatomic, strong) NSString *heartRateString;
+@property (nonatomic, strong) NSString *cadenceString;
+@property (nonatomic, strong) NSString *distanceString;
+@end
+
+
@implementation GPXExtensions
+@synthesize heartRate = _heartRate;
+@synthesize cadence = _cadence;
+@synthesize distance = _distance;
+
+
+- (NSNumber *)heartRate
+{
+ return [NSNumber numberWithFloat:[GPXType decimal:_heartRateString]];
+}
+
+- (void)setHeartRate:(NSNumber *)heartRate
+{
+ _heartRateString = [NSString stringWithFormat:@"%d", [heartRate integerValue]];
+}
+
+- (NSNumber *)cadence
+{
+ return [NSNumber numberWithFloat:[GPXType decimal:_cadenceString]];
+}
+
+- (void)setCadence:(NSNumber *)cadence
+{
+ _cadenceString = [NSString stringWithFormat:@"%d", [cadence integerValue]];
+}
+
+- (NSNumber *)distance
+{
+ return [NSNumber numberWithFloat:[GPXType decimal:_distanceString]];
+}
+
+- (void)setDistance:(NSNumber *)distance
+{
+ _distanceString = [GPXType valueForDecimal:[distance floatValue]];
+}
+
+
#pragma mark - Instance
- (id)initWithXMLElement:(GPXXMLElement *)element parent:(GPXElement *)parent
{
self = [super initWithXMLElement:element parent:parent];
if (self) {
+ _heartRateString = [self textForSingleChildElementNamed:@"gpxdata:hr" xmlElement:element];
+ _cadenceString = [self textForSingleChildElementNamed:@"gpxdata:cadence" xmlElement:element];
+ _distanceString = [self textForSingleChildElementNamed:@"gpxdata:distance" xmlElement:element];
}
return self;
}
@@ -39,7 +86,10 @@ + (NSString *)tagName
- (void)addChildTagToGpx:(NSMutableString *)gpx indentationLevel:(NSInteger)indentationLevel
{
[super addChildTagToGpx:gpx indentationLevel:indentationLevel];
-
+ [self gpx:gpx addPropertyForValue:_heartRateString tagName:@"gpxdata:hr" indentationLevel:indentationLevel];
+ [self gpx:gpx addPropertyForValue:_cadenceString tagName:@"gpxdata:cadence" indentationLevel:indentationLevel];
+ [self gpx:gpx addPropertyForValue:_distanceString tagName:@"gpxdata:distance" indentationLevel:indentationLevel];
+
}
@end

0 comments on commit 9c3b091

Please sign in to comment.