Fix error if there are no points in the ACARS route
This commit is contained in:
parent
e2ab6445d2
commit
e65edc5709
@ -174,7 +174,6 @@ class GeoService extends BaseService
|
|||||||
{
|
{
|
||||||
$route_line = [];
|
$route_line = [];
|
||||||
$route_points = [];
|
$route_points = [];
|
||||||
#$route_line[] = [$pirep->dpt_airport->lon, $pirep->dpt_airport->lat];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var $point \App\Models\Acars
|
* @var $point \App\Models\Acars
|
||||||
@ -191,12 +190,16 @@ class GeoService extends BaseService
|
|||||||
|
|
||||||
++$counter;
|
++$counter;
|
||||||
}
|
}
|
||||||
# Arrival
|
|
||||||
#$route_line[] = [$pirep->arr_airport->lon, $pirep->arr_airport->lat];
|
if(\count($route_line) >= 2) {
|
||||||
$route_line = new Feature(new LineString($route_line));
|
$route_line = new Feature(new LineString($route_line));
|
||||||
|
$route_line = new FeatureCollection([$route_line]);
|
||||||
|
} else {
|
||||||
|
$route_line = new FeatureCollection([]);
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'line' => new FeatureCollection([$route_line]),
|
'line' => $route_line,
|
||||||
'points' => new FeatureCollection($route_points)
|
'points' => new FeatureCollection($route_points)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -69,11 +69,11 @@ class AcarsTest extends TestCase
|
|||||||
$this->assertEquals(PirepState::IN_PROGRESS, $pirep['state']);
|
$this->assertEquals(PirepState::IN_PROGRESS, $pirep['state']);
|
||||||
$this->assertEquals(PirepStatus::ENROUTE, $pirep['status']);
|
$this->assertEquals(PirepStatus::ENROUTE, $pirep['status']);
|
||||||
|
|
||||||
/*$uri = '/api/pireps/' . $pirep_id . '/acars';
|
$uri = '/api/pireps/' . $pirep_id . '/acars';
|
||||||
$response = $this->withHeaders($this->apiHeaders())->get($uri);
|
$response = $this->withHeaders($this->apiHeaders())->get($uri);
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
|
|
||||||
$body = $response->json();
|
/*$body = $response->json();
|
||||||
$this->assertEquals(1, $this->count($body));
|
$this->assertEquals(1, $this->count($body));
|
||||||
$this->assertEquals($pirep_id, $body[0]['pirep_id']);*/
|
$this->assertEquals($pirep_id, $body[0]['pirep_id']);*/
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user