Skip to content
Some extensions to CLLocation providing some coordinate calculations
Objective-C Perl
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
CLLocation+LocationExtensions.h
CLLocation+LocationExtensions.m
LICENSE
README.md

README.md

About

Included are two straightforward methods on CLLocation that provide some convenience calculations that I needed on a recent project.

-locationAtDistance:andBearing:

The first allows you to calculate a new point at a specified distance and bearing from an existing point. Usage is straightforward:

#import <CoreLocation/CoreLocation.h>
#import "CLLocation+LocationExtensions.h"

CLLocation* startPoint = [[CLLocation alloc] initWithLatitude:39.90657 longitude:-75.16656];
CLLocation* newPoint = [startPoint locationAtDistance:300 andBearing:180];
NSLog(@"New point: %@", newPoint); // new point is at 39.90387204, -75.16656

-bearingTo:

The second finds the bearing between two existing points.

#import <CoreLocation/CoreLocation.h>
#import "CLLocation+LocationExtensions.h"

CLLocation* startPoint = [[CLLocation alloc] initWithLatitude:39.90657 longitude:-75.16656];
CLLocation* endPoint = [[CLLocation alloc] initWithLatitude:39.90387204 longitude:-75.16656];
CLLocationDegrees bearing = [startPoint bearingTo:endPoint];
NSLog(@"Bearing: %f", bearing); // bearing is 180

License

Simplified BSD License. See the LICENSE file for details.

You can’t perform that action at this time.