class Geocoder::Lookup::Osmnames
def base_query_url(query)
def base_query_url(query) "#{base_url(query)}/#{params_url(query)}.js?" end
def base_url(query)
def base_url(query) host = configuration[:host] || 'geocoder.tilehosting.com' "#{protocol}://#{host}" end
def country_limited(query)
def country_limited(query) "#{query.options[:country_code].downcase}/" if query.options[:country_code] && !query.reverse_geocode? end
def name
def name 'OSM Names' end
def params_url(query)
def params_url(query) method, args = 'q', CGI.escape(query.sanitized_text) method, args = 'r', query.coordinates.join('/') if query.reverse_geocode? "#{country_limited(query)}#{method}/#{args}" end
def query_url_params(query)
def query_url_params(query) { key: configuration.api_key }.merge(super) end
def required_api_key_parts
def required_api_key_parts configuration[:host] ? [] : ['key'] end
def results(query)
def results(query) return [] unless doc = fetch_data(query) if (error = doc['message']) raise_error(Geocoder::InvalidRequest, error) || Geocoder.log(:warn, "OSMNames Geocoding API error: #{error}") else return doc['results'] end end
def supported_protocols
def supported_protocols [:https] end