Graticule Geocoding Problem
I'm attempting to use Graticule to geocode an addr开发者_开发技巧ess but I'm running into an annoying problem. When geocoding an address in the US, the region attribute from the location is the two letter abbreviation instead of the full name (OH instead of Ohio). Is there any way to retrieve the full name?
Looks like Graticule just passes through the raw results from the various services, only normalizing the attribute names. So the short answer is: only by using a service that currently returns the full name in the field Graticule is mapping to region for that service.
Long answer (or suggestion really).
I'd replace the value using a Hash, e.g.,
US_STATES = {
'OH' => 'Ohio'
[...]
}
my_loc.region = US_STATES[my_loc.region] || my_loc.region
Probably would want to wrap that in a check for country, but then you'd have to be sure to cover all the possible country values from the services, e.g.,
if my_loc.country =~ /\A\s*(US|U\.?S\.?A)\s*\z/i
That would get you some stability so changing services, or services changing their results, won't surprise you later on.
If you were feeling intrepid, could fork Graticule and add region_name and region_abbr methods (or the like) since the current 'region' has variable meanings/results and send a pull request...
精彩评论