live map updates

This commit is contained in:
Nabeel Shahzad
2018-05-04 13:59:47 -05:00
parent d80e70e2b1
commit 0cd7b3b71f
15 changed files with 178 additions and 48 deletions

View File

@@ -107,7 +107,7 @@ class PirepController extends Controller
$active = [];
$pireps = $this->acarsRepo->getPositions();
foreach($pireps as $pirep) {
if(\count($pirep->position) === 0) {
if(!$pirep->position) {
continue;
}

View File

@@ -11,7 +11,13 @@ use App\Models\Traits\FilesTrait;
* @property string id
* @property string iata
* @property string icao
* @property string name
* @property string location
* @property string country
* @property string timezone
* @property float ground_handling_cost
* @property float lat
* @property float lon
* @package App\Models
*/
class Airport extends Model

View File

@@ -44,6 +44,7 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
* @property Carbon updated_at
* @property bool state
* @property Acars position
* @property Acars[] acars
* @package App\Models
*/
class Pirep extends Model

View File

@@ -181,18 +181,29 @@ class GeoService extends Service
*/
public function getFeatureFromAcars(Pirep $pirep)
{
// Get the two airports
$airports = new GeoJson();
$airports->addPoint($pirep->dpt_airport->lat, $pirep->dpt_airport->lon, [
'name' => $pirep->dpt_airport->name,
'icao' => $pirep->dpt_airport->icao,
'type' => 'D',
]);
$airports->addPoint($pirep->arr_airport->lat, $pirep->arr_airport->lon, [
'name' => $pirep->arr_airport->name,
'icao' => $pirep->arr_airport->icao,
'type' => 'A',
]);
$route = new GeoJson();
/**
* @var $point \App\Models\Acars
*/
$counter = 1;
foreach ($pirep->acars as $point) {
$route->addPoint($point->lat, $point->lon, [
'pirep_id' => $pirep->id,
'name' => '',
'alt' => $point->altitude,
'popup' => 'GS: '.$point->gs.'<br />Alt: '.$point->altitude,
]);
}
@@ -201,8 +212,20 @@ class GeoService extends Service
'lat' => $pirep->position->lat,
'lon' => $pirep->position->lon,
],
'line' => $route->getLine(),
'points' => $route->getPoints()
'line' => $route->getLine(),
'points' => $route->getPoints(),
'airports' => [
'a' => [
'icao' => $pirep->arr_airport->icao,
'lat' => $pirep->arr_airport->lat,
'lon' => $pirep->arr_airport->lon,
],
'd' => [
'icao' => $pirep->dpt_airport->icao,
'lat' => $pirep->dpt_airport->lat,
'lon' => $pirep->dpt_airport->lon,
],
]
];
}
@@ -227,10 +250,8 @@ class GeoService extends Service
$flight->addPoint($point->lat, $point->lon, [
'pirep_id' => $pirep->id,
'gs' => $point->gs,
'alt' => $point->altitude,
'heading' => $point->heading ?: 0,
//'popup' => $pirep->ident.'<br />GS: '.$point->gs.'<br />Alt: '.$point->altitude,
]);
}