2017-12-26 05:19:34 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
2017-12-28 06:47:22 +08:00
|
|
|
use App\Services\GeoService;
|
2017-12-26 05:19:34 +08:00
|
|
|
use App\Repositories\AcarsRepository;
|
|
|
|
use App\Repositories\PirepRepository;
|
|
|
|
|
|
|
|
|
2018-01-06 00:45:34 +08:00
|
|
|
class AcarsController extends RestController
|
2017-12-26 05:19:34 +08:00
|
|
|
{
|
2017-12-28 06:47:22 +08:00
|
|
|
protected $acarsRepo, $geoSvc, $pirepRepo;
|
2017-12-26 05:19:34 +08:00
|
|
|
|
|
|
|
public function __construct(
|
2017-12-28 06:47:22 +08:00
|
|
|
GeoService $geoSvc,
|
2017-12-26 05:19:34 +08:00
|
|
|
AcarsRepository $acarsRepo,
|
|
|
|
PirepRepository $pirepRepo
|
|
|
|
) {
|
2017-12-28 06:47:22 +08:00
|
|
|
$this->geoSvc = $geoSvc;
|
2017-12-26 05:19:34 +08:00
|
|
|
$this->acarsRepo = $acarsRepo;
|
|
|
|
$this->pirepRepo = $pirepRepo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-12-28 06:47:22 +08:00
|
|
|
* Return all of the flights (as points) in GeoJSON format
|
2017-12-26 05:19:34 +08:00
|
|
|
*/
|
2017-12-28 06:47:22 +08:00
|
|
|
public function index(Request $request)
|
2017-12-26 05:19:34 +08:00
|
|
|
{
|
2017-12-28 06:47:22 +08:00
|
|
|
$pireps = $this->acarsRepo->getPositions();
|
|
|
|
$positions = $this->geoSvc->getFeatureForLiveFlights($pireps);
|
2017-12-26 05:19:34 +08:00
|
|
|
|
2017-12-28 06:47:22 +08:00
|
|
|
return response(json_encode($positions), 200, [
|
|
|
|
'Content-type' => 'application/json'
|
|
|
|
]);
|
2017-12-26 05:19:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|