CLLocationManager Look up all the Coordinate Info

April 7, 2009 § Leave a comment

There is easy way to print out all the details related to CCLocation object on NSLog within Xcode console and not showing to the user. If you test it on simulator, you would get the same coordinate that is based on Apple headquarter Cupertino location.

Coordinates: +37.331689, -122.030731

Altitude: 0.000000

Updated: 2009-04-06 20:53:05 -0700

The description gives the comprehensive details with latitude, longitude, accuracy in meter, speed and course, date and time. It is the most useful object to give a quick glance of CLLocation of newLocation.

Description: <+37.33168900, -122.03073100> +/- 100.00m (speed -1.00 mps / course -1.00) @ 2009-04-06 20:53:05 -0700

  • oldLocation.coordinate.latitude
  • oldLocation.coordinate.longitude
  • newLocation.coordinate.latitude
  • newLocation.coordinate.longitude
  • newLocation.altitude
  • newLocation description
  • newLocation.timestamp
  • timeIntervalSinceNow
  • getDistanceFrom:startingPoint

– (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

NSLog(@”Old Coordinates: %+.6f, %+.6f\n”, oldLocation.coordinate.latitude, oldLocation.coordinate.longitude);
NSLog(@”New Coordinates: %+.6f, %+.6f\n”, newLocation.coordinate.latitude, newLocation.coordinate.longitude);
NSLog(@”Altitude: %.6f\n”, newLocation.altitude);
NSLog(@”Description: %@\n”, [newLocation description]);
NSLog(@”Updated: %@\n”, newLocation.timestamp);
NSDate *timestamp = newLocation.timestamp;
NSTimeInterval age = [timestamp timeIntervalSinceNow];
NSLog(@”Notification age: %.4f\n”, age);
NSLog(@”Distance: %+.6f”, [newLocation getDistanceFrom:startingPoint]);

}

Xcode console:

[Session started at 2009-04-06 20:53:00 -0700.]
2009-04-06 20:53:02.813 sample[19640:20b] Time elapsed: 0.009864
2009-04-06 20:53:05.864 sample[19640:20b] Old Coordinates: +37.331689, -122.030731
2009-04-06 20:53:05.871 sample[19640:20b] New Coordinates: +37.331689, -122.030731
2009-04-06 20:53:05.873 sample[19640:20b] Altitude: 0.000000
2009-04-06 20:53:05.874 sample[19640:20b] Description: <+37.33168900, -122.03073100> +/- 100.00m (speed -1.00 mps / course -1.00) @ 2009-04-06 20:53:05 -0700
2009-04-06 20:53:05.875 sample[19640:20b] Updated: 2009-04-06 20:53:05 -0700
2009-04-06 20:53:05.875 sample[19640:20b] Notification age: -0.0120
2009-04-06 20:53:05.876 sample[19640:20b] Distance: +0.000000

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading CLLocationManager Look up all the Coordinate Info at Web Builders.

meta

%d bloggers like this: