Skip to content

Instantly share code, notes, and snippets.

@choipd
Created October 5, 2012 17:14
Show Gist options
  • Save choipd/3841074 to your computer and use it in GitHub Desktop.
Save choipd/3841074 to your computer and use it in GitHub Desktop.
call_geocoding 구현
api_key = "당신의 다음 Open API 키"
def call_geocoding(address)
begin
uri = "http://apis.daum.net/local/geo/addr2coord?apikey=#{api_key}&output=xml&q=#{URI::encode(address)}"
doc = Nokogiri::XML(open(uri))
rescue OpenURI::HTTPError => the_error
the_status = the_error.io.status[0]
puts "[#{the_status}]"
else
if doc.xpath("//lng[1]").text == "" then
puts "#{address} failed!"
return call_geocoding(address.gsub(/\s.*$/, ""))
end
return doc
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment