More work on the pirep/acars maps
This commit is contained in:
@@ -73,7 +73,7 @@ class AcarsReplay extends Command
|
||||
|
||||
$flight_number = substr($flight->callsign, 3);
|
||||
|
||||
$response = $this->httpClient->post('/api/pirep/prefile', [
|
||||
$response = $this->httpClient->post('/api/pireps/prefile', [
|
||||
'json' => [
|
||||
'airline_id' => 1,
|
||||
'flight_number' => $flight_number,
|
||||
@@ -97,7 +97,7 @@ class AcarsReplay extends Command
|
||||
*/
|
||||
protected function filePirep($pirep_id)
|
||||
{
|
||||
$response = $this->httpClient->post('/api/pirep/'.$pirep_id.'/file', [
|
||||
$response = $this->httpClient->post('/api/pireps/'.$pirep_id.'/file', [
|
||||
'json'=> []
|
||||
]);
|
||||
|
||||
|
||||
@@ -151,16 +151,19 @@ class PirepController extends AppBaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the ACARS updates for a PIREP
|
||||
* Return the GeoJSON for the ACARS line
|
||||
* @param $id
|
||||
* @return AcarsResource
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory
|
||||
*/
|
||||
public function acars_get($id)
|
||||
public function acars_get($id, Request $request)
|
||||
{
|
||||
$pirep = $this->pirepRepo->find($id);
|
||||
$geodata = $this->geoSvc->getFeatureFromAcars($pirep);
|
||||
|
||||
$updates = $this->acarsRepo->forPirep($id);
|
||||
return new AcarsResource($updates);
|
||||
return response(\json_encode($geodata), 200, [
|
||||
'Content-Type' => 'application/json',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,20 +190,4 @@ class PirepController extends AppBaseController
|
||||
AcarsResource::withoutWrapping();
|
||||
return new AcarsResource($update);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the GeoJSON for the ACARS line
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory
|
||||
*/
|
||||
public function geojson($id, Request $request)
|
||||
{
|
||||
$pirep = $this->pirepRepo->find($id);
|
||||
$geodata = $this->geoSvc->getFeatureFromAcars($pirep);
|
||||
|
||||
return response(\json_encode($geodata), 200, [
|
||||
'Content-Type' => 'application/json',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class Pirep extends BaseModel
|
||||
public function acars()
|
||||
{
|
||||
return $this->hasMany('App\Models\Acars', 'pirep_id')
|
||||
->orderBy('created_at', 'desc');
|
||||
->orderBy('created_at', 'asc');
|
||||
}
|
||||
|
||||
public function aircraft()
|
||||
|
||||
@@ -5,14 +5,15 @@
|
||||
*/
|
||||
Route::group([], function()
|
||||
{
|
||||
Route::match(['get'], 'acars', 'AcarsController@index');
|
||||
Route::get('acars', 'AcarsController@index');
|
||||
|
||||
Route::match(['get'], 'flights/search', 'FlightController@search');
|
||||
Route::match(['get'], 'flights/{id}', 'FlightController@get');
|
||||
Route::get('flights/search', 'FlightController@search');
|
||||
Route::get('flights/{id}', 'FlightController@get');
|
||||
|
||||
Route::match(['post'], 'pirep/{id}/geojson', 'PirepController@file');
|
||||
Route::get('pireps/{id}/acars', 'PirepController@acars_get');
|
||||
Route::get('pireps/{id}/geojson', 'PirepController@acars_get');
|
||||
|
||||
Route::match(['get'], 'status', 'BaseController@status');
|
||||
Route::get('status', 'BaseController@status');
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -20,19 +21,17 @@ Route::group([], function()
|
||||
*/
|
||||
Route::group(['middleware' => ['api.auth']], function ()
|
||||
{
|
||||
Route::match(['get'], 'airports/{id}', 'AirportController@get');
|
||||
Route::match(['get'], 'airports/{id}/lookup', 'AirportController@lookup');
|
||||
Route::get('airports/{id}', 'AirportController@get');
|
||||
Route::get('airports/{id}/lookup', 'AirportController@lookup');
|
||||
|
||||
Route::match(['get'], 'pirep/{id}', 'PirepController@get');
|
||||
Route::match(['post'], 'pirep/prefile', 'PirepController@prefile');
|
||||
Route::match(['post'], 'pirep/{id}/file', 'PirepController@file');
|
||||
Route::get('pireps/{id}', 'PirepController@get');
|
||||
Route::post('pireps/prefile', 'PirepController@prefile');
|
||||
Route::post('pireps/{id}/file', 'PirepController@file');
|
||||
|
||||
Route::match(['get'], 'pirep/{id}/acars', 'PirepController@acars_get');
|
||||
Route::match(['post'], 'pirep/{id}/acars', 'PirepController@acars_store');
|
||||
Route::post('pireps/{id}/acars', 'PirepController@acars_store');
|
||||
|
||||
# This is the info of the user whose token is in use
|
||||
Route::match(['get'], 'user', 'UserController@index');
|
||||
#Route::match(['get'], 'user/bids', 'UserController@index');
|
||||
Route::match(['get'], 'users/{id}', 'UserController@get');
|
||||
Route::match(['get'], 'users/{id}/bids', 'UserController@bids');
|
||||
Route::get('user', 'UserController@index');
|
||||
Route::get('users/{id}', 'UserController@get');
|
||||
Route::get('users/{id}/bids', 'UserController@bids');
|
||||
});
|
||||
|
||||
@@ -168,34 +168,36 @@ class GeoService extends BaseService
|
||||
/**
|
||||
* Read an array/relationship of ACARS model points
|
||||
* @param Pirep $pirep
|
||||
* @return FeatureCollection
|
||||
* @return array
|
||||
*/
|
||||
public function getFeatureFromAcars(Pirep $pirep)
|
||||
{
|
||||
$route_line = [];
|
||||
$route_points = [];
|
||||
|
||||
$route_line[] = [$pirep->dpt_airport->lon, $pirep->dpt_airport->lat];
|
||||
|
||||
/**
|
||||
* @var $point \App\Models\Acars
|
||||
*/
|
||||
foreach ($pirep->acars as $point)
|
||||
{
|
||||
$counter = 1;
|
||||
foreach ($pirep->acars as $point) {
|
||||
$route_line[] = [$point->lon, $point->lat];
|
||||
$route_points[] = new Feature(
|
||||
new Point([$point->lon, $point->lat]), [
|
||||
'pirep_id' => $pirep->id,
|
||||
'name' => $point->altitude,
|
||||
'popup' => 'GS: ' . $point->gs . '<br />Alt: ' . $point->altitude,
|
||||
]);
|
||||
}
|
||||
'name' => $point->altitude,
|
||||
'popup' => $counter . '<br />GS: ' . $point->gs . '<br />Alt: ' . $point->altitude,
|
||||
]);
|
||||
|
||||
$counter += 1;
|
||||
}
|
||||
# Arrival
|
||||
$route_line[] = [$pirep->arr_airport->lon, $pirep->arr_airport->lat];
|
||||
$route_line = new Feature(new LineString($route_line));
|
||||
|
||||
return new FeatureCollection([$route_line, $route_points]);
|
||||
return [
|
||||
'line' => new FeatureCollection([$route_line]),
|
||||
'points' => new FeatureCollection($route_points)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -218,6 +218,7 @@ const phpvms = (function() {
|
||||
|
||||
opts = _.defaults(opts, {
|
||||
update_uri: '/api/acars',
|
||||
pirep_uri: '/api/pireps/{id}/acars',
|
||||
positions: null,
|
||||
render_elem: 'map',
|
||||
aircraft_icon: '/assets/img/acars/aircraft.png',
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<script type="text/javascript">
|
||||
phpvms.render_live_map({
|
||||
'update_uri': '{!! url('/api/acars') !!}',
|
||||
'pirep_uri': '{!! url('/api/pireps/{id}/acars') !!}',
|
||||
'aircraft_icon': '{!! public_asset('/assets/img/acars/aircraft.png') !!}',
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user