GeoKit: Improvements to distance_between and distance_to
Over at Earthcode, a request was made to enable the distance_between and distance_to methods to accept physical locations in pre-geocoded string form. I have added this improvement, so you can now do:
1 2 3 4 5 6 7 |
# Geocode from and to, then calculate the distance # between them. dist = Store.distance_between(“Irving, TX“, “San Francisco, CA“) # Geocode the to, then calculate the distance to it. dist = irving.distance_to(“San Francisco, CA“) |
Andre has also added further flexibility to the :origin to include setting it to an array of lat / lng values. Usage looks like:
1 2 3 |
# Presumably some previous geocoding and then this: stores = Store.find(:all, :origin => [37.792,-122.393], :conditions => ‘distance < 10‘) |
Keep the feedback coming!