PHP code example of ayeo / geo

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

    

ayeo / geo example snippets


use Ayeo\Geo\Coordinate;
use Ayeo\Geo\DistanceCalculator;

//London: 51°30′N 0°07′W
$london = new Coordinate\Degree();
$london->setLatitude(51, 30, 00, 'N');
$london->setLongitude(00, 07, 00, 'W');

//Buenos Aires: 34°35′S 58°55′W
$buenosAires = new Coordinate\Degree();
$buenosAires->setLatitude(34, 35, 00, 'S');
$buenosAires->setLongitude(58, 55, 00, 'W');

$calculator = new DistanceCalculator();
$calculator->getDistance($london, $buenosAires); //result in meters

$example = new Coordinate\Decimal(53.2311, 18.1222);

$calculator = new DistanceCalculator();

$calculator->setMultiplier(1); //default value, returns distance in meters
$calculator->setMultiplier(1/1000); //kilometers
$calculator->setMultiplier(1/1000000); //thousands of kilometers

$calculator->setRadius(1737100); //Moon radius :)

$calculator->setPrecision(0); //returns integers