PHP code example of goosfraba / gps

1. Go to this page and download the library: Download goosfraba/gps 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/ */

    

goosfraba / gps example snippets


use Goosfraba\Gps\GpsCoordinates;
$coordinates = GpsCoordinates::createFromDegrees(38.8, -77.1);
// or
$coordinates = GpsCoordinates::createFromRadians(0.677187749773799875846392, -1.3456488532876281038081655);

// accessing coordinates in radians
$latitudeInRadians = $coordinates->latitudeInRadians();
$longitudeInRadians = $coordinates->longitudeInRadians();

// accessing coordinates in degrees
$latitudeInDegrees = $coordinates->latitudeInDegrees();
$longitudeInDegrees = $coordinates->longitudeInDegrees();

use Goosfraba\Gps\GpsCoordinates;

$coordinate1 = GpsCoordinates::createFromDegrees(51.5, 0);
$coordinate2 = GpsCoordinates::createFromDegrees(38.8, -77.1);

$distanceInMeters = $coordinate1->disntaceTo($coordinate2);

use Goosfraba\Gps\GpsCoordinates;

$coordinate1 = GpsCoordinates::createFromDegrees(51.5, 0);
$coordinate2 = GpsCoordinates::createFromDegrees(38.8, -77.1);

$midPointCoordinates = $coordinate1->pointBetween($coordinate2);
$coordinatesAt10Percent = $coordinate1->pointBetween($coordinate2, $coordinate1->distanceTo($coordinate2) / 10);

use Goosfraba\Gps\GpsCoordinates;

$coordinate = GpsCoordinates::createFromDegrees(51.5, 0);
$antipodes = $coordinate->antipodes();