diff --git a/supported/location.au.inc b/supported/location.au.inc index bc0dd2f..14767ac 100644 --- a/supported/location.au.inc +++ b/supported/location.au.inc @@ -24,17 +24,14 @@ function location_latlon_rough_au($location = array()) { return NULL; } - $row = db_query("SELECT latitude, longitude FROM {zipcodes} WHERE country = :country AND zip = :zip", array( - ':country' => $location['country'], - ':zip' => substr(str_pad($location['postal_code'], 4, '0', STR_PAD_LEFT), 0, 4) - ))->fetchObject(); + // Correct the postal code. + $location['postal_code'] = substr(str_pad($location['postal_code'], 4, '0', STR_PAD_LEFT), 0, 4); - if ($row) { - return array('lat' => $row->latitude, 'lon' => $row->longitude); - } - else { - return NULL; - } + // This is for the Australia. + $location['country'] = 'au'; + + // Defer to the default logic. + return location_latlon_rough_default($location); } /** diff --git a/supported/location.ca.inc b/supported/location.ca.inc index 9508c7b..f58eca5 100644 --- a/supported/location.ca.inc +++ b/supported/location.ca.inc @@ -36,42 +36,6 @@ function location_province_list_numeric_ca() { ); } - -/** - * 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_ca($location = array()) { - if (!isset($location['postal_code'])) { - return NULL; - } - - $row = db_query("SELECT latitude, longitude FROM {zipcodes} WHERE country = :country AND zip = :zip", array( - ':country' => $location['country'], - ':zip' => $location['postal_code'] - ))->fetchObject(); - - if ($row) { - 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 * diff --git a/supported/location.no.inc b/supported/location.no.inc index 2352a58..d1bc300 100644 --- a/supported/location.no.inc +++ b/supported/location.no.inc @@ -26,22 +26,22 @@ function location_province_list_no() { ); } +/** + * Disabled. + */ function _location_latlon_rough_no($location = array()) { if (!isset($location['postal_code'])) { return NULL; } - $row = db_query("SELECT latitude, longitude FROM {zipcodes} WHERE country = :country AND zip = :zip", array( - ':country' => $location['country'], - ':zip' => substr(str_pad($location['postal_code'], 5, '0', STR_PAD_LEFT), 0, 5) - ))->fetchObject(); + // Correct the postal code. + $location['postal_code'] = substr(str_pad($location['postal_code'], 5, '0', STR_PAD_LEFT), 0, 5); - if ($row) { - return array('lat' => $row->latitude, 'lon' => $row->longitude); - } - else { - return NULL; - } + // This is for Norway. + $location['country'] = 'no'; + + // Defer to the default logic. + return location_latlon_rough_default($location); } /** diff --git a/supported/location.nz.inc b/supported/location.nz.inc index cf0e043..9a9bdbd 100644 --- a/supported/location.nz.inc +++ b/supported/location.nz.inc @@ -97,14 +97,14 @@ function location_latlon_rough_nz($location = array()) { return NULL; } - $result = db_query("SELECT latitude, longitude FROM {zipcodes} WHERE country = '%s' AND zip = '%s'", $location['country'], substr(str_pad($location['postal_code'], 4, '0', STR_PAD_LEFT), 0, 4)); + // Correct the postal code. + $location['postal_code'] = substr(str_pad($location['postal_code'], 4, '0', STR_PAD_LEFT), 0, 4); - if ($row = db_fetch_object($result)) { - return array('lat' => $row->latitude, 'lon' => $row->longitude); - } - else { - return NULL; - } + // This is for New Zealand. + $location['country'] = 'nz'; + + // Defer to the default logic. + return location_latlon_rough_default($location); } /** diff --git a/supported/location.us.inc b/supported/location.us.inc index c0f4e0a..a5d567e 100644 --- a/supported/location.us.inc +++ b/supported/location.us.inc @@ -22,17 +22,14 @@ function location_latlon_rough_us($location = array()) { return NULL; } - $row = db_query("SELECT latitude, longitude FROM {zipcodes} where country = :country AND zip = :zip", array( - ':country' => $location['country'], - ':zip' => substr(str_pad($location['postal_code'], 5, '0', STR_PAD_LEFT), 0, 5) - ))->fetchObject(); + // Correct the ZIP code / postal code. + $location['postal_code'] = substr(str_pad($location['postal_code'], 5, '0', STR_PAD_LEFT), 0, 5); - if ($row) { - return array('lat' => $row->latitude, 'lon' => $row->longitude); - } - else { - return NULL; - } + // This is for the USA. + $location['country'] = 'us'; + + // Defer to the default logic. + return location_latlon_rough_default($location); } /**