collectiveidea/graticule — pull request #45 by mckinnsb (2014-10-07 21:36:00+00:00)
Title: Small tweak that gives some love to sublocalities

We have been doing a lot of geocoding in the New York area and noticed that some services ( Google Maps ) did not return any information about locality if the address was in Brooklyn or Queens. ( In other words, the city would be blank ).

For example ( Geocoding::GEOCODER is an instance of Graticule.service, using Google ):

2.0.0 :003 > Geocoding::GEOCODER.locate( "200 Eastern Parkway" ) //this is in brooklyn

=> #>

WIth this small patch, it will correctly return:

=> #>

I'm not sure that Google will report back a locality if a sub-locality is found, In most cases you want to know the sub-locality anyway, as it generally specifies a borough or other region that may appear on a mailing address, and residents probably identify with it more directly rather than the encompassing locality.

If there are cases where Google will report back both ( we have not found any ), then perhaps a better fix would be to have a :sublocality attr_accessor and store the result from Google there.

Decided to make a PR to get the juices flowing. Thanks for the work!