Class: CLLocation

Inherits:
NSObject show all

Overview

A CLLocation object represents the location data generated by a CLLocationManager object. This object incorporates the geographical coordinates and altitude of the device’s location along with values indicating the accuracy of the measurements and when those measurements were made. In iOS, this class also reports information about the speed and heading in which the device is moving.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- (CLLocationDistance) altitude (readonly)

The altitude measured in meters. (read-only) Positive values indicate altitudes above sea level. Negative values indicate altitudes below sea level.

Returns:

  • (CLLocationDistance)

- (CLLocationCoordinate2D) coordinate (readonly)

The geographical coordinate information. (read-only) When running in the simulator, Core Location assigns a fixed set of coordinate values to this property. You must run your application on an iOS-based device to get real location values.

- (CLLocationDirection) course (readonly)

The direction in which the device is traveling. Course values are measured in degrees starting at due north and continuing clockwise around the compass. Thus, north is 0 degrees, east is 90 degrees, south is 180 degrees, and so on. Course values may not be available on all devices. A negative value indicates that the direction is invalid.

Returns:

  • (CLLocationDirection)

- (CLLocationAccuracy) horizontalAccuracy (readonly)

The radius of uncertainty for the location, measured in meters. (read-only) The location’s latitude and longitude identify the center of the circle, and this value indicates the radius of that circle. A negative value indicates that the location’s latitude and longitude are invalid.

Returns:

  • (CLLocationAccuracy)

- (CLLocationSpeed) speed (readonly)

The instantaneous speed of the device in meters per second. This value reflects the instantaneous speed of the device in the direction of its current heading. A negative value indicates an invalid speed. Because the actual speed can change many times between the delivery of subsequent location events, you should use this property for informational purposes only.

Returns:

  • (CLLocationSpeed)

- (NSDate) timestamp (readonly)

The time at which this location was determined. (read-only)

Returns:

- (CLLocationAccuracy) verticalAccuracy (readonly)

The accuracy of the altitude value in meters. (read-only) The value in the altitude property could be plus or minus the value indicated by this property. A negative value indicates that the altitude value is invalid.Determining the vertical accuracy requires a device with GPS capabilities. Thus, on some earlier iOS-based devices, this property always contains a negative value.

Returns:

  • (CLLocationAccuracy)

Instance Method Details

- (String) description

Returns the location data in a formatted text string. The returned string is intended for display purposes only.

Returns:

  • (String)

    A string of the form “, > +/- m (speed kph / heading ) @ ”, where , , , , and are formatted floating point numbers and is a formatted date string that includes date, time, and time zone information.

- (CLLocationDistance) distanceFromLocation(location)

Returns the distance (in meters) from the receiver’s location to the specified location. This method measures the distance between the two locations by tracing a line between them that follows the curvature of the Earth. The resulting arc is a smooth curve and does not take into account specific altitude changes between the two locations.

Parameters:

  • location (const CLLocation)

    The other location.

Returns:

  • (CLLocationDistance)

    The distance (in meters) between the two locations.

- (Object) initWithCoordinate(coordinate, altitude:altitude, horizontalAccuracy:hAccuracy, verticalAccuracy:vAccuracy, course:course, speed:speed, timestamp:timestamp)

Initializes and returns a location object with the specified coordinate and course information. Typically, you acquire location objects from the location service, but you can use this method to create new location objects for other uses in your application.

Parameters:

  • coordinate (CLLocationCoordinate2D)

    A coordinate structure containing the latitude and longitude values.

  • altitude (CLLocationDistance)

    The altitude value for the location.

  • hAccuracy (CLLocationAccuracy)

    The accuracy of the coordinate value. Specifying a negative number indicates that the coordinate value is invalid.

  • vAccuracy (CLLocationAccuracy)

    The accuracy of the altitude value. Specifying a negative number indicates that the altitude value is invalid.

  • course (CLLocationDirection)

    The direction of travel for the location.

  • speed (CLLocationSpeed)

    The current speed associated with this location.

  • timestamp (NSDate)

    The time to associate with the location object. Typically, you would set this to the current time.

Returns:

  • (Object)

    A location object initialized with the specified information.

- (Object) initWithCoordinate(coordinate, altitude:altitude, horizontalAccuracy:hAccuracy, verticalAccuracy:vAccuracy, timestamp:timestamp)

Initializes and returns a location object with the specified coordinate information. Typically, you acquire location objects from the location service, but you can use this method to create new location objects for other uses in your application.

Parameters:

  • coordinate (CLLocationCoordinate2D)

    A coordinate structure containing the latitude and longitude values.

  • altitude (CLLocationDistance)

    The altitude value for the location.

  • hAccuracy (CLLocationAccuracy)

    The accuracy of the coordinate value. Specifying a negative number indicates that the coordinate value is invalid.

  • vAccuracy (CLLocationAccuracy)

    The accuracy of the altitude value. Specifying a negative number indicates that the altitude value is invalid.

  • timestamp (NSDate)

    The time to associate with the location object. Typically, you would set this to the current time.

Returns:

  • (Object)

    A location object initialized with the specified information.

- (Object) initWithLatitude(latitude, longitude:longitude)

Initializes and returns a location object with the specified latitude and longitude. Typically, you acquire location objects from the location service, but you can use this method to create new location objects for other uses in your application. When using this method, the other properties of the object are initialized to appropriate values. In particular, the altitude and horizontalAccuracy properties are set to 0, the verticalAccuracy property is set to -1 to indicate that the altitude value is invalid, and the timestamp property is set to the time at which the instance was initialized.

Parameters:

  • latitude (CLLocationDegrees)

    The latitude of the coordinate point.

  • longitude (CLLocationDegrees)

    The longitude of the coordinate point.

Returns:

  • (Object)

    A location object initialized with the specified coordinate point.