PHP code example of paulhollmann / vatsim-data

1. Go to this page and download the library: Download paulhollmann/vatsim-data library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

paulhollmann / vatsim-data example snippets


Datafeed::FetchedAt();                 // Package fetch time for the VATSIM datafeed
Datafeed::UpdatedAt();                 // VATSIM's own timestamp within the datafeed
Statusfile::FetchedAt();               // VATSIM status file
TransceiverData::FetchedAt();          // Transceiver feed
Metar::FetchedAt('EDDF');              // METAR for one ICAO code
StandStatus::OSMFetchedAt('EDDF');     // OSM stand data for one ICAO code

use VatsimData\Datafeed;

$feed = Datafeed::get();          // ?RootObject
$pilots = Datafeed::Pilots();     // Pilot[]
$controllers = Datafeed::Controllers(); // Controller[]
$atis = Datafeed::Atis();         // Atis[]
$history = Datafeed::PilotHistory(); // array<int, PilotPosition[]>
$tracks = Datafeed::PilotTracks(); // array<int, PilotTrack>

$pilots = Datafeed::PilotsNearAerodrome('EDDF', 50.033333, 8.570556, 2.0);
$tracks = Datafeed::PilotTracksForCids(array_map(fn ($pilot) => $pilot->cid, $pilots));
$controllers = Datafeed::ControllersForAerodrome('EDDF');

use Illuminate\Support\Facades\Schedule;

Schedule::command('vatsimdata:refresh')->everyFifteenSeconds()->withoutOverlapping();

foreach (Datafeed::Pilots() as $pilot) {
    echo $pilot->callsign;
    echo $pilot->latitude;
    echo $pilot->flight_plan?->departure;
}

Datafeed::PilotsArrivingAt('EDDF');
Datafeed::PilotsDepartingFrom('EDDF');

// Existing compatibility method; it delegates to PilotsArrivingAt().
Datafeed::PilotsArrivingAerodrome('EDDF');

use VatsimData\Helpers\Polygon;

$polygon = new Polygon('POLYGON((...))');
$pilots = Datafeed::PilotsWithinPolygon($polygon);

use VatsimData\Datafeed;
use VatsimData\Helpers\Callsign;

$active = Datafeed::ControllersActive();
$eddfControllers = Datafeed::ControllersForAerodrome('EDDF');
$withTransceivers = Datafeed::ControllersWithTransceiversForAerodrome('EDDF');

$callsign = Callsign::parse('EDDF_N_TWR');
$callsign->airport(); // 'EDDF'
$callsign->role;      // 'TWR'
$callsign->observer;  // false

$match = Datafeed::ControllerForStation('EDDF_TWR', 118.7);

$controller = $match?->controller;       // ?Controller
$ident = $match?->stationIdent;
$frequency = $match?->stationFrequency;

$summary = Datafeed::AerodromeSummary('EDDF');

$summary->departures;       // int
$summary->arrivals;         // int
$summary->controllers;      // Controller[]
$summary->atis;             // Atis[]
$summary->roles;            // array<string, bool>
$summary->hasRole('TWR');   // bool

$summaries = Datafeed::AerodromeSummaries(['EDDF', 'EDDM', 'LOWW']);
$eddf = $summaries['EDDF'];

use VatsimData\Metar;
use VatsimData\TransceiverData;

$atis = Datafeed::AtisAerodrome('EDDF');
$metar = Metar::get('EDDF');

$owner = TransceiverData::Owner('EDDF_N_TWR');
$transceivers = $owner?->transceivers ?? [];

use VatsimData\StandStatus;

$stands = new StandStatus(51.148056, -0.190278);

$stands->loadStandDataFromArray([
    ['43N', 51.15712, -0.17373],
    ['43W', 51.15712, -0.17373],
])->parseData();

foreach ($stands->occupiedStands() as $stand) {
    echo $stand->getName().' '.$stand->occupier->callsign;
}

$stands = new StandStatus(
    50.033333,
    8.570556,
    StandStatus::COORD_FORMAT_DECIMAL,
    'EDDF',
    364, // aerodrome elevation in feet MSL
);

// Or configure it after construction:
$stands->setAerodromeElevation(364);

$stands->parseData([
    [
        'callsign' => 'TEST1',
        'latitude' => 51.15712,
        'longitude' => -0.17373,
        'altitude' => 0,
        'groundspeed' => 0,
    ],
]);

$stands->loadStandDataFromArray([
    ['1', 51.154819, -0.164813],
    ['10', 51.155090, -0.164660],
]);

$stands->loadStandDataFromCSV(storage_path('stands.csv'));

$stands = new StandStatus(
    51.148056,
    -0.190278,
    StandStatus::COORD_FORMAT_CAA,
);

$stands = new StandStatus(51.4775, -0.461389); // EGLL
$stands->fetchAndLoadStandDataFromOSM('EGLL')->parseData();

$all = $stands->allStands();
$visible = $stands->stands();
$occupied = $stands->occupiedStands();
$unoccupied = $stands->unoccupiedStands();
$aircraft = $stands->allAircraft();

// Pass true for arrays keyed by stand identifier.
$standsByName = $stands->allStands(true);

use VatsimData\StandData\FlightStatus;

$stands = new StandStatus(50.033333, 8.570556, StandStatus::COORD_FORMAT_DECIMAL, 'EDDF');

$status = $stands->calculateFlightStatus($pilot);

if ($status === FlightStatus::TAXI_FOR_DEPARTURE) {
    // …
}

use Illuminate\Support\Facades\Schedule;

Schedule::command('vatsimdata:refresh')->everyFifteenSeconds();