2017-12-26 05:19:34 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
|
|
use Log;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\Http\Controllers\AppBaseController;
|
|
|
|
|
2017-12-28 06:47:22 +08:00
|
|
|
use App\Models\Acars;
|
|
|
|
use App\Services\GeoService;
|
2017-12-26 05:19:34 +08:00
|
|
|
use App\Repositories\AcarsRepository;
|
|
|
|
use App\Repositories\PirepRepository;
|
|
|
|
|
|
|
|
|
|
|
|
class AcarsController extends AppBaseController
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|