For a project I rely on the proximity filter. I use it with a Gmap to create a store locator. Currently, location.module uses the zipcodes table with a set of zipcodes.xx.mysql files to pre-populate latitudes and longitudes.
But I needed a world wide store locator... So I thought, why not geocode missing zipcodes via the location maps API? I created a patch for the proximity handler and another patch for a small change to install.module:
- we lookup a zipcode in zipcodes table
- if found, OK
- if NOT, then lookup via location.module geocoding (e.g. Google Maps API)
- store the zipcode + country + coordinates in the zipcodes table
- from now on, we can find this zipcode in our zipcodes table
(Invalid zipcodes are never stored, because the geocoder would return empty data.)
Important: my patch includes the patch from comment 159 at #321114, with some re-working and bugfixing!
The zipcodes table also holds city, state, DST and timezone data. Of course that will not be populated automatically. So to make my patch work, the zipcodes table has to have NULL values for city and state. DST and timezone will be 0. Incorrect, but a small price to pay for Drupal's first world wide proximity filter.
I included the patch for location.install file (city state NULL in zipcodes).
This is my first Drupal patch by the way.
Check out my world wide store locator!
PASSED: [[SimpleTest]]: [MySQL] 329 pass(es). View
PASSED: [[SimpleTest]]: [MySQL] 425 pass(es). View
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 662892-based-on-16.patch. Unable to apply patch. See the log in the details link for more information. View