PHP wrapper for Python script igc2kmz, an IGC to Google Earth converter.
igc2kmz-php allows you to use Python script igc2kmz, an IGC to Google Earth converter, with your PHP application.
In a nutshell: you can convert IGC files to KMZ files.
IGC is a Data File Standard, developed by the IGC GPS Subcommittee and the Gliding Flight Data Recorder Manufacturers (…) to facilitate the introduction of GPS technology into gliding and in particular into competition verification and the homologation of badge and record flights, using GPS, by the FAI.
KML is an XML notation for expressing geographic annotation and visualization within Internet-based, two-dimensional maps and three-dimensional Earth browsers. KMZ files are zipped KML files consisting of a single root KML document and optionally any overlays, images and icons.
- igc2kmz Python script
- Python version 2.x, not version 3.0 (as required by igc2kmz)
- PHP 7.1 or greater
- igc2kmz is a Python script to convert IGC files to KMZ files.
- igc2kmz-php is a PHP wrapper around the igc2kmz Python script.
The recommended way to install igc2kmz-php is by using composer:
$ composer require m165437/igc2kmz-php
This will install the PHP package with your application. Please keep in mind that the Python script igc2kmz is not included.
Head over to m165437/igc2kmz-installer.
- Get an instance of the
\Igc2KmzPhp\Igc2KmzInterface
implementation,\Igc2KmzPhp\Igc2Kmz
. Pass the path to the igc2kmz binary to the constructor. - Set the igc file and options on your
\Igc2KmzPhp\Igc2Kmz
instance. - Run your command.
$igc2kmz = new Igc2Kmz('vendor/bin/igc2kmz');
This package includes a Laravel service provider and registers itself via Package Discovery.
Type-hint the class in a constructor or method that is resolved by Laravel's service container. It's automatically resolved and injected into the class.
public function __construct(Igc2Kmz $igc2kmz)
{
$this->igc2kmz = $igc2kmz;
}
If you need to change the default binary path vendor/bin/igc2kmz
, create a config file config/igc2kmz.php
and set the path in there.
return [
'binary' => 'alternative/path/igc2kmz'
];
Keep in mind that igc2kmz-php is designed to keep its state, run
\Igc2KmzPhp\Igc2KmzInterface::resetOptions
and\Igc2KmzPhp\Igc2KmzInterface::resetPhotos
to get rid of the options and photos you set for the next call on the instance.
Make sure your igc path is correct and readable, and your output path is writable.
$igc2kmz
->igc('path/to/flight.igc')
->output('path/to/output.kmz')
->run();
For individual flights you can override the pilot name and glider type (otherwise they are taken from the IGC file).
$igc2kmz
->igc('path/to/flight.igc')
->output('path/to/output.kmz')
->pilotName('Jane Doe')
->gliderType('NOVA Mentor 5')
->run();
$igc2kmz
->igc('path/to/flight.igc')
->output('path/to/output.kmz')
->addPhoto('https://domain.tld/photo_1.jpg', 'Comment on first image')
->addPhoto('https://domain.tld/photo_2.jpg', 'Comment on second image')
->run();
$process = $igc2kmz
->igc('path/to/flight.igc')
->output('path/to/output.kmz')
->build();
// do stuff with the process
$igc2kmz
->run($process);
Run the tests with:
vendor/bin/phpunit
Credit goes to Tom Payne for creating igc2kmz.
Thank you for considering contributing to this package! Please see CONTRIBUTING for details.
igc2kmz-php is licensed under the MIT License (MIT). Please see the LICENSE file for more information.