I would like to be able to get the weather based on a US zip code. What would be the right way to implement this?
Is there a ZIP to ICAO mapping somewhere?

Hopefully, I will implement it and contribute back.

Comments

yhager’s picture

Hmm.. hack it?

I found this code returns the ICAO code, for (some of the) zip codes. Not working in all cases, but maybe a start? Maybe we can build an list offline?

function zip2icao($zip) {
  $page = drupal_http_request("http://forecast.weather.gov/zipcity.php?inputstring=$zip");
  preg_match('@http://www.weather.gov/data/obhistory/([^/]+).html@i',$page->data, $matches);
  return $matches[1];
}
toddy’s picture

Assigned: Unassigned » toddy
Status: Active » Closed (won't fix)

Hi,

the weather module has now the ability to search for locations based on ICAO code, name, or country. Maybe this helps you as well. I don't plan to support US zip codes.

Regards,
Tobias