PHP code example of donyatorabi / geo-measure

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

    

donyatorabi / geo-measure example snippets



GeoMeasure\DTO\Point;
use GeoMeasure\Enums\Unit;
use GeoMeasure\Calculators\HaversineCalculator;

$calc = new HaversineCalculator();

$nyc = new Point(40.7128, -74.0060);
$la  = new Point(34.0522, -118.2437);

$km = $calc->distance($nyc, $la, Unit::Kilometer);
echo $km . " km\n";


GeoMeasure\DTO\Point;
use GeoMeasure\Enums\Unit;
use GeoMeasure\Calculators\VincentyCalculator;

$calc = new VincentyCalculator();

$berlin = new Point(52.5200, 13.4050);
$paris  = new Point(48.8566, 2.3522);

$km = $calc->distance($berlin, $paris, Unit::Kilometer);
echo $km . " km\n";