Metar: TEMPO and trend causing issue with values being overwritten (#862)
Metar: TEMPO and trend causing issue with values being overwritten
This commit is contained in:
parent
c702b01a87
commit
48087fb05f
@ -515,7 +515,7 @@ class Metar implements \ArrayAccess
|
||||
// Delete null values from the TAF report
|
||||
if ($this->result['taf'] === true) {
|
||||
foreach ($this->result as $parameter => $value) {
|
||||
if (!$value) {
|
||||
if ($value === null) {
|
||||
unset($this->result[$parameter]);
|
||||
}
|
||||
}
|
||||
@ -530,7 +530,8 @@ class Metar implements \ArrayAccess
|
||||
} else {
|
||||
/* @noinspection NestedPositiveIfStatementsInspection */
|
||||
if (array_key_exists('cloud_height', $this->result) && $this->result['cloud_height'] !== null) {
|
||||
if ($this->result['cloud_height']['ft'] > 3000 && $this->result['visibility']['nmi'] > 5) {
|
||||
if ($this->result['cloud_height']['ft'] > 3000
|
||||
&& (empty($this->result['visibility']) || $this->result['visibility']['nmi'] > 5)) {
|
||||
$this->result['category'] = 'VFR';
|
||||
} else {
|
||||
$this->result['category'] = 'IFR';
|
||||
@ -868,11 +869,11 @@ class Metar implements \ArrayAccess
|
||||
$this->set_result_value('cavok', false, true);
|
||||
|
||||
// Cloud and visibilty OK or ICAO visibilty greater than 10 km
|
||||
if ($found[1] === 'CAVOK' || $found[1] === '9999') {
|
||||
if (strtoupper($found[1]) === 'CAVOK' || $found[1] === '9999') {
|
||||
$this->set_result_value('visibility', $this->createDistance(10000, 'm'));
|
||||
$this->set_result_value('visibility_report', 'Greater than 10 km');
|
||||
/* @noinspection NotOptimalIfConditionsInspection */
|
||||
if ($found[1] === 'CAVOK') {
|
||||
if (strtoupper($found[1]) === 'CAVOK') {
|
||||
$this->set_result_value('cavok', true);
|
||||
$this->method += 4; // can skip the next 4 methods: visibility_min, runway_vr, present_weather, clouds
|
||||
}
|
||||
@ -1484,6 +1485,8 @@ class Metar implements \ArrayAccess
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ignore trends
|
||||
return true;
|
||||
// Detects TAF on report
|
||||
if ($this->part <= 4) {
|
||||
$this->set_result_value('taf', true);
|
||||
|
@ -8,7 +8,7 @@ use App\Contracts\Award;
|
||||
* Simple example of an awards class, where you can apply an award when a user
|
||||
* has 100 flights. All award classes need to extend Award and implement the check() method
|
||||
*
|
||||
* See: http://docs.phpvms.net/customizing/awards
|
||||
* See: https://docs.phpvms.net/developers/awards
|
||||
*/
|
||||
class PilotFlightAwards extends Award
|
||||
{
|
||||
|
@ -34,7 +34,7 @@
|
||||
<server name="APP_DEBUG" value="true"/>
|
||||
<server name="APP_LOG_LEVEL" value="error"/>
|
||||
<server name="BCRYPT_ROUNDS" value="4"/>
|
||||
<server name="CACHE_DRIVER" value="array"/>
|
||||
<server name="CACHE_DRIVER" value="none"/>
|
||||
<server name="DB_CONNECTION" value="memory"/>
|
||||
<server name="DB_PREFIX" value="vmstest_"/>
|
||||
<server name="MAIL_MAILER" value="array"/>
|
||||
|
@ -173,6 +173,22 @@ class MetarTest extends TestCase
|
||||
$this->assertInstanceOf(Metar::class, $airportSvc->getMetar('kjfk'));
|
||||
}
|
||||
|
||||
/**
|
||||
* TEMPO and trend causing issue with values being overwritten
|
||||
* https://github.com/nabeelio/phpvms/issues/861
|
||||
*/
|
||||
public function testLFRSCall()
|
||||
{
|
||||
$this->mockXmlResponse('aviationweather/lfrs.xml');
|
||||
|
||||
/** @var AirportService $airportSvc */
|
||||
$airportSvc = app(AirportService::class);
|
||||
|
||||
$metar = $airportSvc->getMetar('lfrs');
|
||||
$this->assertInstanceOf(Metar::class, $metar);
|
||||
$this->assertTrue($metar['cavok']);
|
||||
}
|
||||
|
||||
public function testHttpCallSuccessFullResponse()
|
||||
{
|
||||
$this->mockXmlResponse('aviationweather/kphx.xml');
|
||||
|
32
tests/data/aviationweather/lfrs.xml
Normal file
32
tests/data/aviationweather/lfrs.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<response xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2"
|
||||
xsi:noNamespaceSchemaLocation="http://www.aviationweather.gov/static/adds/schema/metar1_2.xsd">
|
||||
<request_index>109074758</request_index>
|
||||
<data_source name="metars"/>
|
||||
<request type="retrieve"/>
|
||||
<errors/>
|
||||
<warnings/>
|
||||
<time_taken_ms>7</time_taken_ms>
|
||||
<data num_results="1">
|
||||
<METAR>
|
||||
<raw_text>LFRS 101630Z AUTO 32007KT 280V340 CAVOK 15/05 Q1027 TEMPO SCT035TCU</raw_text>
|
||||
<station_id>LFRS</station_id>
|
||||
<observation_time>2020-10-10T16:30:00Z</observation_time>
|
||||
<latitude>47.17</latitude>
|
||||
<longitude>-1.6</longitude>
|
||||
<temp_c>15.0</temp_c>
|
||||
<dewpoint_c>5.0</dewpoint_c>
|
||||
<wind_dir_degrees>320</wind_dir_degrees>
|
||||
<wind_speed_kt>7</wind_speed_kt>
|
||||
<visibility_statute_mi>6.21</visibility_statute_mi>
|
||||
<altim_in_hg>30.324802</altim_in_hg>
|
||||
<quality_control_flags>
|
||||
<auto>TRUE</auto>
|
||||
</quality_control_flags>
|
||||
<sky_condition sky_cover="CAVOK"/>
|
||||
<flight_category>VFR</flight_category>
|
||||
<metar_type>SPECI</metar_type>
|
||||
<elevation_m>26.0</elevation_m>
|
||||
</METAR>
|
||||
</data>
|
||||
</response>
|
Loading…
Reference in New Issue
Block a user