Sha256: c4cded71f9eb7e5ff6779d93ce203cf6dc480447081087deddd6c8fa9c81f62b
Contents?: true
Size: 1.11 KB
Versions: 10
Compression:
Stored size: 1.11 KB
Contents
require 'geocoder/lookups/base' require "geocoder/results/geocoder_ca" module Geocoder::Lookup class GeocoderCa < Base private # --------------------------------------------------------------- def results(query, reverse = false) return [] unless doc = fetch_data(query, reverse) if doc['error'].nil? return [doc] elsif doc['error']['code'] == "005" # "Postal Code is not in the proper Format" => no results, just shut up else warn "Geocoder.ca service error: #{doc['error']['code']} (#{doc['error']['description']})." end return [] end def query_url(query, reverse = false) params = { :geoit => "xml", :jsonp => 1, :callback => "test" } if reverse lat,lon = query.split(',') params[:latt] = lat params[:longt] = lon params[:corner] = 1 params[:reverse] = 1 else params[:locate] = query end "http://geocoder.ca/?" + hash_to_query(params) end def parse_raw_data(raw_data) super raw_data[/^test\((.*)\)\;\s*$/, 1] end end end
Version data entries
10 entries across 10 versions & 2 rubygems