You are here

function _weather_create_weather_array in Weather 7.3

Same name and namespace in other branches
  1. 7.2 weather_parser.inc \_weather_create_weather_array()

Create a weather array with the forecast data from database.

Parameters

array $forecasts: Raw forecast data from database.

Return value

array Weather array with forecast information.

1 call to _weather_create_weather_array()
weather_get_forecasts_from_database in ./weather_parser.inc
Try to fetch forecasts from the database.

File

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

Code

function _weather_create_weather_array($forecasts) {
  $weather = array();

  // Cycle through all forecasts and set up a hierarchical array structure.
  foreach ($forecasts as $forecast) {
    list($day_from, $time_from) = explode(' ', $forecast->time_from);
    $time_range = substr($time_from, 0, 5);
    list($day_to, $time_to) = explode(' ', $forecast->time_to);
    $time_range .= '-' . substr($time_to, 0, 5);
    $weather[$day_from][$time_range] = array(
      'period' => $forecast->period,
      'symbol' => $forecast->symbol,
      'precipitation' => $forecast->precipitation,
      'wind_direction' => $forecast->wind_direction,
      'wind_speed' => $forecast->wind_speed,
      'temperature' => $forecast->temperature,
      'pressure' => $forecast->pressure,
    );
  }
  return $weather;
}