tested on cygwin. runs smoothly..
original article :http://blog.hungrymachine.com/2007/10/31/super-fast-ip-to-lat-lng-in-rails-part-2
wget http://www.maxmind.com/download/geoip/api/c/GeoIP.tar.gz tar -zxvf GeoIP.tar.gz cd GeoIP ./configure && make && sudo make install wget http://rubyforge.org/frs/download.php/27077/geoip_city-0.1.gem sudo gem install geoip_city-0.1.gem wget http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz gunzip GeoLiteCity.dat.gz sudo mkdir /usr/local/share/GeoIP sudo mv GeoLiteCity.dat /usr/local/share/GeoIP/GeoLiteCity.dat
>> require 'geoip_city' >> g = GeoIPCity::Database.new('/usr/local/share/GeoIP/GeoLiteCity.dat') >> res = g.look_up('4.2.2.2') >> puts "lat: #{res[:latitude]} lng: #{res[:longitude]}" lat: 38.0 lng: -97.0
0 comments:
Post a Comment