-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataPoint.m
59 lines (46 loc) · 1.61 KB
/
DataPoint.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// DataPoint.m
// Traffic Sense
//
// Created by Alex Pereira on 3/13/12.
// Copyright (c) 2012 UBC. All rights reserved.
//
#import "DataPoint.h"
@implementation DataPoint
@synthesize userID = _userID;
@synthesize speed = _speed;
@synthesize coordinate = _coordinate;
@synthesize transportMode = _transportMode;
@synthesize timeStamp = _timeStamp;
@synthesize title = _title;
@synthesize subtitle = _subtitle;
+ (DataPoint *)dataPointWithID:(NSString *)userID latitude:(double)lat longitude:(double)lng speed:(double)sp timeStamp:(NSString *)time transportMode:(NSString *)mode {
DataPoint *point = [[DataPoint alloc] init];
point.userID = userID;
point.coordinate = CLLocationCoordinate2DMake(lat, lng);
point.speed = sp;
point.timeStamp = time;
point.title = mode;
point.subtitle = [NSString stringWithFormat:@"%.f km/h", sp*3.6];
if ([mode isEqualToString:@"Still"])
point.transportMode = Still;
else if ([mode isEqualToString:@"Walk"])
point.transportMode = Walk;
else if ([mode isEqualToString:@"Run"])
point.transportMode = Run;
else if ([mode isEqualToString:@"Bike"])
point.transportMode = Bike;
else if ([mode isEqualToString:@"Bus"])
point.transportMode = Bus;
else if ([mode isEqualToString:@"Drive"])
point.transportMode = Drive;
return point;
}
- (void)printToConsole {
NSLog(@"UserID: %@", self.userID);
NSLog(@"Speed: %.3f", self.speed);
NSLog(@"Lat: %.3f", self.coordinate.latitude);
NSLog(@"Long: %.3f", self.coordinate.longitude);
NSLog(@"Time: %@", self.timeStamp);
}
@end