Geokit::Mappable

Contains class and instance methods providing distance calcuation services. This module is meant to be mixed into classes containing lat and lng attributes where distance calculation is desired.

At present, two forms of distance calculations are provided:

Distance units supported are :miles, :kms, and :nms.

Constants

PI_DIV_RAD
(Not documented)
KMS_PER_MILE
(Not documented)
NMS_PER_MILE
(Not documented)
EARTH_RADIUS_IN_MILES
(Not documented)
EARTH_RADIUS_IN_KMS
(Not documented)
EARTH_RADIUS_IN_NMS
(Not documented)
MILES_PER_LATITUDE_DEGREE
(Not documented)
KMS_PER_LATITUDE_DEGREE
(Not documented)
NMS_PER_LATITUDE_DEGREE
(Not documented)
LATITUDE_DEGREES
(Not documented)

Public Instance Methods

distance_from(other, options={}) click to toggle source

Alias for distance_to

distance_to(other, options={}) click to toggle source

Returns the distance from another point. The other point parameter is required to have lat and lng attributes. Valid options are: :units - valid values are :miles, :kms, :or :nms (:miles is the default) :formula - valid values are :flat or :sphere (:sphere is the default)

     # File /Users/andre/projects/rails/geokit/lib/geokit/mappable.rb, line 177
177:     def distance_to(other, options={})
178:       self.class.distance_between(self, other, options)
179:     end
Also aliased as: distance_from
endpoint(heading,distance,options={}) click to toggle source

Returns the endpoint, given a heading (in degrees) and distance. Valid option: :units - valid values are :miles, :kms, or :nms (:miles is the default)

     # File /Users/andre/projects/rails/geokit/lib/geokit/mappable.rb, line 197
197:     def endpoint(heading,distance,options={})
198:       self.class.endpoint(self,heading,distance,options)  
199:     end
heading_from(other) click to toggle source

Returns heading in degrees (0 is north, 90 is east, 180 is south, etc) FROM the given point. The given point can be a LatLng or a string to be Geocoded

     # File /Users/andre/projects/rails/geokit/lib/geokit/mappable.rb, line 190
190:     def heading_from(other)
191:       self.class.heading_between(other,self)
192:     end
heading_to(other) click to toggle source

Returns heading in degrees (0 is north, 90 is east, 180 is south, etc) to the given point. The given point can be a LatLng or a string to be Geocoded

     # File /Users/andre/projects/rails/geokit/lib/geokit/mappable.rb, line 184
184:     def heading_to(other)
185:       self.class.heading_between(self,other)
186:     end
midpoint_to(other, options={}) click to toggle source

Returns the midpoint, given another point on the map. Valid option: :units - valid values are :miles, :kms, or :nms (:miles is the default)

     # File /Users/andre/projects/rails/geokit/lib/geokit/mappable.rb, line 204
204:     def midpoint_to(other, options={})
205:       self.class.midpoint_between(self,other,options)
206:     end
to_lat_lng() click to toggle source

Extracts a LatLng instance. Use with models that are acts_as_mappable

     # File /Users/andre/projects/rails/geokit/lib/geokit/mappable.rb, line 167
167:     def to_lat_lng
168:       return self if instance_of?(Geokit::LatLng) || instance_of?(Geokit::GeoLoc)
169:       return LatLng.new(send(self.class.lat_column_name),send(self.class.lng_column_name)) if self.class.respond_to?(:acts_as_mappable)
170:       nil
171:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.