PHP code example of nubs / coordinator

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

    

nubs / coordinator example snippets



use Nubs\Coordinator\Coordinate;

$coordinate = new Coordinate($latitudeInRadians, $longitudeInRadians);


use Nubs\Coordinator\CoordinateFactory;

$coordinateFactory = new CoordinateFactory();
$coordinate = $coordinateFactory->createFromRadians(
    $latitudeInRadians,
    $longitudeInRadians
);


use Nubs\Coordinator\CoordinateFactory;

$coordinateFactory = new CoordinateFactory();
$coordinate = $coordinateFactory->createFromDegrees(
    $latitudeInDegrees,
    $longitudeInDegrees
);

echo "Latitude: {$coordinate->latitudeInRadians()}\n";
echo "Longitude: {$coordinate->longitudeInRadians()}\n";

echo "Latitude: {$coordinate->latitudeInDegrees()}\n";
echo "Longitude: {$coordinate->longitudeInDegrees()}\n";

echo (string)$coordinate;


use Nubs\Coordinator\CoordinateFactory;
use Nubs\Coordinator\CoordinateSystem\Mercator;
use Nubs\Coordinator\Spheroid\Earth;

$mercator = new Mercator(new Earth(), new CoordinateFactory());
$coordinate = $mercator->loadCoordinate($xCoordinate, $yCoordinate);
echo (string)$coordinate;