You are here

weather.install in Weather 7

Install, update and uninstall functions for the weather module.

Copyright © 2006-2013 Tobias Quathamer <t.quathamer@gmx.net>

This program 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.

This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

File

weather.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the weather module.
 *
 * Copyright © 2006-2013 Tobias Quathamer <t.quathamer@gmx.net>
 *
 * This program 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.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

/**
 * Helper function for installation and upgrades.
 *
 * This function inserts data into the weather_icao table.
 *
 * The data file lists one table entry per line. Fields are separated
 * by tab stops. In order to be better readable by humans, the fields
 * are filled with spaces. Those superfluous space characters are
 * removed before inserting the value in the table. The fields are
 * listed in the file with the following order:
 *
 * ICAO code
 *   4 characters.
 * Tab stop
 * Latitude
 *   10 characters, positive values for north, negative for south.
 * Tab stop
 * Longitude
 *   11 characters, positive values for east, negative for west.
 * Tab stop
 * Country
 *   35 characters.
 * Tab stop
 * Name
 *   Variable length, not padded with spaces.
 */
function weather_data_installation() {

  // Delete all entries from the table, if any.
  db_delete('weather_icao')
    ->execute();

  // Prepare the SQL query.
  $query = db_insert('weather_icao')
    ->fields(array(
    'icao',
    'country',
    'name',
    'latitude',
    'longitude',
  ));

  // Read the data file and append values to query.
  $data = fopen(drupal_get_path('module', 'weather') . '/weather_data.txt', 'r');
  while (!feof($data)) {
    $line = fgets($data);
    $fields = explode("\t", $line);

    // If we get to the last line, there won't be more than one field.
    if (isset($fields[1])) {
      $query
        ->values(array(
        'icao' => $fields[0],
        'country' => trim($fields[3]),
        'name' => trim($fields[4]),
        'latitude' => $fields[1],
        'longitude' => $fields[2],
      ));
    }
  }
  fclose($data);
  $query
    ->execute();
}

/**
 * Implement hook_install().
 *
 * Currently, it's only needed to insert data into the weather_icao
 * table. We use a helper function for this task.
 */
function weather_install() {
  weather_data_installation();
}

/**
 * Implement hook_uninstall().
 */
function weather_uninstall() {
  variable_del('weather_image_directory');

  // Remove blocks provided by the module
  db_delete('block')
    ->condition('module', 'weather')
    ->execute();
  db_delete('block_node_type')
    ->condition('module', 'weather')
    ->execute();
  db_delete('block_role')
    ->condition('module', 'weather')
    ->execute();
}

/**
 * Implement hook_schema().
 */
