jeroendesloovere/distance 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jeroendesloovere/distance

最新稳定版本:1.0.2.1

Composer 安装命令:

composer require jeroendesloovere/distance

包简介

Get distance between two locations using PHP.

README 文档

README

Latest Stable Version License Build Status

Get distance between two locations using PHP. The distance is getting calculated based on latitude and logitude variables and without using any other external class.

Usage

Installing using Composer

When using Composer you can always load in the latest version.

{
    "require": {
        "jeroendesloovere/distance": "1.0.*"
    }
}

Check in Packagist.

Example

Setting our example data

use JeroenDesloovere\Distance\Distance;

// first location
$latitude1 = '50.8538510000';
$longitude1 = '3.3550450000';

// second location
$latitude2 = '50.8325600000';
$longitude2 = '3.4787650000';

Get distance between two locations

$distance = Distance::between(
    $latitude1,
    $longitude1,
    $latitude2,
    $longitude2
);

// dump data
echo 'Distance between the two locations = ' . $distance . ' km';

Get closest distance from location 1 to one of the two locations (2 and 3)

// third location
$latitude3 = '50.8865040000';
$longitude3 = '3.4320850000';

// define multiple items
$items = array(
    array(
        'title' => 'location 2',
        'latitude' => $latitude2,
        'longitude' => $longitude2
    ),
    array(
        'title' => 'location 3',
        'latitude' => $latitude3,
        'longitude' => $longitude3
    )
);

$distance = Distance::getClosest(
    $latitude1,
    $longitude1,
    $items
);

// dump data
echo 'The closest location to location 1 is ' . $distance['title'] . ' and the distance between them is ' . $distance['distance'] . ' km';

Documentation

The class is well documented inline. If you use a decent IDE you'll see that each method is documented with PHPDoc.

Contributing

It would be great if you could help us improve this class. GitHub does a great job in managing collaboration by providing different tools, the only thing you need is a GitHub login.

  • Use Pull requests to add or update code
  • Issues for bug reporting or code discussions
  • Or regarding documentation and how-to's, check out Wiki More info on how to work with GitHub on help.github.com.

License

The module is licensed under MIT. In short, this license allows you to do everything as long as the copyright statement stays present.

统计信息

  • 总下载量: 60.93k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 37
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 35
  • Watchers: 3
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-04-08