diff --git a/phoneClients/ios/GpsTracker.xcodeproj/project.pbxproj b/phoneClients/ios/GpsTracker.xcodeproj/project.pbxproj index 39966c8..36c49f6 100644 --- a/phoneClients/ios/GpsTracker.xcodeproj/project.pbxproj +++ b/phoneClients/ios/GpsTracker.xcodeproj/project.pbxproj @@ -298,6 +298,7 @@ CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -337,6 +338,7 @@ CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; diff --git a/phoneClients/ios/GpsTracker/Base.lproj/Main.storyboard b/phoneClients/ios/GpsTracker/Base.lproj/Main.storyboard index 0ce4e3d..eaf5ea6 100644 --- a/phoneClients/ios/GpsTracker/Base.lproj/Main.storyboard +++ b/phoneClients/ios/GpsTracker/Base.lproj/Main.storyboard @@ -1,21 +1,86 @@ - + - + + - + + + + + - + + + + + + + + + + + + + + + + + + + + + + diff --git a/phoneClients/ios/GpsTracker/WSAppDelegate.h b/phoneClients/ios/GpsTracker/WSAppDelegate.h index edc8b55..c8af465 100644 --- a/phoneClients/ios/GpsTracker/WSAppDelegate.h +++ b/phoneClients/ios/GpsTracker/WSAppDelegate.h @@ -7,9 +7,8 @@ // #import -#import -@interface WSAppDelegate : UIResponder +@interface WSAppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; diff --git a/phoneClients/ios/GpsTracker/WSViewController.m b/phoneClients/ios/GpsTracker/WSViewController.m index 4d89b27..1264914 100644 --- a/phoneClients/ios/GpsTracker/WSViewController.m +++ b/phoneClients/ios/GpsTracker/WSViewController.m @@ -7,23 +7,109 @@ // #import "WSViewController.h" +#import -@interface WSViewController () - +@interface WSViewController () +@property (weak, nonatomic) IBOutlet UILabel *latitudeLabel; +@property (weak, nonatomic) IBOutlet UILabel *longitudeLabel; +@property (weak, nonatomic) IBOutlet UILabel *accuracyLabel; +@property (weak, nonatomic) IBOutlet UILabel *timestampLabel; +@property (weak, nonatomic) IBOutlet UIButton *trackingButton; @end @implementation WSViewController +{ + CLLocationManager *locationManager; + CLLocation *previousLocation; + int totalDistanceInMeters; + bool currentlyTracking; + bool firstTimeGettingPosition; +} - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. + currentlyTracking = NO; + +} + +- (void)startTracking +{ + NSLog(@"start tracking "); + locationManager = [[CLLocationManager alloc] init]; + locationManager.desiredAccuracy = kCLLocationAccuracyBest; + locationManager.delegate = self; + // locationManager.activityType = CLActivityTypeAutomotiveNavigation; + locationManager.distanceFilter = 0; // meters + + totalDistanceInMeters = 0; + firstTimeGettingPosition = YES; + + [locationManager startUpdatingLocation]; +} + +- (void)stopTracking +{ + NSLog(@"stop tracking"); + [locationManager stopUpdatingLocation]; + locationManager = nil; +} +- (IBAction)handleTrackingButton:(id)sender { + if (currentlyTracking) { + [self stopTracking]; + currentlyTracking = NO; + [self.trackingButton setTitle:@"start tracking" forState:UIControlStateNormal]; + } else { + [self startTracking]; + currentlyTracking = YES; + [self.trackingButton setTitle:@"stop tracking" forState:UIControlStateNormal]; + } +} + +- (void)reduceTrackingAccuracy +{ + locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers; + locationManager.distanceFilter = 9999; +} + +- (void)increaseTrackingAccuracy +{ + locationManager.desiredAccuracy = kCLLocationAccuracyBest; + locationManager.distanceFilter = 0; +} + +- (void)locationManager:(CLLocationManager *)manager + + + :(NSArray *)locations +{ + CLLocation *location = [locations lastObject]; + + if (location.horizontalAccuracy < 100.0) { + + } + + NSLog(@"lat/lng: %f/%f accuracy: %f", location.coordinate.latitude, location.coordinate.longitude, location.horizontalAccuracy); + + + if (firstTimeGettingPosition) { + firstTimeGettingPosition = NO; + } else { + CLLocationDistance distance = [location distanceFromLocation:previousLocation]; + totalDistanceInMeters += distance; + } + + previousLocation = location; +} + +- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error +{ + NSLog(@"locationManager error: %@", [error description]); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. } @end