Add acars map page and show in-progress flights

This commit is contained in:
Nabeel Shahzad
2017-12-27 16:47:22 -06:00
parent a2e2a2a6a7
commit edca0644ff
103 changed files with 12380 additions and 827 deletions

View File

@@ -139,6 +139,32 @@ class GeoService extends BaseService
return $coords;
}
/**
* Determine the center point between two sets of coordinates
* @param $latA
* @param $lonA
* @param $latB
* @param $lonB
* @return array
* @throws \League\Geotools\Exception\InvalidArgumentException
*/
public function getCenter($latA, $lonA, $latB, $lonB)
{
$geotools = new Geotools();
$coordA = new Coordinate([$latA, $lonA]);
$coordB = new Coordinate([$latB, $lonB]);
$vertex = $geotools->vertex()->setFrom($coordA)->setTo($coordB);
$middlePoint = $vertex->middle();
$center = [
$middlePoint->getLatitude(),
$middlePoint->getLongitude()
];
return $center;
}
/**
* Read an array/relationship of ACARS model points
* @param Pirep $pirep
@@ -171,12 +197,42 @@ class GeoService extends BaseService
# Convert to a feature
$route_line = new Feature(new LineString($route_line), [], 1);
# TODO: Draw the plane icon from the last point
return [
'line' => new FeatureCollection([$route_line]),
'points' => new FeatureCollection($route_points)
];
}
/**
* Return a single feature point for the
*/
public function getFeatureForLiveFlights($pireps)
{
$flight_points = [];
/**
* @var Pirep $pirep
*/
foreach($pireps as $pirep) {
/**
* @var $point \App\Models\Acars
*/
$point = $pirep->position;
$flight_points[] = new Feature(
new Point([$point->lon, $point->lat]), [
'gs' => $point->gs,
'alt' => $point->altitude,
'heading' => $point->heading ?: 0,
'popup' => 'Flight: ' . $pirep->ident,
]);
}
return new FeatureCollection($flight_points);
}
/**
* Return a FeatureCollection GeoJSON object
* @param Flight $flight
@@ -300,30 +356,4 @@ class GeoService extends BaseService
'actual_route_points' => $actual_route['points'],
];
}
/**
* Determine the center point between two sets of coordinates
* @param $latA
* @param $lonA
* @param $latB
* @param $lonB
* @return array
* @throws \League\Geotools\Exception\InvalidArgumentException
*/
public function getCenter($latA, $lonA, $latB, $lonB)
{
$geotools = new Geotools();
$coordA = new Coordinate([$latA, $lonA]);
$coordB = new Coordinate([$latB, $lonB]);
$vertex = $geotools->vertex()->setFrom($coordA)->setTo($coordB);
$middlePoint = $vertex->middle();
$center = [
$middlePoint->getLatitude(),
$middlePoint->getLongitude()
];
return $center;
}
}