Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Metar Decoding / Wind check for Wind Chill #1072

Merged
merged 5 commits into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Support/Metar.php
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,7 @@ private function calculate_heat_index($temperature_f, $rh): void
*/
private function calculate_wind_chill($temperature_f): void
{
if ($temperature_f < 51 && $this->result['wind_speed'] !== 0) {
if ($temperature_f < 51 && $this->result['wind_speed'] && $this->result['wind_speed'] !== 0) {
$windspeed = $this->result['wind_speed']->toUnit('mph');
if ($windspeed > 3) {
$chill_f = 35.74 + 0.6215 * $temperature_f - 35.75 * ($windspeed ** 0.16);
Expand Down
13 changes: 13 additions & 0 deletions tests/MetarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@ public function testMetar4Clouds()
$this->assertEquals('Few at 1500 feet; few at 25000 feet', $metar['clouds_report_ft']);
}

/**
* https://github.com/nabeelio/phpvms/issues/1071
*/
public function testMetarWindSpeedChill()
{
$metar = 'EKYT 091020Z /////KT CAVOK 02/M03 Q1019';
$metar = Metar::parse($metar);

$this->assertEquals('VFR', $metar['category']);
$this->assertNull($metar['wind_speed']);
$this->assertEquals(6.21, $metar['visibility']['mi']);
}

/**
* Visibility in KM not parsed
*
Expand Down