PHP code example of ixnode / php-gpx-reader

1. Go to this page and download the library: Download ixnode/php-gpx-reader 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/ */

    

ixnode / php-gpx-reader example snippets


use Ixnode\PhpGpxReader\GpxReader;

...


$gpxReader = new GpxReader($fileObject);

/* Set time gap from camera time: The clock goes ahead. */
$gpxReader->setTimeGapFromString('-00:13:00');

/* Set (real) time to search. */
$gpxReader->setDateTimeFromString('2024-05-05 13:04:16', new DateTimeZone(Timezones::EUROPE_BERLIN));

/* Get the closest coordinate from GPX file. */
$coordinate = $gpxReader->getCoordinate();

/* Time difference to next point. */
print $gpxReader->getTimeDifference();
// (int) 5

/* Latitude to the closest point. */
print $coordinate->getLatitude();
// (float) 47.099262

/* Longitude to the closest point. */
print $coordinate->getLongitude();
// (float) 9.942202

/* Google maps link. */
print $coordinate->getLinkGoogle().PHP_EOL;
// (string) https://www.google.de/maps/place/47.099262+9.942202

bash
vendor/bin/php-gpx-reader -V
bash
0.1.0 (2024-12-07 19:00:00) - Björn Hempel <[email protected]>
bash
vendor/bin/php-gpx-reader gpx:read data/gpx/2024-05-05.gpx --image="data/image/example-basic.jpg" --gap="\-00:13:00"
bash
git clone [email protected]:ixnode/php-gpx-reader.git && cd php-gpx-reader