20 lines
403 B
PHP
20 lines
403 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Service;
|
||
|
|
||
|
use Location\Coordinate;
|
||
|
use Location\Distance\Vincenty;
|
||
|
|
||
|
class DistanceCalculator
|
||
|
{
|
||
|
public function calculateDistance(Coordinate $coordinate1, Coordinate $coordinate2)
|
||
|
{
|
||
|
$calculator = new Vincenty();
|
||
|
|
||
|
$distance = $calculator->getDistance($coordinate1, $coordinate2);
|
||
|
|
||
|
$distance = round($distance / 1000);
|
||
|
|
||
|
return $distance;
|
||
|
}
|
||
|
}
|