You are here

icao_codes.inc in Weather 5.6

Same filename and directory in other branches
  1. 5 icao_codes.inc

File

icao_codes.inc
View source
<?php

/*
 * Copyright (C) 2006-2007 Tobias Quathamer <t.quathamer@gmx.net>
 *
 * This file is part of the Drupal Weather module.
 *
 * Weather is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Weather is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Weather; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
function _weather_get_countries() {
  $sql = "SELECT country FROM {weather_icao}\n";
  $sql .= "GROUP BY country ORDER BY country ASC";
  $result = db_query($sql);
  while ($row = db_fetch_array($result)) {
    $countries[] = $row['country'];
  }
  return $countries;
}
function _weather_get_places($country) {
  $sql = "SELECT icao, name FROM {weather_icao}\n";
  $sql .= "WHERE country='%s' ORDER BY name ASC";
  $result = db_query($sql, $country);
  while ($row = db_fetch_array($result)) {
    $places[$row['icao']] = $row['name'];
  }
  return $places;
}
function _weather_get_country_from_icao($wanted_icao) {
  $sql = "SELECT country FROM {weather_icao} WHERE icao='%s'";
  $result = db_query($sql, $wanted_icao);
  $row = db_fetch_array($result);
  return $row['country'];
}
function _weather_get_lat_long($wanted_icao) {
  $sql = "SELECT latitude, longitude FROM {weather_icao} WHERE icao='%s'";
  $result = db_query($sql, $wanted_icao);
  $row = db_fetch_array($result);
  return $row;
}