From c0ba6a21acf79c4bd7dc9cf8b83cd1384a2fca35 Mon Sep 17 00:00:00 2001 From: Rudi Zhang Date: Fri, 5 Apr 2024 12:50:32 +0200 Subject: [PATCH] Fix sequence --- datis.php | 97 +++++++++++++++++++++++++++---------------------------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/datis.php b/datis.php index 048f86a..afea25b 100644 --- a/datis.php +++ b/datis.php @@ -61,12 +61,49 @@ //NOTAM (reserve) +// Wind +print(' WIND '); -// Visibility -if (strpos($rawMetar, 'CAVOK') !== false) { - print(' CAVOK '); +if ($surfaceWindObj->getMeanSpeed()->getValue() == 0) { + print('CALM '); } else { - print(' VIS ' . $visObj->getVisibility()->getValue() . ' M '); + if ($surfaceWindObj->withVariableDirection() == true) { + print('VRB DEG '); + } else { + if ($surfaceWindObj->getMeanDirection()->getValue() < 100) { + print('0'); + } + print($surfaceWindObj->getMeanDirection()->getValue() . ' DEG '); + } + + $raw_sw = $surfaceWindObj->getMeanSpeed()->getValue(); + $int_sw = (int)$raw_sw; + $str_sw = strval($int_sw); + if ($int_sw < 10) { + $out_sw = '0' . $str_sw ; + } else { + $out_sw = $str_sw ; + } + + print($out_sw . ' MPS '); + +} +If ($surfaceWindObj->getSpeedVariations() != null) { + if ($surfaceWindObj->getSpeedVariations()->getValue() < 10) { + print(' GUST 0' . $surfaceWindObj->getSpeedVariations()->getValue() . ' MPS '); + } else { + print(' GUST ' . $surfaceWindObj->getSpeedVariations()->getValue() . ' MPS '); + } +} +if ($surfaceWindObj->getDirectionVariations() != null) { + if ($surfaceWindObj->getDirectionVariations()[0]->getValue() < 100) { + print('0'); + } + print($surfaceWindObj->getDirectionVariations()[0]->getValue() . 'V'); + if ($surfaceWindObj->getDirectionVariations()[1]->getValue() < 100) { + print('0'); + } + print($surfaceWindObj->getDirectionVariations()[1]->getValue() . ' DEG '); } // RVR @@ -99,6 +136,13 @@ } } +// Visibility +if (strpos($rawMetar, 'CAVOK') !== false) { + print(' CAVOK '); +} else { + print(' VIS ' . $visObj->getVisibility()->getValue() . ' M '); +} + // Cloud & Weather Phenomenon if (strpos($rawMetar, 'NSC') === true) { print(' NSC'); @@ -132,51 +176,6 @@ print(' '); } -// Wind -print(' WIND '); - -if ($surfaceWindObj->getMeanSpeed()->getValue() == 0) { - print('CALM '); -} else { - if ($surfaceWindObj->withVariableDirection() == true) { - print('VRB DEG '); - } else { - if ($surfaceWindObj->getMeanDirection()->getValue() < 100) { - print('0'); - } - print($surfaceWindObj->getMeanDirection()->getValue() . ' DEG '); - } - - $raw_sw = $surfaceWindObj->getMeanSpeed()->getValue(); - $int_sw = (int)$raw_sw; - $str_sw = strval($int_sw); - if ($int_sw < 10) { - $out_sw = '0' . $str_sw ; - } else { - $out_sw = $str_sw ; - } - - print($out_sw . ' MPS '); - -} -If ($surfaceWindObj->getSpeedVariations() != null) { - if ($surfaceWindObj->getSpeedVariations()->getValue() < 10) { - print(' GUST 0' . $surfaceWindObj->getSpeedVariations()->getValue() . ' MPS '); - } else { - print(' GUST ' . $surfaceWindObj->getSpeedVariations()->getValue() . ' MPS '); - } -} -if ($surfaceWindObj->getDirectionVariations() != null) { - if ($surfaceWindObj->getDirectionVariations()[0]->getValue() < 100) { - print('0'); - } - print($surfaceWindObj->getDirectionVariations()[0]->getValue() . 'V'); - if ($surfaceWindObj->getDirectionVariations()[1]->getValue() < 100) { - print('0'); - } - print($surfaceWindObj->getDirectionVariations()[1]->getValue() . ' DEG '); -} - // Miscellaneous $temp_data = $decoded->getAirTemperature()->getValue(); $int_temp_data = (int)$temp_data;