Has anyone go UK postcode for radius/proximity search working in production using drupal??

I've looked at stable d6 modules and nothing seems to achieve this? Please can anyone help??

I want to be able to associate a user or node with a location and then allow searching for this. I've looked at location module but I can't get that to achieve this in uk, can anyone?

Comments

steveadamo’s picture

*bump*

having the same problem here...

-----------------------------
Find. Meet. Play!
http://www.weplaygroup.com

steveadamo’s picture

for me, the solution was to apply a fix I read about for proximty searching Canadian content.

http://drupal.org/node/255995

i simply took the location_latlon_rough_ca and added it to my location.uk.inc file (changing the function to _uk):

function location_latlon_rough_uk($location = array()) {
  if (!isset($location['postal_code'])) {
    return NULL;
  }

  $postal_code = $location['postal_code'];
  while(strlen($postal_code) >= 2) {
      $result = db_query("SELECT latitude, longitude FROM {zipcodes} WHERE country = '%s' AND zip LIKE '%s%'", $location['country'], $postal_code);

      if ($row = db_fetch_object($result)) {
        return array('lat' => $row->latitude, 'lon' => $row->longitude);
      }
      $postal_code = trim(substr($postal_code, 0, -1));
  }
  return NULL;
}

i dropped the strlen check by one, as the first address i was unable to find (via proximity search) was E8 1EJ.

hope this helps!

-----------------------------
Find. Meet. Play!
http://www.weplaygroup.com