Fixes for API and live map
This commit is contained in:
@@ -48,7 +48,7 @@ class DevInstall extends Command
|
||||
#
|
||||
|
||||
$this->info('Importing sample data');
|
||||
\Artisan::call('phpvms:import', [
|
||||
\Artisan::call('phpvms:yaml-import', [
|
||||
'files' => ['app/Database/seeds/sample.yml'],
|
||||
]);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\Enums\PirepStatus;
|
||||
use App\Support\Units\Distance;
|
||||
use App\Support\Units\Fuel;
|
||||
use Illuminate\Http\Resources\Json\Resource;
|
||||
@@ -40,9 +41,12 @@ class Pirep extends Resource
|
||||
if($this->block_off_time)
|
||||
$pirep['block_off_time'] = $this->block_off_time->toIso8601ZuluString();
|
||||
|
||||
$pirep['status_text'] = PirepStatus::label($this->status);
|
||||
|
||||
$pirep['airline'] = new Airline($this->airline);
|
||||
$pirep['dpt_airport'] = new Airport($this->dpt_airport);
|
||||
$pirep['arr_airport'] = new Airport($this->arr_airport);
|
||||
|
||||
$pirep['position'] = new Acars($this->position);
|
||||
$pirep['comments'] = PirepComment::collection($this->comments);
|
||||
$pirep['user'] = [
|
||||
|
||||
@@ -34,8 +34,14 @@ class GeoJson
|
||||
*/
|
||||
public function addPoint($lat, $lon, array $attrs)
|
||||
{
|
||||
$point = [$lon, $lat];
|
||||
$this->line_coords[] = [$lon, $lat];
|
||||
$this->point_coords[] = new Feature(new Point([$lon, $lat]), $attrs);
|
||||
|
||||
if(array_key_exists('alt', $attrs)) {
|
||||
$point[] = $attrs['alt'];
|
||||
}
|
||||
|
||||
$this->point_coords[] = new Feature(new Point($point), $attrs);
|
||||
++$this->counter;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
|
||||
* @property Carbon created_at
|
||||
* @property Carbon updated_at
|
||||
* @property bool state
|
||||
* @property Acars position
|
||||
* @package App\Models
|
||||
*/
|
||||
class Pirep extends Model
|
||||
@@ -177,6 +178,19 @@ class Pirep extends Model
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the block on time
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getSubmittedAtAttribute()
|
||||
{
|
||||
if (array_key_exists('submitted_at', $this->attributes)) {
|
||||
return new Carbon($this->attributes['submitted_at']);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new Length unit so conversions can be made
|
||||
* @return int|Distance
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
Route::group([], function () {
|
||||
Route::get('acars', 'AcarsController@index');
|
||||
Route::get('pireps/{pirep_id}', 'PirepController@get');
|
||||
Route::get('pireps/{pirep_id}/acars/geojson', 'PirepController@acars_geojson');
|
||||
|
||||
Route::get('news', 'NewsController@index');
|
||||
@@ -32,7 +33,6 @@ Route::group(['middleware' => ['api.auth']], function () {
|
||||
Route::get('flights/{id}', 'FlightController@get');
|
||||
Route::get('flights/{id}/route', 'FlightController@route');
|
||||
|
||||
Route::get('pireps/{pirep_id}', 'PirepController@get');
|
||||
Route::put('pireps/{pirep_id}', 'PirepController@update');
|
||||
|
||||
/*
|
||||
|
||||
@@ -190,12 +190,17 @@ class GeoService extends Service
|
||||
foreach ($pirep->acars as $point) {
|
||||
$route->addPoint($point->lat, $point->lon, [
|
||||
'pirep_id' => $pirep->id,
|
||||
'name' => $point->altitude,
|
||||
'popup' => $counter.'<br />GS: '.$point->gs.'<br />Alt: '.$point->altitude,
|
||||
'name' => '',
|
||||
'alt' => $point->altitude,
|
||||
'popup' => 'GS: '.$point->gs.'<br />Alt: '.$point->altitude,
|
||||
]);
|
||||
}
|
||||
|
||||
return [
|
||||
'position' => [
|
||||
'lat' => $pirep->position->lat,
|
||||
'lon' => $pirep->position->lon,
|
||||
],
|
||||
'line' => $route->getLine(),
|
||||
'points' => $route->getPoints()
|
||||
];
|
||||
@@ -225,7 +230,7 @@ class GeoService extends Service
|
||||
'gs' => $point->gs,
|
||||
'alt' => $point->altitude,
|
||||
'heading' => $point->heading ?: 0,
|
||||
'popup' => $pirep->ident.'<br />GS: '.$point->gs.'<br />Alt: '.$point->altitude,
|
||||
//'popup' => $pirep->ident.'<br />GS: '.$point->gs.'<br />Alt: '.$point->altitude,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user