Created
December 7, 2014 19:26
-
-
Save n1zyy/fee0a53e60ebf532ba5e to your computer and use it in GitHub Desktop.
Half-assed GeoIP center-finder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
geos = {} | |
places.each do |p| | |
puts "Geocoding #{p}..." | |
geo = Geocoder.search(p) | |
geos[p] = { | |
:lat => geo.first.latitude, | |
:long => geo.first.longitude | |
} | |
puts " Found #{geos[p].inspect}" | |
end | |
puts "\nFound #{places.size} locations..." | |
lat = 0.0 | |
long = 0.0 | |
geos.each do |g| | |
lat += g[1][:lat] | |
long += g[1][:long] | |
end | |
puts "Average lat = #{lat} / #{places.size}" | |
puts "Average long = #{long} / #{places.size}" | |
puts "Reverse geocoding..." | |
center = Geocoder.search("#{lat}, #{long}") | |
puts center.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment