class WeatherSage::Census::Geocoder
Wrapper around Census geocoder API.
Constants
- PARAMS
Static parameters for geocoder requests.
Source: geocoding.geo.census.gov/geocoder/Geocoding_Services_API.pdf
- URL
Public Class Methods
new(ctx)
click to toggle source
Create new Geocoder
instance.
# File lib/weather-sage/census/geocoder.rb, line 24 def initialize(ctx) @ctx = ctx end
Public Instance Methods
run(s)
click to toggle source
Geocode given address string s
and return an array of Match objects.
# File lib/weather-sage/census/geocoder.rb, line 32 def run(s) # exec request data = @ctx.cache.get(URL, PARAMS.merge({ address: s, })) # log data @ctx.log.debug('Geocoder#run') do 'data = %p' % [data] end # map matches and return result data['result']['addressMatches'].map { |row| ::WeatherSage::Census::Match.new(@ctx, row) } end