You are here

function _weather_construct_image_filename in Weather 7

Construct filename of the weather image.

Parameters

object $metar: METAR data object, may be altered.

1 call to _weather_construct_image_filename()
weather_parse_metar in ./weather_parser.inc
Parses a raw METAR data string.

File

./weather_parser.inc, line 684
Retrieves and parses raw METAR data and stores result in database.

Code

function _weather_construct_image_filename(&$metar) {

  // Is there any data available?
  if (empty($metar->sky_condition)) {
    $metar->image = 'nodata';
  }
  else {

    // First part: daytime (day/night).
    $image_part[] = $metar->daytime_condition;

    // Next part: sky condition
    // Handle special case: NSC, we just use few for the display.
    if ($metar->sky_condition == 'no significant clouds') {
      $image_part[] = 'few';
    }
    else {
      $image_part[] = $metar->sky_condition;
    }

    // Next part: fog.
    if (isset($metar->image_part['fog'])) {
      $image_part[] = $metar->image_part['fog'];
    }

    // Next part: precipitation.
    if (isset($metar->image_part['precipitation'])) {
      $image_part[] = $metar->image_part['precipitation'];
    }
    $metar->image = implode('-', $image_part);
  }
}