Index: location.uk.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/location/supported/location.uk.inc,v
retrieving revision 1.7
diff -b -B -u -r1.7 location.uk.inc
--- location.uk.inc	8 Mar 2008 18:55:18 -0000	1.7
+++ location.uk.inc	4 May 2010 12:10:16 -0000
@@ -268,3 +268,89 @@
     return NULL;
   }
 }
+
+/**
+ * Returns a lat/lon pair of the approximate center of the given postal code in the given country
+ *
+ * @param $location
+ *   An associative array $location where
+ *     'street'       => the street portion of the location
+ *     'supplemental' => additional street portion of the location
+ *     'province'     => the province, state, or territory
+ *     'country'      => lower-cased two-letter ISO code (REQUIRED)
+ *     'postal_code'  => the international postal code for this location (REQUIRED)
+ *
+ * @return
+ *   An associative array where
+ *      'lat' => approximate latitude of the center of the postal code's area
+ *      'lon' => approximate longitude of the center of the postal code's area
+ *
+ */
+function location_latlon_rough_uk($location = array()) {
+  if (!isset($location['postal_code'])) {
+    return NULL;
+  }
+  if (! db_table_exists('zipcodes')) {
+    return NULL;
+  }
+
+  $result = db_query("SELECT latitude, longitude FROM {zipcodes} WHERE country = '%s' AND zip = '%s'", $location['country'], 
+$location['postal_code']);
+
+  if ($row = db_fetch_object($result)) {
+    return array('lat' => $row->latitude, 'lon' => $row->longitude);
+  }
+  else {
+    return NULL;
+  }
+}
+
+/**
+ * Returns a lat/lon pair of the approximate center of the given postal code in the given country
+ *
+ * @param $location
+ *   An associative array $location where only postal code and country are necessary, but can have the keys:
+ *     'street'       => the street portion of the location
+ *     'supplemental' => additional street portion of the location
+ *     'province'     => the province, state, or territory
+ *     'country'      => lower-cased two-letter ISO code (REQUIRED)
+ *     'postal_code'  => the international postal code for this location (REQUIRED)
+ *
+ * @return
+ *   An associative array where
+ *      'lat' => approximate latitude of the center of the postal code's area
+ *      'lon' => approximate longitude of the center of the postal code's area
+ *
+ */
+function location_get_postalcode_data_uk($location = array()) {
+  if (! db_table_exists('zipcodes')) {
+    return NULL;
+  }
+
+  // Now we query.
+  $res = db_query("SELECT * FROM {zipcodes} where country = '%s' AND zip = '%s'", $location['country'], $location['postal_code']);
+  if ($row = db_fetch_object($res)) {
+    return array('lat' => $row->latitude, 'lon' => $row->longitude, 'city' => $row->city, 'province' => $row->state, 'country' => 
+$row->country);
+  }
+  else {
+    return NULL;
+  }
+}
+
+/**
+ * Parameters:
+ *   An associative array $location where
+ *     'street'       => the street portion of the location
+ *     'supplemental' => additional street portion of the location
+ *     'province'     => the province, state, or territory
+ *     'country'      => lower-cased two-letter ISO code (REQUIRED)
+ *     'postal_code'  => the international postal code for this location (REQUIRED)
+ *
+ *
+ */
+function location_latlon_exact_uk($location = array()) {
+  return NULL;
+  // someday when Royal Mail et al let go of their monopoly.....
+}
+
