CLLocation Category for Calculating Bearing w/ Haversine function

Your code seems fine to me. Nothing wrong with the calculous. You don’t specify how far off your results are, but you might try tweaking your radian/degrees converters to this: double DegreesToRadians(double degrees) {return degrees * M_PI / 180.0;}; double RadiansToDegrees(double radians) {return radians * 180.0/M_PI;}; If you are getting negative bearings, add 2*M_PI to … Read more

How to store CLLocation using Core Data (iPhone)?

What you’re doing is fine. You should save the latitude and longitude as doubles in Core Data. When you need to get the information again, get the doubles back from Core Data and construct a CLLocationCoordinate2D struct with a function like CLLocationCoordinate2DMake. There’s no built in way to store a location, so storing the latitude … Read more

didUpdateLocations not called

Furthermore in iOS8 you must have two extra things: Add a key to your Info.plist and request authorization from the location manager asking it to start. NSLocationWhenInUseUsageDescription NSLocationAlwaysUsageDescription You need to request authorization for the corresponding location method. [self.locationManager requestWhenInUseAuthorization] [self.locationManager requestAlwaysAuthorization] Code example: self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; // Check for … Read more

What do horizontalAccuracy and verticalAccuracy of a CLLocation refer to?

The -1 for verticalAccuracy indicates that the altitude in the CLLocation is not valid. You only get altitude with a 3D GPS position. The 1414 for horizontalAccuracy indicates that the horizontal (lat/lon) position could be up to 1414m off (this is just an estimated error). This is probably a location determined by cell tower triangulation … Read more

How can I compare CLLocationCoordinate2D

Either the generic approach for comparing two instances of any given struct type: memcmp(&cllc2d1, &second_cllc2d, sizeof(CLLocationCoordinate2D)) or cllc2d1.latitude == cllc2d2.latitude && cllc2d1.longitude == cllc2d2.longitude should work, if you really want to be sure they’re exactly equal. However, given that latitude and longitude are defined as doubles, you might really want to do a “close enough” … Read more