function weather_schema() {
  $schema['weather_metar'] = array(
    'description' => 'Raw and parsed METAR data for all currently used ICAO codes.',
    'fields' => array(
      'icao' => array(
        'description' => 'ICAO code of the METAR station.',
        'type' => 'varchar',
        'length' => 4,
        'not null' => TRUE,
        'default' => '',
      ),
      'reported_on' => array(
        'description' => 'UTC time of weather report.',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'next_update_on' => array(
        'description' => 'UTC time of next scheduled update.',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'sky_condition' => array(
        'description' => 'Sky condition, cloud covering.',
        'type' => 'varchar',
        'length' => 25,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'phenomena' => array(
        'description' => 'Phenomena like rain, snow, thunderstorm.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'temperature' => array(
        'description' => 'Temperature in degree celsius.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'dewpoint' => array(
        'description' => 'Dewpoint temperature in degree celsius.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'wind_direction' => array(
        'description' => 'Wind direction in degrees.',
        'type' => 'varchar',
        'length' => 8,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'wind_speed' => array(
        'description' => 'Wind speed in km/h.',
        'type' => 'float',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'wind_gusts' => array(
        'description' => 'Wind gust speed in km/h.',
        'type' => 'float',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'pressure' => array(
        'description' => 'Pressure in hPa.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'visibility' => array(
        'description' => 'Visibility in meter.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'sunrise_on' => array(
        'description' => 'UTC time of sunrise (NULL if there is no sunrise).',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'sunset_on' => array(
        'description' => 'UTC time of sunset (NULL if there is no sunset).',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'image' => array(
        'description' => 'Filename of the weather image file.',
        'type' => 'varchar',
        'length' => 35,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'raw' => array(
        'description' => 'Raw METAR data.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'icao',
    ),
  );
  $schema['weather_location'] = array(
    'description' => 'Configuration of a location.',
    'fields' => array(
      'id' => array(
        'description' => 'Location id.',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'display_type' => array(
        'description' => 'Type of display (system-wide, user, location, default, ...).',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'display_number' => array(
        'description' => 'Display number.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'icao' => array(
        'description' => 'ICAO code of the METAR station.',
        'type' => 'varchar',
        'length' => 4,
        'not null' => TRUE,
        'default' => '',
      ),
      'real_name' => array(
        'description' => 'The name to display for the ICAO code.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'weight' => array(
        'description' => 'Weight of the location.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'foreign keys' => array(
      'display_type' => array(
        'weather_display' => 'type',
      ),
      'display_number' => array(
        'weather_display' => 'number',
      ),
    ),
  );
  $schema['weather_display'] = array(
    'description' => 'Configuration of a display (for example, a block).',
    'fields' => array(
      'type' => array(
        'description' => 'Type of display (system-wide, user, location, default, ...).',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'number' => array(
        'description' => 'Display number.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'units' => array(
        'description' => 'Units for display (Celsius/Fahrenheit, mmHg/hPa etc.).',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'serialize' => TRUE,
      ),
      'settings' => array(
        'description' => 'Settings for display (Show raw METAR, abbrev. wind directions etc.).',
        'type' => 'text',
        'size' => 'normal',
        'not null' => TRUE,
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'type',
      'number',
    ),
  );
  $schema['weather_icao'] = array(
    'description' => 'Contains all known ICAO codes with further information.',
    'fields' => array(
      'icao' => array(
        'description' => 'ICAO code of the METAR station.',
        'type' => 'varchar',
        'length' => 4,
        'not null' => TRUE,
        'default' => '',
      ),
      'country' => array(
        'description' => 'Name of the country.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'name' => array(
        'description' => 'Name of the METAR station.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'latitude' => array(
        'description' => 'Location of METAR station, latitude.',
        'type' => 'float',
        'size' => 'big',
        'not null' => TRUE,
        'default' => 0.0,
      ),
      'longitude' => array(
        'description' => 'Location of METAR station, longitude.',
        'type' => 'float',
        'size' => 'big',
        'not null' => TRUE,
        'default' => 0.0,
      ),
    ),
    'primary key' => array(
      'icao',
    ),
  );
  return $schema;
}

/**
 * Implement hook_update_last_removed().
 *
 * History of removed updates and their Drupal version:
 * Drupal 4.7.x: 1, 2, 3
 * Drupal 5.x: 4, 5, 6, 7, 8, 9, 10
 * Drupal 6.x: 6100, 6101, 6200, 6500, 6501, 6502, 6503, 6504, 6505,
 *             6506, 6507, 6508, 6509
 */
function weather_update_last_removed() {
  return 6509;
}

/**
 * Removes hardcoded numeric deltas from blocks.
 */
function weather_update_7000(&$sandbox) {

  // Get an array of the renamed block deltas, organized by module.
  $renamed_deltas = array(
    'weather' => array(
      '0' => 'user',
      '1' => 'location',
    ),
  );

  // Determine the highest used block delta of system-wide blocks.
  $max_delta = (int) db_query("SELECT MAX(delta) FROM {block} WHERE module='weather'")
    ->fetchField();

  // Add all possible deltas up to the maximal delta determined above.
  // The system-wide block deltas start at 3, which represents block number 1.
  $delta = 3;
  while ($delta <= $max_delta) {
    $renamed_deltas['weather'][$delta] = 'system_' . ($delta - 2);
    $delta++;
  }
  $moved_deltas = array();
  update_fix_d7_block_deltas($sandbox, $renamed_deltas, $moved_deltas);
}

/**
 * Implement hook_update_N().
 *
 * Change tables of weather module to match the new schema.
 */
function weather_update_7100(&$sandbox) {

  // The cron option is no longer provided.
  variable_del('weather_use_cron');

  // Table 'weather' is replaced by 'weather_metar'. Because all data
  // is updated at least after one hour, there's no need to migrate
  // old data from the the 'weather' table, so we simply remove it.
  db_drop_table('weather');

  // Define and create the new table.
  $schema = array(
    'description' => 'Raw and parsed METAR data for all currently used ICAO codes.',
    'fields' => array(
      'icao' => array(
        'description' => 'ICAO code of the METAR station.',
        'type' => 'varchar',
        'length' => 4,
        'not null' => TRUE,
        'default' => '',
      ),
      'reported_on' => array(
        'description' => 'UTC time of weather report.',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'next_update_on' => array(
        'description' => 'UTC time of next scheduled update.',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'sky_condition' => array(
        'description' => 'Sky condition, cloud covering.',
        'type' => 'varchar',
        'length' => 25,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'phenomena' => array(
        'description' => 'Phenomena like rain, snow, thunderstorm.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'temperature' => array(
        'description' => 'Temperature in degree celsius.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'dewpoint' => array(
        'description' => 'Dewpoint temperature in degree celsius.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'wind_direction' => array(
        'description' => 'Wind direction in degrees.',
        'type' => 'varchar',
        'length' => 8,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'wind_speed' => array(
        'description' => 'Wind speed in km/h.',
        'type' => 'float',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'wind_gusts' => array(
        'description' => 'Wind gust speed in km/h.',
        'type' => 'float',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'pressure' => array(
        'description' => 'Pressure in hPa.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'visibility' => array(
        'description' => 'Visibility in meter.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'sunrise_on' => array(
        'description' => 'UTC time of sunrise (NULL if there is no sunrise).',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'sunset_on' => array(
        'description' => 'UTC time of sunset (NULL if there is no sunset).',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'image' => array(
        'description' => 'Filename of the weather image file.',
        'type' => 'varchar',
        'length' => 35,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'raw' => array(
        'description' => 'Raw METAR data.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'icao',
    ),
  );
  db_create_table('weather_metar', $schema);

  // Create new table for locations.
  $schema = array(
    'description' => 'Configuration of a location.',
    'fields' => array(
      'id' => array(
        'description' => 'Location id.',
        'type' => 'serial',
      ),
      'display_type' => array(
        'description' => 'Type of display (system-wide, user, location, default, ...).',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'display_number' => array(
        'description' => 'Display number.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'icao' => array(
        'description' => 'ICAO code of the METAR station.',
        'type' => 'varchar',
        'length' => 4,
        'not null' => TRUE,
        'default' => '',
      ),
      'real_name' => array(
        'description' => 'The name to display for the ICAO code.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'weight' => array(
        'description' => 'Weight of the location.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'foreign keys' => array(
      'display_type' => array(
        'weather_display' => 'type',
      ),
      'display_number' => array(
        'weather_display' => 'number',
      ),
    ),
  );
  db_create_table('weather_location', $schema);

  // Create new table for displays.
  $schema = array(
    'description' => 'Configuration of a display (for example, a block).',
    'fields' => array(
      'type' => array(
        'description' => 'Type of display (system-wide, user, location, default, ...).',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'number' => array(
        'description' => 'Display number.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'units' => array(
        'description' => 'Units for display (Celsius/Fahrenheit, mmHg/hPa etc.).',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'serialize' => TRUE,
      ),
      'settings' => array(
        'description' => 'Settings for display (Show raw METAR, abbrev. wind directions etc.).',
        'type' => 'text',
        'size' => 'normal',
        'not null' => TRUE,
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'type',
      'number',
    ),
  );
  db_create_table('weather_display', $schema);

  // Migrate default settings from 'weather_config'.
  $result = db_query('SELECT * FROM {weather_config} WHERE uid=0 AND cid=1')
    ->fetchObject();
  if (!empty($result)) {
    $display['type'] = 'default';
    $display['number'] = 1;
    $display['units'] = serialize(_weather_convert_units($result->units));
    $display['settings'] = serialize(_weather_convert_settings($result->settings, $result->units));
    db_insert('weather_display')
      ->fields($display)
      ->execute();
  }

  // Migrate system-wide blocks.
  $result = db_query('SELECT * FROM {weather_config} WHERE uid<0 ORDER BY cid ASC');
  $display_number = 0;
  foreach ($result as $row) {
    $location = array();
    if ($display_number < abs($row->uid)) {

      // This is a new system-wide display. Migrate display data as well.
      $display = array();
      $display_number = abs($row->uid);
      $display['type'] = 'system-wide';
      $display['number'] = $display_number;
      $display['units'] = serialize(_weather_convert_units($row->units));
      $display['settings'] = serialize(_weather_convert_settings($row->settings, $row->units));
      db_insert('weather_display')
        ->fields($display)
        ->execute();
    }

    // Migrate the location.
    $location['display_type'] = 'system-wide';
    $location['display_number'] = $display_number;
    $location['icao'] = $row->icao;
    $location['real_name'] = $row->real_name;
    $location['weight'] = $row->weight;
    db_insert('weather_location')
      ->fields($location)
      ->execute();
  }

  // Migrate custom user blocks.
  $result = db_query('SELECT * FROM {weather_config} WHERE uid>0 ORDER BY cid ASC');
  $display_number = 0;
  foreach ($result as $row) {
    $location = array();
    if ($display_number < $row->uid) {

      // This is a new custom user display. Migrate display data as well.
      $display = array();
      $display_number = $row->uid;
      $display['type'] = 'user';
      $display['number'] = $display_number;
      $display['units'] = serialize(_weather_convert_units($row->units));
      $display['settings'] = serialize(_weather_convert_settings($row->settings, $row->units));
      db_insert('weather_display')
        ->fields($display)
        ->execute();
    }

    // Migrate the location.
    $location['display_type'] = 'user';
    $location['display_number'] = $display_number;
    $location['icao'] = $row->icao;
    $location['real_name'] = $row->real_name;
    $location['weight'] = $row->weight;
    db_insert('weather_location')
      ->fields($location)
      ->execute();
  }

  // Remove old table
  db_drop_table('weather_config');
  return t('Converted tables to new internal schema.');
}

/**
 * Converts units from 6.x to 7.x module versions.
 */
function _weather_convert_units($units) {
  $units = unserialize($units);
  $new = array();
  $new['temperature'] = $units['temperature'];
  if ($new['temperature'] == 'dont-display') {
    $new['temperature'] = 'celsius';
  }
  $new['windspeed'] = $units['windspeed'];
  if ($new['windspeed'] == 'dont-display') {
    $new['windspeed'] = 'kmh';
  }
  $new['pressure'] = $units['pressure'];
  if ($new['pressure'] == 'dont-display') {
    $new['pressure'] = 'hpa';
  }
  $new['distance'] = $units['visibility'];
  if ($new['distance'] == 'dont-display') {
    $new['distance'] = 'kilometers';
  }
  return $new;
}

/**
 * Converts settings from 6.x to 7.x module versions.
 */
function _weather_convert_settings($settings, $units) {
  $settings = unserialize($settings);
  $units = unserialize($units);
  $new = array();
  $new['data'] = array();
  if ($units['temperature'] != 'dont-display') {
    $new['data']['temperature'] = 'temperature';
  }
  if ($units['windspeed'] != 'dont-display') {
    $new['data']['wind'] = 'wind';
  }
  if ($units['pressure'] != 'dont-display') {
    $new['data']['pressure'] = 'pressure';
  }
  if ($units['humidity'] != 'dont-display') {
    $new['data']['humidity'] = 'humidity';
  }
  if ($units['visibility'] != 'dont-display') {
    $new['data']['visibility'] = 'visibility';
  }
  if ($settings['show_unconverted_metar']) {
    $new['data']['metar'] = 'metar';
  }
  if ($settings['show_sunrise_sunset']) {
    $new['data']['suninfo'] = 'suninfo';
  }
  $new['show_windchill'] = $settings['show_windchill'];
  $new['show_abbreviated_directions'] = $settings['show_abbreviated_directions'];
  $new['show_directions_degree'] = $settings['show_directions_degree'];
  $new['show_compact_block'] = $settings['show_compact_block'];
  return $new;
}

/**
 * Implement hook_update_N().
 *
 * Insert new locations into ICAO table.
 * After the update to the new download location, the "fetch" variable
 * is no longer needed.
 */
function weather_update_7101(&$sandbox) {
  weather_data_installation();
  variable_del('weather_fetch');
}

/**
 * Implement hook_update_N().
 *
 * Insert three new locations into ICAO table.
 * (Northern Mariana Islands)
 */
function weather_update_7102(&$sandbox) {
  weather_data_installation();
}

/**
 * Implement hook_update_N().
 *
 * Convert settings to support heat index temperatures.
 */
function weather_update_7103(&$sandbox) {
  $result = db_query('SELECT * FROM {weather_display}');
  foreach ($result as $row) {
    $new['type'] = $row->type;
    $new['number'] = $row->number;
    $new['units'] = $row->units;
    $old = unserialize($row->settings);
    $settings = array(
      'data' => $old['data'],
      'show_apparent_temperature' => $old['show_windchill'],
      'show_abbreviated_directions' => $old['show_abbreviated_directions'],
      'show_directions_degree' => $old['show_directions_degree'],
      'show_compact_block' => $old['show_compact_block'],
    );
    $new['settings'] = serialize($settings);
    db_delete('weather_display')
      ->condition('type', $row->type)
      ->condition('number', $row->number)
      ->execute();
    db_insert('weather_display')
      ->fields($new)
      ->execute();
  }
}

/**
 * Implement hook_update_N().
 *
 * Update information for Mariscal Sucre International Airport, Ecuador.
 * Remove information for stations which no longer provide weather data.
 */
function weather_update_7104(&$sandbox) {
  weather_data_installation();
  db_update('weather_location')
    ->fields(array(
    'icao' => 'SEQM',
  ))
    ->condition('icao', 'SEQU')
    ->execute();
  $removed_icaos = array(
    'CWDL',
    'CWGZ',
    'CYEL',
    'CYLU',
    'CYSD',
    'CYSR',
    'CYTJ',
    'CZEM',
    'DAOL',
    'DFOO',
    'DGSI',
    'DNAA',
    'DNCA',
    'DNEN',
    'DNIL',
    'DNKA',
    'DNMA',
    'DNPO',
    'DNSO',
    'DRZA',
    'DRZR',
    'EDBM',
    'EDDI',
    'EDQD',
    'EGDG',
    'EGDL',
    'EGHD',
    'EGTG',
    'EGXJ',
    'EGYW',
    'EHSB',
    'EHTW',
    'EHVB',
    'EKTS',
    'ENFR',
    'ENLI',
    'EQBC',
    'ESNY',
    'ESPC',
    'ESSF',
    'ETHM',
    'FAAB',
    'FADN',
    'FAGM',
    'FAJS',
    'FAKD',
    'FANS',
    'FAPS',
    'FARG',
    'FASR',
    'FAWK',
    'FBGZ',
    'FBJW',
    'FBLT',
    'FBSN',
    'FBSW',
    'FBTE',
    'FBTS',
    'FEFG',
    'FEFT',
    'FKKN',
    'FKKR',
    'FLLS',
    'FLMF',
    'FLND',
    'FMST',
    'FNBG',
    'FNHU',
    'FOGR',
    'FOOB',
    'FOOK',
    'FOON',
    'FOOR',
    'FOOT',
    'FQIN',
    'FTTA',
    'FTTD',
    'FZOA',
    'FZQA',
    'HBBA',
    'HCMH',
    'HCMI',
    'HCMV',
    'HUAR',
    'HUKS',
    'HUMA',
    'HUTO',
    'K04V',
    'K2F8',
    'K2GL',
    'K3A1',
    'K3A6',
    'K3B2',
    'K3B6',
    'K3DU',
    'K40B',
    'K45J',
    'K47A',
    'K48I',
    'K4BL',
    'K4BM',
    'K4CR',
    'K4HV',
    'K4MY',
    'K4SL',
    'K5J0',
    'K5T6',
    'K6V3',
    'K76S',
    'K77M',
    'K78N',
    'K9BB',
    'KALM',
    'KAQR',
    'KARL',
    'KAUD',
    'KAWG',
    'KAWH',
    'KAXA',
    'KB23',
    'KBID',
    'KBKX',
    'KBNW',
    'KBRX',
    'KCCO',
    'KCMS',
    'KDNK',
    'KDNS',
    'KE33',
    'KECU',
    'KEKA',
    'KEOK',
    'KGBN',
    'KGSM',
    'KH08',
    'KHMS',
    'KILL',
    'KMUT',
    'KNHZ',
    'KNXX',
    'KO87',
    'KOGS',
    'KOQU',
    'KPFN',
    'KPLB',
    'KPNT',
    'KPUM',
    'KQUK',
    'KRPE',
    'KRZZ',
    'KS47',
    'KS58',
    'KSFD',
    'KSIB',
    'KSMN',
    'KSMP',
    'KSRE',
    'KSRN',
    'KTDO',
    'KU24',
    'KU28',
    'KU59',
    'KU78',
    'KVDW',
    'KXCN',
    'KYUM',
    'LFLD',
    'LFLV',
    'LFQI',
    'LFSC',
    'LFSF',
    'LFSR',
    'LICP',
    'LIPT',
    'LKHO',
    'LKLB',
    'LLOV',
    'LOAG',
    'LOGG',
    'LOLF',
    'LOXA',
    'LOXT',
    'LRCS',
    'LTAB',
    'LTAD',
    'LTAE',
    'LTBG',
    'LTBI',
    'LTBL',
    'LTBQ',
    'LZKC',
    'LZLU',
    'LZNI',
    'LZPE',
    'MDHE',
    'MGTK',
    'MUCA',
    'MYEG',
    'NGTA',
    'NLWW',
    'NZOH',
    'OERY',
    'ORBB',
    'ORBS',
    'OSAP',
    'OSDZ',
    'PADT',
    'PAER',
    'PAFE',
    'PAGB',
    'PAHV',
    'PAHZ',
    'PAJC',
    'PAJV',
    'PALK',
    'PALR',
    'PALV',
    'PAMD',
    'PAPC',
    'PAPM',
    'PAPR',
    'PARD',
    'PARL',
    'PASP',
    'PATC',
    'PATW',
    'PAUO',
    'PAWN',
    'PAWR',
    'PAXK',
    'PHHN',
    'PHIK',
    'RJAK',
    'RJBH',
    'RJCJ',
    'RJDM',
    'RJFA',
    'RJFC',
    'RJFE',
    'RJFN',
    'RJFY',
    'RJFZ',
    'RJKB',
    'RJNF',
    'RJNH',
    'RJOE',
    'RJOP',
    'RJOS',
    'RJOZ',
    'RJSH',
    'RJSM',
    'RJSO',
    'RJST',
    'RJSU',
    'RJTA',
    'RJTE',
    'RJTH',
    'RJTJ',
    'RJTL',
    'RKJY',
    'ROKJ',
    'SAAC',
    'SAST',
    'SATR',
    'SAVT',
    'SCCH',
    'SLAS',
    'SLJV',
    'SUAG',
    'SUME',
    'UAFM',
    'UELL',
    'UERP',
    'UERR',
    'UEST',
    'UGGG',
    'ULAA',
    'ULMM',
    'ULOL',
    'ULWW',
    'UNWW',
    'UUEM',
    'UUOO',
    'UWPP',
    'VAGO',
    'VTPM',
    'VTSR',
    'YAYE',
    'FQNP',
    'HUSO',
    'KDPG',
    'KICL',
    'KMYF',
    'KRSV',
  );
  foreach ($removed_icaos as $icao) {
    db_delete('weather_location')
      ->condition('icao', $icao)
      ->execute();
    db_delete('weather_metar')
      ->condition('icao', $icao)
      ->execute();
  }
}

/**
 * Implement hook_update_N().
 *
 * Insert one new location into ICAO table.
 * (Maniwaki, Canada)
 */
function weather_update_7105(&$sandbox) {
  weather_data_installation();
}

Functions

Namesort descending Description
weather_data_installation Helper function for installation and upgrades.
weather_install Implement hook_install().
weather_schema Implement hook_schema().
weather_uninstall Implement hook_uninstall().
weather_update_7000 Removes hardcoded numeric deltas from blocks.
weather_update_7100 Implement hook_update_N().
weather_update_7101 Implement hook_update_N().
weather_update_7102 Implement hook_update_N().
weather_update_7103 Implement hook_update_N().
weather_update_7104 Implement hook_update_N().
weather_update_7105 Implement hook_update_N().
weather_update_last_removed Implement hook_update_last_removed().
_weather_convert_settings Converts settings from 6.x to 7.x module versions.
_weather_convert_units Converts units from 6.x to 7.x module versions.