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.
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
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
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
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
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
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.
Generated with the Darkfish Rdoc Generator 1.1.6.