yrehan32/php-haversine

使用哈夫曼算法计算两点之间距离的包

1.0.0 2022-12-27 15:25 UTC

This package is auto-updated.

Last update: 2024-09-27 19:32:35 UTC


README

通过Composer安装库

composer require yrehan32/php-haversine

安装库后,你可以在代码中使用它,如下所示

use Yrehan32\PhpHaversine\Haversine;

/*
 * Calculate the distance between two points
 * @param float   $latitudeFrom   Latitude of the first point
 * @param float   $longitudeFrom  Longitude of the first point
 * @param float   $latitudeTo     Latitude of the second point
 * @param float   $longitudeTo    Longitude of the second point
 * @param string  $separators     Number of digits after the comma (default: 2)
 * 
 * @return float Distance between the two points
 */
$distance = Haversine::calculate(
    52.2296756,
    21.0122287,
    52.406374,
    16.9251681
);
echo $distance; // It will print 278.46

许可证

此库根据LGPL-2.1许可证授权。