2018-04-05 06:14:46 +08:00
|
|
|
<?php
|
|
|
|
|
2018-04-05 09:59:52 +08:00
|
|
|
use App\Repositories\SettingRepository;
|
|
|
|
use App\Support\Metar;
|
2018-04-05 06:14:46 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the parsing/support class of the metar
|
|
|
|
*/
|
|
|
|
class MetarTest extends TestCase
|
|
|
|
{
|
2018-04-05 09:59:52 +08:00
|
|
|
private $settingsRepo;
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp(); // TODO: Change the autogenerated stub
|
|
|
|
$this->settingsRepo = app(SettingRepository::class);
|
|
|
|
}
|
|
|
|
|
2018-04-05 06:14:46 +08:00
|
|
|
/**
|
|
|
|
* Test adding/subtracting a percentage
|
|
|
|
*/
|
|
|
|
public function testMetar1()
|
|
|
|
{
|
|
|
|
$metar =
|
2018-04-05 09:59:52 +08:00
|
|
|
'KJFK 042151Z 28026G39KT 10SM FEW055 SCT095 BKN110 BKN230 12/M04 A2958 RMK AO2 PK WND 27045/2128 PRESRR SLP018 T01221044';
|
2018-04-05 06:14:46 +08:00
|
|
|
|
2018-04-05 09:59:52 +08:00
|
|
|
#$m = new Metar($metar);
|
|
|
|
#$parsed = $m->result;
|
|
|
|
$parsed = Metar::parse($metar);
|
2018-04-05 06:14:46 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
Conditions VFR visibility 10NM
|
|
|
|
Barometer 1001.58 Hg / 29.58 MB
|
|
|
|
Clouds FEW @ 5500 ft
|
|
|
|
SCT @ 9500 ft
|
|
|
|
BKN @ 11000 ft
|
|
|
|
BKN @ 23000 ft
|
|
|
|
Wind 26 kts @ 280° gusts to 39
|
|
|
|
*/
|
2018-04-05 09:59:52 +08:00
|
|
|
$this->assertEquals('KJFK', $parsed['station']);
|
|
|
|
$this->assertEquals('Wed, 04 Apr 2018 21:51:00 +0000', $parsed['observed_date']);
|
|
|
|
$this->assertEquals(4, $parsed['observed_day']);
|
|
|
|
$this->assertEquals('21:51 UTC', $parsed['observed_time']);
|
|
|
|
#$this->assertEquals('3:42 hr. ago', $parsed['observed_age']);
|
|
|
|
$this->assertEquals(13.38, $parsed['wind_speed']);
|
|
|
|
$this->assertEquals(20.06, $parsed['wind_gust_speed']);
|
|
|
|
$this->assertEquals(280, $parsed['wind_direction']);
|
|
|
|
$this->assertEquals('W', $parsed['wind_direction_label']);
|
|
|
|
$this->assertEquals(false, $parsed['wind_direction_varies']);
|
|
|
|
$this->assertEquals(16093, $parsed['visibility']);
|
|
|
|
$this->assertEquals('16093 meters', $parsed['visibility_report']);
|
|
|
|
$this->assertEquals('Dry', $parsed['present_weather_report']);
|
|
|
|
|
|
|
|
$this->assertCount(4, $parsed['clouds']);
|
|
|
|
$this->assertEquals(
|
|
|
|
'A few at 1676 meters; scattered at 2896 meters; broken sky at 3353 meters; broken sky at 7010 meters',
|
|
|
|
$parsed['clouds_report']);
|
|
|
|
$this->assertEquals(1676, $parsed['cloud_height']);
|
|
|
|
$this->assertEquals(false, $parsed['cavok']);
|
|
|
|
|
|
|
|
$this->assertEquals(12, $parsed['temperature']);
|
|
|
|
$this->assertEquals(54, $parsed['temperature_f']);
|
|
|
|
|
|
|
|
$this->assertEquals(-4, $parsed['dew_point']);
|
|
|
|
$this->assertEquals(25, $parsed['dew_point_f']);
|
|
|
|
|
|
|
|
$this->assertEquals(33, $parsed['humidity']);
|
|
|
|
$this->assertEquals(29.58, $parsed['barometer']);
|
|
|
|
$this->assertEquals(0.87, $parsed['barometer_in']);
|
|
|
|
|
|
|
|
$this->assertEquals('AO2 PK WND 27045/2128 PRESRR SLP018 T01221044', $parsed['remarks']);
|
|
|
|
|
2018-04-05 06:14:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testMetar2()
|
|
|
|
{
|
|
|
|
$metar =
|
2018-04-07 22:05:06 +08:00
|
|
|
'KJFK 070151Z 20005KT 10SM BKN100 08/07 A2970 RMK AO2 SLP056 T00780067';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* John F.Kennedy International, New York, NY (KJFK). Apr 7, 0151Z. Wind from 200° at 5 knots,
|
|
|
|
* 10 statute miles visibility, Ceiling is Broken at 10,000 feet, Temperature 8°C, Dewpoint 7°C,
|
|
|
|
* Altimeter is 29.70. Remarks: automated station with precipitation discriminator sea level
|
|
|
|
* pressure 1005.6 hectopascals hourly temp 7.8°C dewpoint 6.7°C
|
|
|
|
*/
|
|
|
|
|
|
|
|
$parsed = Metar::parse($metar);
|
2018-04-05 06:14:46 +08:00
|
|
|
}
|
|
|
|
}
|