You are here

function _weather_parse_pressure in Weather 5

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

Extract the pressure information

Parameters

string Raw METAR data to parse:

array Parsed METAR data, will be altered:

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

File

./weather_parser.inc, line 340

Code

function _weather_parse_pressure($metar_raw, &$metar) {
  if (preg_match('/^' . '(A|Q)([0-9]{4})' . '$/', $metar_raw, $matches)) {
    if ($matches[1] == 'A') {

      // Pressure is given in inch Hg
      $metar['pressure']['inHg'] = $matches[2] / 100;
      $metar['pressure']['hPa'] = round(33.8639 * $metar['pressure']['inHg'], 0);
    }
    else {

      // Pressure is given in HektoPascal, hPa
      $metar['pressure']['hPa'] = (int) $matches[2];
      $metar['pressure']['inHg'] = round($metar['pressure']['hPa'] * 0.02953, 2);
    }
  }
}