You are here

function _location_latlon_rough_no in Location 5.3

Same name and namespace in other branches
  1. 6.3 supported/location.no.inc \_location_latlon_rough_no()
  2. 7.5 supported/location.no.inc \_location_latlon_rough_no()
  3. 7.3 supported/location.no.inc \_location_latlon_rough_no()
  4. 7.4 supported/location.no.inc \_location_latlon_rough_no()

File

supported/location.no.inc, line 27

Code

function _location_latlon_rough_no($location = array()) {
  if (!isset($location['postal_code'])) {
    return NULL;
  }
  $result = db_query("SELECT latitude, longitude FROM {zipcodes} WHERE country = '%s' AND zip = '%s'", $location['country'], substr(str_pad($location['postal_code'], 5, '0', STR_PAD_LEFT), 0, 5));
  if ($row = db_fetch_object($result)) {
    return array(
      'lat' => $row->latitude,
      'lon' => $row->longitude,
    );
  }
  else {
    return NULL;
  }
}