Class: CLLocationCoordinate2D

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoa/sugarcube-corelocation/core_location.rb

Overview

denver = CLLocationCoordinate2D.new(39.764032,-104.963112) cincinnati = CLLocationCoordinate2D.new(39.267024,-84.251736) denver.distance_to(cincinnati).in_miles denver.delta_miles(1101.6, -32.556) # go east 1,101.6 miles, and south 32.556 miles

Instance Method Summary collapse

Instance Method Details

#delta_kilometers(dx, dy) ⇒ Object



12
13
14
15
# File 'lib/cocoa/sugarcube-corelocation/core_location.rb', line 12

def delta_kilometers(dx, dy)
  earth_radius = 6378.137
  _sugarcube_delta(dx, dy, earth_radius)
end

#delta_miles(dx, dy) ⇒ Object



7
8
9
10
# File 'lib/cocoa/sugarcube-corelocation/core_location.rb', line 7

def delta_miles(dx, dy)
  earth_radius = 3963.19
  _sugarcube_delta(dx, dy, earth_radius)
end

#distance_to(cl_location_2d) ⇒ Object



32
33
34
35
36
# File 'lib/cocoa/sugarcube-corelocation/core_location.rb', line 32

def distance_to(cl_location_2d)
  my_location = CLLocation.alloc.initWithLatitude(self.latitude, longitude:self.longitude)
  other_location = CLLocation.alloc.initWithLatitude(cl_location_2d.latitude, longitude:cl_location_2d.longitude)
  my_location.distanceFromLocation(other_location)
end