remove duplicate method calls

This commit is contained in:
Nabeel Shahzad 2018-01-01 15:04:32 -06:00
parent b456dc1a71
commit d1c626afe8
4 changed files with 25 additions and 65 deletions

View File

@ -275,6 +275,24 @@ user_bids:
user_id: 1 user_id: 1
flight_id: flightid_3 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: pireps:
- id: pirepid_1 - id: pirepid_1
user_id: 1 user_id: 1
@ -286,7 +304,7 @@ pireps:
arr_airport_id: KJFK arr_airport_id: KJFK
flight_time: 180 # 6 hours flight_time: 180 # 6 hours
state: 1 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 notes: just a pilot report
created_at: NOW created_at: NOW
updated_at: NOW updated_at: NOW

View File

@ -183,8 +183,7 @@ class PirepController extends BaseController
$orig_route = $pirep->route; $orig_route = $pirep->route;
$pirep = $this->pirepRepo->update($attrs, $id); $pirep = $this->pirepRepo->update($attrs, $id);
// A route change in the PIREP, so update the saved points // A route change in the PIREP, so update the saved points in the ACARS table
// in the ACARS table
if($pirep->route !== $orig_route) { if($pirep->route !== $orig_route) {
$this->pirepSvc->saveRoute($pirep); $this->pirepSvc->saveRoute($pirep);
} }

View File

@ -37,64 +37,6 @@ class GeoService extends BaseService
$this->navRepo = $navRepo; $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 * Determine the closest set of coordinates from the starting position
* @param array $coordStart * @param array $coordStart

View File

@ -66,10 +66,11 @@ class PIREPService extends BaseService
return $pirep; return $pirep;
} }
$route = $this->geoSvc->routeToNavPoints( $route = $this->geoSvc->getCoordsFromRoute(
$pirep->route, $pirep->dpt_airport_id,
$pirep->dep_airport, $pirep->arr_airport_id,
$pirep->arr_airport [$pirep->dpt_airport->lat, $pirep->dpt_airport->lon],
$pirep->route
); );
/** /**