Skip to content

Commit

Permalink
Add catch for VATSIM XML downtime
Browse files Browse the repository at this point in the history
  • Loading branch information
atoff committed Apr 1, 2020
1 parent 809126e commit 2c5e69d
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/StandStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
class StandStatus
{

public $stands = array();
public $occupiedStands = array();
public $aircraftSearchResults;
public $stands = [];
public $occupiedStands = [];
public $aircraftSearchResults = [];

/*
Airport Stand Details
Expand Down Expand Up @@ -89,7 +89,7 @@ public function allStandsPaginationArray($pageLimit)
{
// Work out the ammount of pages
$noOfPages = ceil(count($this->stands) / $pageLimit);
$pageinationArray = array();
$pageinationArray = [];
for ($i = 0; $i < $noOfPages; $i++) {
$pageinationArray[] = $this->allStands($i, $pageLimit);
}
Expand All @@ -110,7 +110,7 @@ function parseData()
// Load the stand data
function loadStandsData()
{
$array = $fields = array();
$array = $fields = [];
$i = 0;
$handle = @fopen($this->airportStandsFile, "r");
if ($handle) {
Expand Down Expand Up @@ -149,7 +149,11 @@ function getAircraftWithinParameters()
$vatsim = new VatsimData();
$vatsim->loadData();

$pilots = $vatsim->getPilots()->toArray();
try {
$pilots = $vatsim->getPilots()->toArray();
}catch (Exception $e){
return false;
}

// INSERT TEST PILOTS
//$pilots[] = array('callsign' => "TEST", "latitude" => 55.949228, "longitude" => -3.364303, "altitude" => 0, "groundspeed" => 0, "planned_destairport" => "TEST", "planned_depairport" => "TEST");
Expand All @@ -162,7 +166,7 @@ function getAircraftWithinParameters()
}


$filteredResults = array();
$filteredResults = ;
foreach ($pilots as $pilot) {
if (($this->getCoordDistance($pilot['latitude'], $pilot['longitude'], $this->airportCoordinates['lat'], $this->airportCoordinates['long']) < $this->maxDistanceFromAirport)) {
if (($pilot['groundspeed'] <= $this->maxAircraftGroundspeed) && ($pilot['altitude'] <= $this->maxAircraftAltitude)) {
Expand All @@ -184,7 +188,7 @@ function checkIfAircraftAreOnStand()
foreach ($pilots as $pilot) {

// Array to hold the stands they could possibly be on
$possibleStands = array();
$possibleStands = ;

// Check each stand to see how close they are
foreach ($stands as $stand) {
Expand Down Expand Up @@ -305,7 +309,7 @@ function unsetStandOccupied($standID)

function standSides($standID)
{
$standSides = array();
$standSides = ;
$stands = $this->stands;

//Find the 'base' stand number
Expand Down

0 comments on commit 2c5e69d

Please sign in to comment.