This repository has been archived on 2024-10-16. You can view files and clone it, but cannot push or open issues or pull requests.
pflaenz.li-Symfony/src/Service/DistanceCalculator.php
2021-12-22 17:36:12 +01:00

27 lines
No EOL
565 B
PHP

<?php
namespace App\Service;
use Location\Coordinate;
use Location\Distance\Vincenty;
class DistanceCalculator
{
public function calculateDistance(Coordinate $coordinate1, Coordinate $coordinate2)
{
if ($coordinate1 == null || $coordinate2 == null)
{
$distance = "N/A";
}
else
{
$calculator = new Vincenty();
$distance = $calculator->getDistance($coordinate1, $coordinate2);
$distance = round($distance / 1000);
}
return $distance;
}
}