Replace METAR data with custom class

This commit is contained in:
Nabeel Shahzad
2018-04-07 09:05:06 -05:00
parent f4f41cd900
commit eae5989845
6 changed files with 151 additions and 163 deletions

View File

@@ -41,6 +41,7 @@ class Metar
'observed_day' => null, 'observed_day' => null,
'observed_time' => null, 'observed_time' => null,
'observed_age' => null, 'observed_age' => null,
'category' => null,
'wind_speed' => null, 'wind_speed' => null,
'wind_gust_speed' => null, 'wind_gust_speed' => null,
'wind_direction' => null, 'wind_direction' => null,
@@ -63,6 +64,7 @@ class Metar
'clouds_report' => null, 'clouds_report' => null,
'clouds_report_ft' => null, 'clouds_report_ft' => null,
'cloud_height' => null, 'cloud_height' => null,
'cloud_height_ft' => null,
'cavok' => null, 'cavok' => null,
'temperature' => null, 'temperature' => null,
'temperature_f' => null, 'temperature_f' => null,
@@ -75,6 +77,7 @@ class Metar
'wind_chill_f' => null, 'wind_chill_f' => null,
'barometer' => null, 'barometer' => null,
'barometer_in' => null, 'barometer_in' => null,
'barometer_mb' => null,
'recent_weather' => null, 'recent_weather' => null,
'recent_weather_report' => null, 'recent_weather_report' => null,
'runways_report' => null, 'runways_report' => null,
@@ -428,6 +431,16 @@ class Metar
} }
} }
// Finally determine if it's VFR or IFR conditions
// https://www.aviationweather.gov/cva/help
if($this->result['cavok']
|| ($this->result['cloud_height_ft'] > 3000 && $this->result['visibility_nm'] > 5))
{
$this->result['category'] = 'VFR';
} else {
$this->result['category'] = 'IFR';
}
return $this->result; return $this->result;
} }
@@ -951,6 +964,7 @@ class Metar
// Cloud height // Cloud height
if (null === $this->result['cloud_height'] || $observed['height'] < $this->result['cloud_height']) { if (null === $this->result['cloud_height'] || $observed['height'] < $this->result['cloud_height']) {
$this->set_result_value('cloud_height', $observed['height']); $this->set_result_value('cloud_height', $observed['height']);
$this->set_result_value('cloud_height_ft', $observed['height_ft']);
} }
if (isset(static::$cloud_codes[$found[4]])) { if (isset(static::$cloud_codes[$found[4]])) {
@@ -1061,6 +1075,7 @@ class Metar
} }
$this->set_result_value('barometer', $pressure); // units are hPa $this->set_result_value('barometer', $pressure); // units are hPa
$this->set_result_value('barometer_mb', $pressure); // units are hPa
$this->set_result_value('barometer_in', round(0.02953 * $pressure, 2)); // convert to in Hg $this->set_result_value('barometer_in', round(0.02953 * $pressure, 2)); // convert to in Hg
$this->method++; $this->method++;

View File

