Skip to content

Commit

Permalink
feature: Refactor, Testing and New Features!
Browse files Browse the repository at this point in the history
  • Loading branch information
atoff authored May 4, 2020
2 parents 790940c + 09399b8 commit 771a812
Show file tree
Hide file tree
Showing 40 changed files with 2,510 additions and 1,092 deletions.
Binary file added .github/docs/images/readme-header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Stand Status CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: "0 12 1 * *"

jobs:
build:
name: CI on PHP Version ${{ matrix.php_versions }}
runs-on: ubuntu-latest

strategy:
matrix:
php_versions: ['7.2', '7.3', '7.4']

steps:
- name: Checkout Repo
uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_versions }}

- name: Verify PHP Version
run: php -v

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPUNIT
run: vendor/bin/phpunit --coverage-text
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
vendor
composer.lock
.idea
build
.phpunit.result.cache
storage/data/*.csv
377 changes: 246 additions & 131 deletions README.md

Large diffs are not rendered by default.

57 changes: 37 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
{
"name": "cobaltgrid/vatsim-stand-status",
"description" : "A PHP library to access the status of aircraft stands on VATSIM",
"keywords" : ["vatsim", "stand", "stands", "flight simulator"],
"homepage" : "https://github.com/atoff/vatsim-stand-status",
"type" : "library",
"license" : "AGPL-3.0-or-later",
"authors" : [
{
"name" : "Alex Toff",
"email" : "[email protected]",
"homepage" : "https://www.cobaltgrid.com"
}
],
"require": {
"skymeyer/vatsimphp": "^2.0"
},
"autoload": {
"psr-4": {
"CobaltGrid\\VatsimStandStatus\\": "src/"
}
"name": "cobaltgrid/vatsim-stand-status",
"description": "A PHP library to access the status of aircraft stands on VATSIM",
"keywords": [
"vatsim",
"stand",
"stands",
"flight simulator"
],
"homepage": "https://github.com/atoff/vatsim-stand-status",
"type": "library",
"license": "AGPL-3.0-or-later",
"authors": [
{
"name": "Alex Toff",
"email": "[email protected]",
"homepage": "https://cobaltgrid.com"
}
],
"require": {
"php": ">=7.2",
"skymeyer/vatsimphp": "^2.0",
"guzzlehttp/guzzle": "^6.5"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
"mockery/mockery": "^1.3",
"symfony/var-dumper": "^5.0"
},
"autoload": {
"psr-4": {
"CobaltGrid\\VatsimStandStatus\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
}
}
256 changes: 135 additions & 121 deletions examples/egkkStands.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,128 +4,142 @@

require_once '../vendor/autoload.php';

$StandStatus = new StandStatus("EGKK", dirname(__FILE__) . "/standData/egkkstands.csv", 51.148056, -0.190278);

$StandStatus = new StandStatus(51.148056, -0.190278, StandStatus::COORD_FORMAT_CAA);
$StandStatus->loadStandDataFromCSV(dirname(__FILE__) . "/../tests/Fixtures/SampleData/egkkstands.csv")->parseData();
?>

<!-- GMaps & Labels -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key="></script>
<script src="js/maplabel-min.js"></script>

<script>
$(document).ready(function(){
var center = {lat: 51.158, lng: -0.1820};
map = new google.maps.Map(document.getElementById('map'), {
zoom: 14,
mapTypeId: 'satellite',
center: center,
disableDefaultUI: true

});
<?php
foreach($StandStatus->occupiedStands() as $stand){
?>
var cityCircle = new google.maps.Circle({
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35,
map: map,
center: {lat:
<?php
echo $stand['occupied']['latitude'];
?>, lng:
<?php
echo $stand['occupied']['longitude'];
?>},
radius: 40
});
var mapLabel = new MapLabel({
text: "<?php echo $stand['occupied']['callsign'] ?>",
position: new google.maps.LatLng(
<?php
echo $stand['occupied']['latitude'];
?>,
<?php
echo $stand['occupied']['longitude'];
?>),
map: map,
fontSize: 12,
strokeWeight: 2
<html>
<head>
<!-- Boostrap 4 -->
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

<script src="//cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="//cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css">

<!-- GMaps & Labels -->
<script src="https://maps.googleapis.com/maps/api/js?key="></script>
<script src="js/maplabel-min.js"></script>

<!-- Map Script -->
<script>
$(document).ready(function () {
var center = {lat: 51.158, lng: -0.1820};
map = new google.maps.Map(document.getElementById('map'), {
zoom: 14,
mapTypeId: 'satellite',
center: center,
disableDefaultUI: true

});

<? foreach($StandStatus->occupiedStands() as $stand){ ?>
new google.maps.Circle({
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35,
map: map,
center: {
lat: <?= $stand->occupier->latitude; ?>,
lng: <?= $stand->occupier->longitude; ?>
},
radius: 40
});
new MapLabel({
text: "<?= $stand->occupier->callsign ?>",
position: new google.maps.LatLng(
<?= $stand->occupier->latitude;?>,
<?= $stand->occupier->longitude; ?>
),
map: map,
fontSize: 12,
strokeWeight: 2
});
<? } ?>

$('#standsTable').DataTable();
});
<?php
}

?>
var cityCircle = new google.maps.Circle({
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35,
map: map,
center: {lat: 19.505434, lng:-98.919304},
radius: 100000
});

});
</script>
<div id="map" style="height: 500px;width: 700px;"></div>


<table border="1">
<tr>
<th>Stand</th>
<th>Occupied</th>
</tr>
<?php
foreach($StandStatus->occupiedStands() as $stand){
?>
<tr>
<td><?php echo $stand['id'] ?></td>
<td><?php echo $stand['occupied']['callsign'] ?></td>
</tr>
<?php
}

?>
</table>


<table border="1">
<tr>
<th>Stand</th>
<th>Lat</th>
<th>Long</th>
</tr>
<?php
foreach ($StandStatus->allStands() as $stand) {

?>
<tr>
<td><?php echo $stand['id'] ?></td>
<td><?php echo $stand['latcoord'] ?></td>
<td><?php echo $stand['longcoord'] ?></td>
<td><?php
if (isset($stand['occupied']['callsign'])){
echo $stand['occupied']['callsign'];
}
?></td>
</tr>
<?php

}
?>
</table>

<div>
<ul>
<?php
foreach($StandStatus->aircraftSearchResults as $pilot){
echo "<li>" . $pilot['callsign'] . "</li> " . $pilot['latitude'] . " BY " . $pilot['longitude'];
}
?>
</ul>
</script>


</head>
<body>
<div class="container">
<div class="row">
<div class="col-12 col-md-2 d-flex flex-column justify-content-center">
<h5>Occupied Stands</h5>
<table class="table table-responsive table-sm text-center align-self-center">
<tr>
<th>Stand</th>
<th>Occupied By</th>
</tr>
<?php
foreach ($StandStatus->occupiedStands() as $stand) {
?>
<tr>
<td><?= $stand->getName() ?></td>
<td><?= $stand->occupier->callsign ?></td>
</tr>
<?php
}

?>
</table>
</div>
<div class="col">
<div id="map" style="height: 500px;width: 100%;"></div>
</div>
</div>
<div class="row">
<div class="col d-flex flex-column justify-content-center">
<h5>All Stands</h5>
<table id="standsTable" class="table table-responsive table-sm text-center align-self-center">
<thead>
<tr>
<th>Stand</th>
<th>Latitude</th>
<th>Longitude</th>
<th>Occupier</th>
</tr>
</thead>
<tbody>
<? foreach ($StandStatus->stands() as $stand) { ?>
<tr>
<td><?= $stand->getName() ?></td>
<td><?= $stand->latitude ?></td>
<td><?= $stand->longitude ?></td>
<td><? echo $stand->isOccupied() ? $stand->occupier->callsign : null ?></td>
</tr>
<? } ?>
</tbody>
</table>
</div>
<div class="col">
<h5>Aircraft On The Ground</h5>
<div class="row">
<?php
foreach ($StandStatus->getAllAircraft() as $pilot) {
if($pilot->onStand()){
echo "<div class='col-5 bg-primary m-1 text-white'>{$pilot->callsign} ({$pilot->latitude},{$pilot->longitude}) (Stand {$pilot->getStandIndex()})</div>";
}else{
echo "<div class='col-5 bg-light m-1'>{$pilot->callsign} ({$pilot->latitude},{$pilot->longitude}) (Not on stand)</div>";
}
}
?>
</div>
</div>
</div>
</div>
</body>
</html>
Loading

0 comments on commit 771a812

Please sign in to comment.