Skip to content

Instantly share code, notes, and snippets.

@ashlynnpai
Created July 26, 2016 21:52
Show Gist options
  • Save ashlynnpai/7756c55f037083d3da8823065b5dd9bb to your computer and use it in GitHub Desktop.
Save ashlynnpai/7756c55f037083d3da8823065b5dd9bb to your computer and use it in GitHub Desktop.
require "geocoder"
list = [[38.0813888889,46.2930555556,0,1,1346,"Tabriz Historic Bazaar Complex"]]
def get_coordinates(list)
all_places = []
list.each do |row|
place = []
name = row[5]
lat = row[0]
long = row[1]
coordinates = lat.to_s + "," + long.to_s
addresses = Geocoder.search(coordinates)
address = addresses[0].formatted_address
place.push(name, address, lat, long)
all_places << place
end
File.open('cleaned.txt', 'w') { |file| file.write(all_places) }
all_places
end
get_coordinates(list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment