Add METAR interface and use local library for decoding
This commit is contained in:
@@ -37,13 +37,6 @@ return [
|
||||
'api_key' => '',
|
||||
],
|
||||
|
||||
// For METAR features, register for an API key at
|
||||
// https://www.checkwx.com
|
||||
'checkwx' => [
|
||||
'url' => 'https://api.checkwx.com',
|
||||
'api_key' => false,
|
||||
],
|
||||
|
||||
#
|
||||
# Other settings and configuration you might not need to modify
|
||||
#
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
|
||||
{{-- Show the weather widget in one column --}}
|
||||
<div class="col-5">
|
||||
{{ Widget::checkWx([
|
||||
{{ Widget::Weather([
|
||||
'icao' => $airport->icao,
|
||||
]) }}
|
||||
</div>
|
||||
|
||||
{{-- Show the airspace map in the other column --}}
|
||||
<div class="col-7">
|
||||
{{ Widget::airspaceMap([
|
||||
{{ Widget::AirspaceMap([
|
||||
'width' => '100%',
|
||||
'height' => '400px',
|
||||
'lat' => $airport->lat,
|
||||
@@ -29,7 +29,7 @@
|
||||
@if($airport->files && Auth::check())
|
||||
<div class="col-12">
|
||||
<h3 class="description">Downloads</h3>
|
||||
@include('files.table', ['files' => $airport->files])
|
||||
@include('downloads.table', ['files' => $airport->files])
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
<div class="card-block">
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
{{ Widget::checkWx(['icao' => $current_airport]) }}
|
||||
{{ Widget::Weather(['icao' => $current_airport]) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -50,13 +50,13 @@
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<h5>{{$flight->dpt_airport_id}} METAR</h5>
|
||||
{{ Widget::checkWx([
|
||||
{{ Widget::Weather([
|
||||
'icao' => $flight->dpt_airport_id,
|
||||
]) }}
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<h5>{{$flight->arr_airport_id}} METAR</h5>
|
||||
{{ Widget::checkWx([
|
||||
{{ Widget::Weather([
|
||||
'icao' => $flight->arr_airport_id,
|
||||
]) }}
|
||||
</div>
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
{{--
|
||||
|
||||
If you want to edit this, you can reference the CheckWX API docs:
|
||||
https://api.checkwx.com/#metar-decoded
|
||||
|
||||
--}}
|
||||
@if(!$data)
|
||||
<p>METAR/TAF data could not be retrieved</p>
|
||||
@else
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td>Conditions</td>
|
||||
<td>
|
||||
{{$data->flight_category}},
|
||||
@if($unit_temp === 'f')
|
||||
{{$data->temperature->fahrenheit}}°F
|
||||
@else
|
||||
{{$data->temperature->celsius}}°C
|
||||
@endif
|
||||
|
||||
@if($data->visibility->miles)
|
||||
, visibility
|
||||
@if($unit_dist === 'km')
|
||||
{{intval(str_replace(',', '', $data->visibility->meters)) / 1000}}
|
||||
@else
|
||||
{{$data->visibility->miles}}
|
||||
@endif
|
||||
@endif
|
||||
|
||||
@if($data->humidity_percent)
|
||||
, {{$data->humidity_percent}}% humidity
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Barometer</td>
|
||||
<td>{{ $data->barometer->hg }}hg/{{ $data->barometer->mb }}mb</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Clouds</td>
|
||||
<td>
|
||||
@foreach($data->clouds as $cloud)
|
||||
<p>
|
||||
{{$cloud->text}} @
|
||||
@if($unit_alt === 'ft')
|
||||
{{$cloud->base_feet_agl}}
|
||||
@else
|
||||
{{$cloud->base_meters_agl}}
|
||||
@endif
|
||||
{{$unit_alt}}
|
||||
</p>
|
||||
@endforeach
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Wind</td>
|
||||
<td>
|
||||
{{$data->wind->speed_kts}}kts @ {{$data->wind->degrees}},
|
||||
@if(property_exists($data->wind, 'gusts_kts'))
|
||||
gusts to {{$data->wind->gusts_kts}}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Metar</td>
|
||||
<td>
|
||||
<div style="line-height:1.5em;min-height: 3em;">
|
||||
{{$data->raw_text}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Updated</td>
|
||||
<td>{{$data->observed}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
@endif
|
||||
78
resources/views/layouts/default/widgets/weather.blade.php
Normal file
78
resources/views/layouts/default/widgets/weather.blade.php
Normal file
@@ -0,0 +1,78 @@
|
||||
{{--
|
||||
|
||||
If you want to edit this, you can reference the CheckWX API docs:
|
||||
https://api.checkwx.com/#metar-decoded
|
||||
|
||||
--}}
|
||||
@if(!$metar)
|
||||
<p>METAR/TAF data could not be retrieved</p>
|
||||
@else
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td>Conditions</td>
|
||||
<td>
|
||||
{{ $category }},
|
||||
@if($unit_temp === 'c')
|
||||
{{ $metar->getAirTemperature()->getValue() }}
|
||||
@else
|
||||
{{ round(($metar->getAirTemperature()->getValue() * 9/5) + 32, 2) }}
|
||||
@endif
|
||||
°{{strtoupper($unit_temp)}}
|
||||
|
||||
@if($metar->getVisibility()->getVisibility())
|
||||
, visibility
|
||||
@if($unit_dist === 'km')
|
||||
{{ $metar->getVisibility()->getVisibility()->getConvertedValue('m') / 1000 }}
|
||||
@else
|
||||
{{ $metar->getVisibility()->getVisibility()->getValue() }}
|
||||
@endif
|
||||
{{$unit_dist}}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Barometer</td>
|
||||
<td>{{ $metar->getPressure()->getValue() }} Hg
|
||||
/ {{ round($metar->getPressure()->getValue() * 33.86) }} MB
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Clouds</td>
|
||||
<td>
|
||||
@foreach($metar->getClouds() as $cloud)
|
||||
<p>
|
||||
{{$cloud->getAmount()}} @
|
||||
@if($unit_alt === 'ft')
|
||||
{{$cloud->getBaseHeight()->getValue()}}
|
||||
@else
|
||||
{{$cloud->getBaseHeight()->getConvertedValue('m')}}
|
||||
@endif
|
||||
{{ $unit_alt }}
|
||||
</p>
|
||||
@endforeach
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Wind</td>
|
||||
<td>
|
||||
{{$metar->getSurfaceWind()->getMeanSpeed()->getConvertedValue('kt')}} kts
|
||||
@ {{$metar->getSurfaceWind()->getMeanDirection()->getValue()}}°
|
||||
@if($metar->getSurfaceWind()->getSpeedVariations())
|
||||
gusts to {{$metar->getSurfaceWind()->getSpeedVariations()->getConvertedValue('kt')}}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>METAR</td>
|
||||
<td>
|
||||
<div style="line-height:1.5em;min-height: 3em;">
|
||||
{{ $metar->getRawMetar() }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Updated</td>
|
||||
<td>{{$metar->getTime()}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
@endif
|
||||
Reference in New Issue
Block a user