You are here

function _weather_parse_pressure in Weather 7

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

Extract pressure information.

Parameters

string $metar_raw: Raw METAR data to parse.

object $metar: METAR data object, may 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 570
Retrieves and parses raw METAR data and stores result in database.

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 = round($matches[2] / 100 * 33.8639, 0);
    }
    else {

      // Pressure is given in HektoPascal, hPa
      $metar->pressure = (int) $matches[2];
    }
  }
}