Skip to content

Commit

Permalink
Merge pull request #32 from VMGWARE/27-bug-incorrect-approach-paramet…
Browse files Browse the repository at this point in the history
…ers-being-passed

Fix approach type submission in API
  • Loading branch information
Codycody31 authored Aug 26, 2023
2 parents 185e393 + dd65b22 commit 7807b01
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
22 changes: 13 additions & 9 deletions src/app/Custom/AtisGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class AtisGenerator
private array $parts = array();
private mixed $override_runways;
private mixed $output_type;
private array $approaches;
private array $weather_codes = array(
"VA" => "volcanic ash",
"HZ" => "haze",
Expand Down Expand Up @@ -72,7 +73,7 @@ class AtisGenerator
private array $spoken_runways = array("c" => "center", "l" => "left", "r" => "right");


public function __construct($icao = null, $ident = null, $landing_runways = [], $departing_runways = [], $remarks1 = null, $remarks2 = null, $override_runways = null, $output_type = null)
public function __construct($icao = null, $ident = null, $landing_runways = [], $departing_runways = [], $remarks1 = null, $remarks2 = null, $override_runways = null, $output_type = null, $approaches = [])
{
$this->icao = strtoupper($icao);
$this->ident = $ident;
Expand All @@ -83,6 +84,7 @@ public function __construct($icao = null, $ident = null, $landing_runways = [],
$this->override_runways = $override_runways;
$this->metar = explode(" ", Helpers::fetch_metar($this->icao));
$this->output_type = $output_type;
$this->approaches = $approaches;
}

/**
Expand Down Expand Up @@ -155,10 +157,9 @@ private function atis_ident(bool $speak = false): bool
if (isset($this->parts["atis_ident"])) {
return false;
}
if($this->output_type == "awos"){
if ($this->output_type == "awos") {
$this->parts["atis_ident"] = " automated weather observation";
}
else{
} else {
$this->parts["atis_ident"] = " information " . $this->spoken($this->ident, false, $speak);
}
return true;
Expand Down Expand Up @@ -620,15 +621,18 @@ private function approaches(mixed $parts)
return false;
}

// ddd($parts, sizeof($parts));

// If $parts contains ils, then the airport has ils approaches
if (sizeof($parts) == 1) {
$this->parts["approaches"] = $parts[0] . " approaches in use";

return true;
}

$this->parts["approaches"] = "simultaneous ils and visual approaches in use";
} else {
$this->parts["approaches"] = "simultaneous ils and visual approaches in use";

return true;
return true;
}
}

/**
Expand Down Expand Up @@ -775,7 +779,7 @@ public function parse_atis(mixed $speak)
next($metar);
}

$this->approaches(array("ils", "visual"));
$this->approaches($this->approaches);
$this->runways($this->landing_runways, $this->departing_runways, $speak);
$this->remarks1($this->remarks1);
$this->remarks2($this->remarks2);
Expand Down
6 changes: 4 additions & 2 deletions src/app/Http/Controllers/API/AirportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ public function atis(string $icao, Request $request): JsonResponse
remarks1: $request->remarks1,
remarks2: $request->remarks2,
override_runways: $request->override_runways,
output_type: $request['output-type']
output_type: $request['output-type'],
approaches: $request->approaches,
);
$text_atis = new AtisGenerator(
$icao,
Expand All @@ -247,7 +248,8 @@ public function atis(string $icao, Request $request): JsonResponse
remarks1: $request->remarks1,
remarks2: $request->remarks2,
override_runways: $request->override_runways,
output_type: $request['output-type']
output_type: $request['output-type'],
approaches: $request->approaches,
);

// Generate the ATIS
Expand Down
4 changes: 2 additions & 2 deletions src/resources/views/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@
<label class="form-label">4. Select Approaches (optional)</label>
</div>
<div class="col-md-6">
<input type="checkbox" class="form-check-input" id="ils" name="approaches[]">
<input type="checkbox" class="form-check-input" id="ils" name="approaches[]" value="ils">
<label class="form-check-label" for="ils">ILS Approaches</label>
</div>
<div class="col-md-6">
<input type="checkbox" class="form-check-input" id="visual" name="approaches[]">
<input type="checkbox" class="form-check-input" id="visual" name="approaches[]" value="visual">
<label class="form-check-label" for="visual">Visual Approaches</label>
</div>
</div>
Expand Down

0 comments on commit 7807b01

Please sign in to comment.