Hello All,
· Distance calculations between two points on the earth. Calculate the distance in miles or KM, with all the trigonometry abstracted away by Geokit.
· ActiveRecord distance-based finders. For example, you can find all the points in your database within a 50-mile radius.
· Geocoding from multiple providers. It supports Google, Yahoo, Geocoder.us, Geonames, Geocoder.ca, and more. Geokit provides a uniform response structure from all of them. It also provides a fail-over mechanism, in case your input fails to geocode in one service.
· IP-based location lookup utilizing hostip.info. Provide an IP address, and get city name and latitude/longitude in return.
· A before_filter helper to geocode the user's location based on IP address, and retain the location in a cookie.
Find near latitude and longitude:
Store.find(:all, :origin =>[37.792,-122.393], :within=>10)Find near an address:
Store.find(:all, :origin=>'100 Spear st, San Francisco, CA', :within=>10)
Order by distance from the center of a zipcode:
Store.find(:all, :origin=>'94117', :within=>10, :order=>'distance asc')Combine distance conditions with regular conditions
Store.find(:all, :origin=>'94117', :within=>10, :conditions=>{:store_type=>'CAFE'})
Geocode an address:
include Geokit::Geocodersres=MultiGeocoder.geocode('100 Spear st, San Francisco, CA')
puts res.ll # ll=latitude,longitudeFind the address near a latitude/longitude (reverse geocoding):
include Geokit::Geocodersres=GoogleGeocoder.reverse_geocode([37.792821,-122.393992])puts res.full_address>> 36-98 Mission St, San Francisco, CA 94105, USA
Find distances, headings, endpoints, and midpoints:
distance=home.distance_from(work, :units=>:miles)heading=home.heading_to(work) # result is in degrees, 0 is northendpoint=home.endpoint(90,2) # two miles due eastmidpoing=home.midpoint_to(work)Test if a point is contained within bounds:
bounds=Bounds.new(sw_point,ne_point)bounds.contains?(home)Find within bounds:
bounds=Bounds.new(sw_point,ne_point)Store.find :all, :bounds=>boundsFind distance to a second location with on-the-fly geocoding:
s = Store.find(:first)distance = s.distance_from('100 spear st, San Francisco, CA')
Best Regards
Naveen Butola�
|
My Blog Title
|