public function parse($remaining_metar, $cavok = false) { $result = $this->consume($remaining_metar); $found = $result['found']; $new_remaining_metar = $result['remaining']; // handle the case where nothing has been found and metar is not cavok if ($found == null && !$cavok) { throw new ChunkDecoderException($remaining_metar, $new_remaining_metar, 'Bad format for clouds information', $this); } // default case: CAVOK or clear sky, no cloud layer $result = array('clouds' => array()); // there are clouds, handle cloud layers and visibility if ($found != null && $found[2] == null) { for ($i = 3; $i <= 15; $i += 4) { if ($found[$i] != null) { $layer = new CloudLayer(); $layer_height = Value::toInt($found[$i + 2]); if ($layer_height !== null) { $layer_height_ft = $layer_height * 100; } else { $layer_height_ft = null; } $layer->setChunk(trim($found[$i])); $layer->setAmount($found[$i + 1])->setBaseHeight(Value::newValue($layer_height_ft, Value::FEET))->setType($found[$i + 3]); $result['clouds'][] = $layer; } } } // return result + remaining metar return array('result' => $result, 'remaining_metar' => $new_remaining_metar); }
public function parse($remaining_metar, $cavok = false) { $result = $this->consume($remaining_metar); $found = $result['found']; $new_remaining_metar = $result['remaining']; // handle the case where nothing has been found if ($found == null) { $result = null; } else { // detect if we have windshear on all runway or only one if ($found[1] == 'WS ALL RWY') { $all = true; $runways = null; } else { // one or more runways, build array $all = false; $runways = array(); for ($k = 2; $k < 9; $k += 3) { if ($found[$k] != null) { $runway = $found[$k + 2]; $qfu_as_int = Value::toInt($runway); // check runway qfu validity if ($qfu_as_int > 36 || $qfu_as_int < 1) { throw new ChunkDecoderException($remaining_metar, $new_remaining_metar, 'Invalid runway QFU runway visual range information', $this); } $runways[] = $runway; } } } $result = array('windshearAllRunways' => $all, 'windshearRunways' => $runways); } // return result + remaining metar return array('result' => $result, 'remaining_metar' => $new_remaining_metar); }
public function parse($remaining_metar, $cavok = false) { $result = $this->consume($remaining_metar); $found = $result['found']; $new_remaining_metar = $result['remaining']; // handle the case where nothing has been found if ($found == null) { $result = null; } else { // iterate on the results to get all runways visual range found $runways = array(); for ($i = 1; $i <= 20; $i += 7) { if ($found[$i] != null) { // check runway qfu validity $qfu_as_int = Value::toInt($found[$i + 1]); if ($qfu_as_int > 36 || $qfu_as_int < 1) { throw new ChunkDecoderException($remaining_metar, $new_remaining_metar, 'Invalid runway QFU runway visual range information', $this); } // get distance unit if ($found[$i + 5] == 'FT') { $range_unit = Value::FEET; } else { $range_unit = Value::METER; } $observation = new RunwayVisualRange(); $observation->setChunk(trim($found[$i])); $observation->setRunway($found[$i + 1])->setPastTendency($found[$i + 6]); if ($found[$i + 3] != null) { $interval = array(Value::newIntValue($found[$i + 3], $range_unit), Value::newIntValue($found[$i + 4], $range_unit)); $observation->setVariable(true)->setVisualRangeInterval($interval); } else { $observation->setVariable(false)->setVisualRange(Value::newIntValue($found[$i + 4], $range_unit)); } $runways[] = $observation; } } $result = array('runwaysVisualRange' => $runways); } // return result + remaining metar return array('result' => $result, 'remaining_metar' => $new_remaining_metar); }
public function parse($remaining_metar, $cavok = false) { $result = $this->consume($remaining_metar); $found = $result['found']; $new_remaining_metar = $result['remaining']; // throw error if nothing has been found if ($found == null) { throw new ChunkDecoderException($remaining_metar, $new_remaining_metar, 'Atmospheric pressure not found', $this); } $raw_value = Value::toInt($found[2]); $type = $found[1]; // convert value if needed if ($type == 'A') { $raw_value = $raw_value / 100; } $value = Value::newValue($raw_value, $this->units[$type]); // retrieve found params $result = array('pressure' => $value); // return result + remaining metar return array('result' => $result, 'remaining_metar' => $new_remaining_metar); }