README.markdown in geokit-with-google-premier-1.5.0 vs README.markdown in geokit-with-google-premier-1.5.5
- old
+ new
@@ -1,9 +1,52 @@
## GEOKIT GEM DESCRIPTION
-For Premier instructions visit:
+**For Premier instructions visit:**
-http://groups.google.com/group/geokit/browse_thread/thread/14813f74bc0da41f/cd9d30f79dfa7088?lnk=gst&q=premier#cd9d30f79dfa7088
+1. http://groups.google.com/group/geokit/browse_thread/thread/14813f74bc0da41f/cd9d30f79dfa7088?lnk=gst&q=premier#cd9d30f79dfa7088
+
+**Cache Support Added:**
+credit: Brian Armstrong
+http://groups.google.com/group/geokit/browse_thread/thread/cab2e140184de9bf/f29bc0d284b5cd41?lnk=gst&q=%5B%3Acache#f29bc0d284b5cd41
+
+You need to:
+
+1. Create GeocodeCache model
+
+class CreateGeocodeCaches < ActiveRecord::Migration
+ def self.up
+ create_table :geocode_caches do |t|
+ t.string :address
+ t.float :lat
+ t.float :lng
+
+ t.timestamps
+ end
+ add_index :geocode_caches, :address
+ end
+
+ def self.down
+ drop_table :geocode_caches
+ end
+end
+
+
+2. And then add a method to this model
+
+class GeocodeCache < ActiveRecord::Base
+ def self.store address, lat, lng
+ GeocodeCache.create(:address=>address, :lat=>lat, :lng=>lng)
+ end
+end
+
+3. In environment.rb add the new cache geocoder to the front of your priority list so it will try the cache first (note: this assumes you are using the MultiCoder)
+
+GeoKit::Geocoders::provider_order = [:cache,:google,:yahoo]
+
+4. To invalidate the cache occasionally you can run something like this in a cron job (addresses shouldn't move very often)
+
+GeocodeCache.delete_all(["created_at < ?",2.months.ago]
+
The Geokit gem provides:
* Distance calculations between two points on the earth. Calculate the distance in miles, kilometers, or nautical miles, with all the trigonometry abstracted away by GeoKit.
* Geocoding from multiple providers. It supports Google, Yahoo, Geocoder.us, and Geocoder.ca geocoders, and others. It provides a uniform response structure from all of them.