michi/geocoder.rb
# Fetch the coordinate (or coordinate*s*) matching this address.
# This method includes error handling and retry logic.
# It will return all matching addresses, in the form of a Hash object:
# [{"formatted_address" => "what google thinks", "location" => {"lat" => float, "lng" => float}] 
Fetch the coordinate (or coordinate*s*) matching this address.
This method includes error handling and retry logic.
Fetch the coordinate ( or coordinate * s * ) matching this address . This method includes error handling and retry logic .
def encode(address)
    resultset = query_google(address)
    if resultset.nil?
      @log.fatal("Fatal error: nil response instead of an HTTP response of some kind from the attempt to query_google")
      return nil
    end
    until(resultset.kind_of?(Hash) || resultset.kind_of?(Array))
      @log.error {"Error from Google API: #{resultset.code} #{resultset.message}: #{resultset.body.to_s}. Sleeping 5 seconds before the next retry"}
      sleep(5)
      resultset = query_google(address)
    end
    return resultset
  end
def encode ( address ) resultset = query_google ( address ) if resultset . nil? @log . fatal ( "Fatal error: nil response instead of an HTTP response of some kind from the attempt to query_google" ) return nil end until ( resultset . kind_of? ( Hash ) || resultset . kind_of? ( Array ) ) @log . error { "Error from Google API: #{resultset.code} #{resultset.message}: #{resultset.body.to_s}. Sleeping 5 seconds before the next retry" } sleep ( 5 ) resultset = query_google ( address ) end return resultset end
Fetch the coordinate (or coordinate*s*) matching this address.
Fetch the coordinate ( or coordinate * s * ) matching this address .
address