You are here

function _weather_parse_temperature in Weather 7

Same name and namespace in other branches
  1. 5.6 weather_parser.inc \_weather_parse_temperature()
  2. 5 weather_parser.inc \_weather_parse_temperature()
  3. 6.5 weather_parser.inc \_weather_parse_temperature()

Extract temperature information.

Parameters

string $metar_raw: Raw METAR data to parse.

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

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

File

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

Code

function _weather_parse_temperature($metar_raw, &$metar) {
  if (preg_match('/^' . '(M?[0-9]{2})' . '\\/' . '(M?[0-9]{2}|XX)?' . '$/', $metar_raw, $matches)) {
    $metar->temperature = (int) strtr($matches[1], 'M', '-');
    if (isset($matches[2]) and $matches[2] != 'XX') {
      $metar->dewpoint = (int) strtr($matches[2], 'M', '-');
    }
    else {
      $metar->dewpoint = NULL;
    }
  }
}