承接 roslov/location 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

roslov/location

最新稳定版本:1.0.0

Composer 安装命令:

composer require roslov/location

包简介

Location calculator

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

This package provides calculations based on longitude and latitude.

Features

It calculates distance between two locations.

It uses the “haversine” formula to calculate the great-circle distance between two points — that is, the shortest distance over the earth’s surface — giving an “as-the-crow-flies” distance between the points.

Formula:

a = sin²( Δφ / 2 ) + cos φ1 × cos φ2 × sin²( Δλ / 2 )
c = 2 × atan2( √a, √( 1 − a ) )
d = R × c

where φ is latitude, λ is longitude, R is the earth’s radius (mean radius = 6371 km).

Requirements

  • PHP 7.2 or higher.

Installation

The package could be installed with composer:

composer require roslov/location

General usage

Validator allows to check data in any format. For example, when data is an object:

use Roslov\Location\LocationCalculator;

$locationCalculator = new LocationCalculator();
$distance = $locationCalculator->getDistance(49.841905, 24.031511, 50.450885, 30.522798);
echo $distance; // 467.32327173219

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-17