remove duplicate method calls
This commit is contained in:
parent
b456dc1a71
commit
d1c626afe8
@ -275,6 +275,24 @@ user_bids:
|
||||
user_id: 1
|
||||
flight_id: flightid_3
|
||||
|
||||
acars:
|
||||
- pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: IAH
|
||||
lat: 29.95691
|
||||
lon: -95.345719
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: MEI
|
||||
lat: 32.37843
|
||||
lon: -88.804267
|
||||
created_at: now
|
||||
updated_at: now
|
||||
|
||||
pireps:
|
||||
- id: pirepid_1
|
||||
user_id: 1
|
||||
@ -286,7 +304,7 @@ pireps:
|
||||
arr_airport_id: KJFK
|
||||
flight_time: 180 # 6 hours
|
||||
state: 1
|
||||
route: PLMMR2 SPA Q22 BEARI FAK PHLBO3
|
||||
route: KAUS SID TNV J87 IAH J2 LCH J22 MEI J239 ATL J52 AJFEB J14 BYJAC Q60 JAXSN J14 COLIN J61 HUBBS J55 SIE STAR KJFK
|
||||
notes: just a pilot report
|
||||
created_at: NOW
|
||||
updated_at: NOW
|
||||
|
@ -183,8 +183,7 @@ class PirepController extends BaseController
|
||||
$orig_route = $pirep->route;
|
||||
$pirep = $this->pirepRepo->update($attrs, $id);
|
||||
|
||||
// A route change in the PIREP, so update the saved points
|
||||
// in the ACARS table
|
||||
// A route change in the PIREP, so update the saved points in the ACARS table
|
||||
if($pirep->route !== $orig_route) {
|
||||
$this->pirepSvc->saveRoute($pirep);
|
||||
}
|
||||
|
@ -37,64 +37,6 @@ class GeoService extends BaseService
|
||||
$this->navRepo = $navRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a route string into a collection of Navadata points
|
||||
* TODO: Add the distance calculation in here
|
||||
* @param $route
|
||||
* @param Airport|null $dep
|
||||
* @param Airport|null $arr
|
||||
* @return array|Collection
|
||||
*/
|
||||
public function routeToNavPoints($route, Airport $dep=null, Airport $arr=null)
|
||||
{
|
||||
$route = trim($route);
|
||||
if(empty($route)) {
|
||||
return collect();
|
||||
}
|
||||
|
||||
$skip_points = ['SID', 'STAR'];
|
||||
if($dep !== null) {
|
||||
$skip_points[] = $dep->icao;
|
||||
}
|
||||
|
||||
if($arr !== null) {
|
||||
$skip_points[] = $arr->icao;
|
||||
}
|
||||
|
||||
# Iterate through the route
|
||||
$route = collect(explode(' ', $route))
|
||||
->transform(function($point) use ($skip_points) {
|
||||
$point = trim($point);
|
||||
|
||||
if(empty($point)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(\in_array($point, $skip_points, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$navpoints = $this->navRepo->findWhere(['id'=>$point]);
|
||||
} catch(ModelNotFoundException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($navpoints->count() === 0) {
|
||||
return false;
|
||||
} elseif ($navpoints->count() === 1) {
|
||||
return $navpoints[0];
|
||||
}
|
||||
|
||||
# find the closest waypoint...
|
||||
})
|
||||
->filter(function($value, $key) {
|
||||
return !empty($value);
|
||||
});
|
||||
|
||||
return $route;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the closest set of coordinates from the starting position
|
||||
* @param array $coordStart
|
||||
|
@ -66,10 +66,11 @@ class PIREPService extends BaseService
|
||||
return $pirep;
|
||||
}
|
||||
|
||||
$route = $this->geoSvc->routeToNavPoints(
|
||||
$pirep->route,
|
||||
$pirep->dep_airport,
|
||||
$pirep->arr_airport
|
||||
$route = $this->geoSvc->getCoordsFromRoute(
|
||||
$pirep->dpt_airport_id,
|
||||
$pirep->arr_airport_id,
|
||||
[$pirep->dpt_airport->lat, $pirep->dpt_airport->lon],
|
||||
$pirep->route
|
||||
);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user