@@ -3,13 +3,7 @@
namespace App\Widgets; namespace App\Widgets;
use App\Interfaces\Widget; use App\Interfaces\Widget;
use App\Support\Http; use App\Support\Metar;
use App\Support\MetarWrapper;
use App\Support\Units\Distance;
use App\Support\Units\Temperature;
use Illuminate\Support\Facades\Cache;
use MetarDecoder\MetarDecoder;
use SimpleXMLElement;
/** /**
* This is a widget for the 3rd party CheckWX service * This is a widget for the 3rd party CheckWX service
@@ -23,17 +17,6 @@ class Weather extends Widget
public const URL = 'https://avwx.rest/api/metar/'; public const URL = 'https://avwx.rest/api/metar/';
/**
* Determine the category depending on the rules for visibility/ceiling
* https://www.aviationweather.gov/cva/help
* @param $metar
* @return string
*/
protected function determineCategory($metar): string
{
}
/** /**
* Attempt to get the data from the CheckWX API * Attempt to get the data from the CheckWX API
*/ */
@@ -50,14 +33,12 @@ class Weather extends Widget
$raw_metar = $metar_class->get_metar($this->config['icao']); $raw_metar = $metar_class->get_metar($this->config['icao']);
if ($raw_metar && $raw_metar !== '') { if ($raw_metar && $raw_metar !== '') {
$metar = new MetarWrapper($raw_metar); $metar = Metar::parse($raw_metar);
$wind = $metar->getWinds();
} }
return view('widgets.weather', [ return view('widgets.weather', [
'config' => $this->config, 'config' => $this->config,
'metar' => $metar, 'metar' => $metar,
'wind' => $wind,
'unit_alt' => setting('units.altitude'), 'unit_alt' => setting('units.altitude'),
'unit_dist' => setting('units.distance'), 'unit_dist' => setting('units.distance'),
'unit_temp' => setting('units.temperature'), 'unit_temp' => setting('units.temperature'),

View File

@@ -38,8 +38,7 @@
"akaunting/money": "^1.0", "akaunting/money": "^1.0",
"igaster/laravel-theme": "^2.0", "igaster/laravel-theme": "^2.0",
"anhskohbo/no-captcha": "^3.0", "anhskohbo/no-captcha": "^3.0",
"league/csv": "^9.1", "league/csv": "^9.1"
"safran-cassiopee/php-metar-decoder": "^0.7.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~7.0", "phpunit/phpunit": "~7.0",

188
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "fd9f4121a32ed91cda47e6f5a5df3bd8", "content-hash": "60281a4e1830c6c5a9a9338b02936d30",
"packages": [ "packages": [
{ {
"name": "akaunting/money", "name": "akaunting/money",
@@ -619,23 +619,23 @@
}, },
{ {
"name": "dragonmantank/cron-expression", "name": "dragonmantank/cron-expression",
"version": "v2.0.0", "version": "v2.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/dragonmantank/cron-expression.git", "url": "https://github.com/dragonmantank/cron-expression.git",
"reference": "8a84aee649c3a3ba03a721c1fb080e08dfbcd68b" "reference": "3f00985deec8df53d4cc1e5c33619bda1ee309a5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/8a84aee649c3a3ba03a721c1fb080e08dfbcd68b", "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/3f00985deec8df53d4cc1e5c33619bda1ee309a5",
"reference": "8a84aee649c3a3ba03a721c1fb080e08dfbcd68b", "reference": "3f00985deec8df53d4cc1e5c33619bda1ee309a5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.0.0" "php": ">=7.0.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~5.7" "phpunit/phpunit": "~6.4"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@@ -664,7 +664,7 @@
"cron", "cron",
"schedule" "schedule"
], ],
"time": "2017-10-12T15:59:13+00:00" "time": "2018-04-06T15:51:55+00:00"
}, },
{ {
"name": "egulias/email-validator", "name": "egulias/email-validator",
@@ -1651,16 +1651,16 @@
}, },
{ {
"name": "league/flysystem", "name": "league/flysystem",
"version": "1.0.43", "version": "1.0.44",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/flysystem.git", "url": "https://github.com/thephpleague/flysystem.git",
"reference": "1ce7cc142d906ba58dc54c82915d355a9191c8a8" "reference": "168dbe519737221dc87d17385cde33073881fd02"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/1ce7cc142d906ba58dc54c82915d355a9191c8a8", "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/168dbe519737221dc87d17385cde33073881fd02",
"reference": "1ce7cc142d906ba58dc54c82915d355a9191c8a8", "reference": "168dbe519737221dc87d17385cde33073881fd02",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1731,7 +1731,7 @@
"sftp", "sftp",
"storage" "storage"
], ],
"time": "2018-03-01T10:27:04+00:00" "time": "2018-04-06T09:58:14+00:00"
}, },
{ {
"name": "league/geotools", "name": "league/geotools",
@@ -2214,16 +2214,16 @@
}, },
{ {
"name": "paragonie/random_compat", "name": "paragonie/random_compat",
"version": "v2.0.11", "version": "v2.0.12",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/paragonie/random_compat.git", "url": "https://github.com/paragonie/random_compat.git",
"reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8" "reference": "258c89a6b97de7dfaf5b8c7607d0478e236b04fb"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/5da4d3c796c275c55f057af5a643ae297d96b4d8", "url": "https://api.github.com/repos/paragonie/random_compat/zipball/258c89a6b97de7dfaf5b8c7607d0478e236b04fb",
"reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8", "reference": "258c89a6b97de7dfaf5b8c7607d0478e236b04fb",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -2241,7 +2241,7 @@
"lib/random.php" "lib/random.php"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -2258,7 +2258,7 @@
"pseudorandom", "pseudorandom",
"random" "random"
], ],
"time": "2017-09-27T21:40:39+00:00" "time": "2018-04-04T21:24:14+00:00"
}, },
{ {
"name": "php-http/discovery", "name": "php-http/discovery",
@@ -3005,46 +3005,6 @@
], ],
"time": "2017-03-25T12:08:31+00:00" "time": "2017-03-25T12:08:31+00:00"
}, },
{
"name": "safran-cassiopee/php-metar-decoder",
"version": "v0.7",
"source": {
"type": "git",
"url": "https://github.com/SafranCassiopee/php-metar-decoder.git",
"reference": "ed920c93a6025af9bf6787af7683246c37b1d648"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/SafranCassiopee/php-metar-decoder/zipball/ed920c93a6025af9bf6787af7683246c37b1d648",
"reference": "ed920c93a6025af9bf6787af7683246c37b1d648",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "4.3.*"
},
"type": "library",
"autoload": {
"psr-4": {
"MetarDecoder\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-3.0+"
],
"authors": [
{
"name": "Edouard de Labareyre",
"email": "edouard@melix.net",
"role": "Developer"
}
],
"description": "METAR weather observation decoder",
"time": "2016-03-18T21:37:22+00:00"
},
{ {
"name": "santigarcor/laratrust", "name": "santigarcor/laratrust",
"version": "5.0.9", "version": "5.0.9",
@@ -3290,7 +3250,7 @@
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
@@ -3358,7 +3318,7 @@
}, },
{ {
"name": "symfony/css-selector", "name": "symfony/css-selector",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/css-selector.git", "url": "https://github.com/symfony/css-selector.git",
@@ -3411,7 +3371,7 @@
}, },
{ {
"name": "symfony/debug", "name": "symfony/debug",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/debug.git", "url": "https://github.com/symfony/debug.git",
@@ -3467,7 +3427,7 @@
}, },
{ {
"name": "symfony/dom-crawler", "name": "symfony/dom-crawler",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/dom-crawler.git", "url": "https://github.com/symfony/dom-crawler.git",
@@ -3523,16 +3483,16 @@
}, },
{ {
"name": "symfony/event-dispatcher", "name": "symfony/event-dispatcher",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/event-dispatcher.git", "url": "https://github.com/symfony/event-dispatcher.git",
"reference": "85eaf6a8ec915487abac52e133efc4a268204428" "reference": "63353a71073faf08f62caab4e6889b06a787f07b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/85eaf6a8ec915487abac52e133efc4a268204428", "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/63353a71073faf08f62caab4e6889b06a787f07b",
"reference": "85eaf6a8ec915487abac52e133efc4a268204428", "reference": "63353a71073faf08f62caab4e6889b06a787f07b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -3582,20 +3542,20 @@
], ],
"description": "Symfony EventDispatcher Component", "description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2018-02-14T14:11:10+00:00" "time": "2018-04-06T07:35:43+00:00"
}, },
{ {
"name": "symfony/finder", "name": "symfony/finder",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/finder.git", "url": "https://github.com/symfony/finder.git",
"reference": "c72995d9f5999b3fcdd8660c0c9690243252e1e1" "reference": "ca27c02b7a3fef4828c998c2ff9ba7aae1641c49"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/c72995d9f5999b3fcdd8660c0c9690243252e1e1", "url": "https://api.github.com/repos/symfony/finder/zipball/ca27c02b7a3fef4828c998c2ff9ba7aae1641c49",
"reference": "c72995d9f5999b3fcdd8660c0c9690243252e1e1", "reference": "ca27c02b7a3fef4828c998c2ff9ba7aae1641c49",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -3631,11 +3591,11 @@
], ],
"description": "Symfony Finder Component", "description": "Symfony Finder Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2018-04-02T09:52:41+00:00" "time": "2018-04-04T05:10:37+00:00"
}, },
{ {
"name": "symfony/http-foundation", "name": "symfony/http-foundation",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-foundation.git", "url": "https://github.com/symfony/http-foundation.git",
@@ -3688,16 +3648,16 @@
}, },
{ {
"name": "symfony/http-kernel", "name": "symfony/http-kernel",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-kernel.git", "url": "https://github.com/symfony/http-kernel.git",
"reference": "38337d03a554a2b0e9f553d368723692b7c04a8f" "reference": "6dd620d96d64456075536ffe3c6c4658dd689021"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/38337d03a554a2b0e9f553d368723692b7c04a8f", "url": "https://api.github.com/repos/symfony/http-kernel/zipball/6dd620d96d64456075536ffe3c6c4658dd689021",
"reference": "38337d03a554a2b0e9f553d368723692b7c04a8f", "reference": "6dd620d96d64456075536ffe3c6c4658dd689021",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -3770,11 +3730,11 @@
], ],
"description": "Symfony HttpKernel Component", "description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2018-04-03T06:20:33+00:00" "time": "2018-04-06T16:25:03+00:00"
}, },
{ {
"name": "symfony/inflector", "name": "symfony/inflector",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/inflector.git", "url": "https://github.com/symfony/inflector.git",
@@ -3945,7 +3905,7 @@
}, },
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/process.git", "url": "https://github.com/symfony/process.git",
@@ -3994,7 +3954,7 @@
}, },
{ {
"name": "symfony/property-access", "name": "symfony/property-access",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/property-access.git", "url": "https://github.com/symfony/property-access.git",
@@ -4061,16 +4021,16 @@
}, },
{ {
"name": "symfony/routing", "name": "symfony/routing",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/routing.git", "url": "https://github.com/symfony/routing.git",
"reference": "ca780c838046bfef4a6fd50284ae71a5d1f1a8b2" "reference": "0663036dd57dbfd4e9ff29f75bbd5dd3253ebe71"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/ca780c838046bfef4a6fd50284ae71a5d1f1a8b2", "url": "https://api.github.com/repos/symfony/routing/zipball/0663036dd57dbfd4e9ff29f75bbd5dd3253ebe71",
"reference": "ca780c838046bfef4a6fd50284ae71a5d1f1a8b2", "reference": "0663036dd57dbfd4e9ff29f75bbd5dd3253ebe71",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -4135,11 +4095,11 @@
"uri", "uri",
"url" "url"
], ],
"time": "2018-04-02T09:52:41+00:00" "time": "2018-04-04T13:50:32+00:00"
}, },
{ {
"name": "symfony/serializer", "name": "symfony/serializer",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/serializer.git", "url": "https://github.com/symfony/serializer.git",
@@ -4217,7 +4177,7 @@
}, },
{ {
"name": "symfony/translation", "name": "symfony/translation",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/translation.git", "url": "https://github.com/symfony/translation.git",
@@ -4285,16 +4245,16 @@
}, },
{ {
"name": "symfony/var-dumper", "name": "symfony/var-dumper",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/var-dumper.git", "url": "https://github.com/symfony/var-dumper.git",
"reference": "f9b257f2009c7f09166bcfd3d3d96455741ed371" "reference": "e1b4d008100f4d203cc38b0d793ad6252d8d8af0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/f9b257f2009c7f09166bcfd3d3d96455741ed371", "url": "https://api.github.com/repos/symfony/var-dumper/zipball/e1b4d008100f4d203cc38b0d793ad6252d8d8af0",
"reference": "f9b257f2009c7f09166bcfd3d3d96455741ed371", "reference": "e1b4d008100f4d203cc38b0d793ad6252d8d8af0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -4350,11 +4310,11 @@
"debug", "debug",
"dump" "dump"
], ],
"time": "2018-04-03T05:24:00+00:00" "time": "2018-04-04T05:10:37+00:00"
}, },
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
"version": "v4.0.7", "version": "v4.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/yaml.git", "url": "https://github.com/symfony/yaml.git",
@@ -5892,16 +5852,16 @@
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "6.0.1", "version": "6.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "f8ca4b604baf23dab89d87773c28cc07405189ba" "reference": "774a82c0c5da4c1c7701790c262035d235ab7856"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f8ca4b604baf23dab89d87773c28cc07405189ba", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/774a82c0c5da4c1c7701790c262035d235ab7856",
"reference": "f8ca4b604baf23dab89d87773c28cc07405189ba", "reference": "774a82c0c5da4c1c7701790c262035d235ab7856",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -5912,7 +5872,7 @@
"phpunit/php-text-template": "^1.2.1", "phpunit/php-text-template": "^1.2.1",
"phpunit/php-token-stream": "^3.0", "phpunit/php-token-stream": "^3.0",
"sebastian/code-unit-reverse-lookup": "^1.0.1", "sebastian/code-unit-reverse-lookup": "^1.0.1",
"sebastian/environment": "^3.0", "sebastian/environment": "^3.1",
"sebastian/version": "^2.0.1", "sebastian/version": "^2.0.1",
"theseer/tokenizer": "^1.1" "theseer/tokenizer": "^1.1"
}, },
@@ -5951,7 +5911,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2018-02-02T07:01:41+00:00" "time": "2018-04-06T15:39:20+00:00"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
@@ -6141,16 +6101,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "7.0.3", "version": "7.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "536f4d853c12d8189963435088e8ff7c0daeab2e" "reference": "f7fe5127889519e421600fe0feeb113a5e210f20"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/536f4d853c12d8189963435088e8ff7c0daeab2e", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f7fe5127889519e421600fe0feeb113a5e210f20",
"reference": "536f4d853c12d8189963435088e8ff7c0daeab2e", "reference": "f7fe5127889519e421600fe0feeb113a5e210f20",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -6168,7 +6128,7 @@
"phpunit/php-file-iterator": "^1.4.3", "phpunit/php-file-iterator": "^1.4.3",
"phpunit/php-text-template": "^1.2.1", "phpunit/php-text-template": "^1.2.1",
"phpunit/php-timer": "^2.0", "phpunit/php-timer": "^2.0",
"phpunit/phpunit-mock-objects": "^6.0", "phpunit/phpunit-mock-objects": "^6.1",
"sebastian/comparator": "^2.1", "sebastian/comparator": "^2.1",
"sebastian/diff": "^3.0", "sebastian/diff": "^3.0",
"sebastian/environment": "^3.1", "sebastian/environment": "^3.1",
@@ -6191,7 +6151,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "7.0-dev" "dev-master": "7.1-dev"
} }
}, },
"autoload": { "autoload": {
@@ -6217,20 +6177,20 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2018-03-26T07:36:48+00:00" "time": "2018-04-06T12:39:30+00:00"
}, },
{ {
"name": "phpunit/phpunit-mock-objects", "name": "phpunit/phpunit-mock-objects",
"version": "6.0.1", "version": "6.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "e3249dedc2d99259ccae6affbc2684eac37c2e53" "reference": "3f5ca97eee66a07951d018f6726017629c85c86d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/e3249dedc2d99259ccae6affbc2684eac37c2e53", "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3f5ca97eee66a07951d018f6726017629c85c86d",
"reference": "e3249dedc2d99259ccae6affbc2684eac37c2e53", "reference": "3f5ca97eee66a07951d018f6726017629c85c86d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -6248,7 +6208,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "6.0.x-dev" "dev-master": "6.1-dev"
} }
}, },
"autoload": { "autoload": {
@@ -6273,7 +6233,7 @@
"mock", "mock",
"xunit" "xunit"
], ],
"time": "2018-02-15T05:27:38+00:00" "time": "2018-04-06T08:14:40+00:00"
}, },
{ {
"name": "sebastian/code-unit-reverse-lookup", "name": "sebastian/code-unit-reverse-lookup",
@@ -6840,7 +6800,7 @@
}, },
{ {
"name": "symfony/class-loader", "name": "symfony/class-loader",
"version": "v3.4.7", "version": "v3.4.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/class-loader.git", "url": "https://github.com/symfony/class-loader.git",

View File

@@ -11,39 +11,57 @@ https://api.checkwx.com/#metar-decoded
<tr> <tr>
<td>Conditions</td> <td>Conditions</td>
<td> <td>
{{ $metar->getCategory() }} {{ $metar['category'] }}
@if($metar->getTemperature()) &nbsp;
&nbsp; @if($unit_temp === 'c')
{{$metar->getTemperature()}}°{{strtoupper($unit_temp)}} {{$metar['temperature']}}
,&nbsp; @else
{{$metar['temperature_f']}}
@endif @endif
°{{strtoupper($unit_temp)}}
@if($metar['visibility'])
,&nbsp;
visibility visibility
{{$metar->getVisibility()}}{{$unit_dist}} @if($unit_dist === 'km')
{{$metar['visibility'] / 1000}}
@else
{{$metar['visibility_nm']}}
@endif
@endif
{{$unit_dist}}
@if($metar['humidity'])
,&nbsp;
{{ $metar['humidity'] }}% humidity
@endif
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Barometer</td> <td>Barometer</td>
<td>{{ $metar->getPressure('hg') }} Hg
/ {{ $metar->getPressure('mb') }} MB
</td>
</tr>
<tr>
<td>Clouds</td>
<td> <td>
@foreach($metar->getClouds() as $cloud) {{ $metar['barometer'] }} Hg
<p> / {{ $metar['barometer_in'] * 1000 }} MB
{{$cloud['amount']}} @ {{$cloud['base_height']}} {{ $unit_alt }}
</p>
@endforeach
</td> </td>
</tr> </tr>
@if($metar['clouds'])
<tr>
<td>Clouds</td>
<td>
@if($unit_alt === 'ft')
{{$metar['clouds_report_ft']}}
@else
{{ $metar['clouds_report'] }}
@endif
</td>
</tr>
@endif
<tr> <tr>
<td>Wind</td> <td>Wind</td>
<td> <td>
{{$wind['speed']}} kts {{$metar['wind_speed']}} kts from {{$metar['wind_direction_label']}}
@ {{$wind['direction']}}° ({{$metar['wind_direction']}}°)
@if($wind['gusts']) @if($metar['wind_gust_speed'])
gusts to {{$wind['gusts']}} gusts to {{ $metar['wind_gust_speed'] }}
@endif @endif
</td> </td>
</tr> </tr>
@@ -51,13 +69,21 @@ https://api.checkwx.com/#metar-decoded
<td>METAR</td> <td>METAR</td>
<td> <td>
<div style="line-height:1.5em;min-height: 3em;"> <div style="line-height:1.5em;min-height: 3em;">
{{ $metar->getRawMetar() }} {{ $metar['raw'] }}
</div> </div>
</td> </td>
</tr> </tr>
@if($metar['remarks'])
<tr>
<td>Remarks</td>
<td>
{{ $metar['remarks'] }}
</td>
</tr>
@endif
<tr> <tr>
<td>Updated</td> <td>Updated</td>
<td>{{$metar->getLastUpdate()}}</td> <td>{{$metar['observed_time']}} ({{$metar['observed_age']}})</td>
</tr> </tr>
</table> </table>
@endif @endif

View File

@@ -75,8 +75,15 @@ class MetarTest extends TestCase
public function testMetar2() public function testMetar2()
{ {
$metar = $metar =
'CYWG 172000Z 30015G25KT 3/4SM R36/4000FT/D -SN ' 'KJFK 070151Z 20005KT 10SM BKN100 08/07 A2970 RMK AO2 SLP056 T00780067';
.'BLSN BKN008 OVC040 M05/M08 A2992 REFZRA WS RWY36 '
.'RMK SF5NS3 SLP134'; /**
* 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);
} }
} }