0x13a / geodistance-php
Calculate geodistance between two points, latitude and longitude
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 20 583
Dependents: 0
Suggesters: 0
Security: 0
Stars: 31
Watchers: 3
Forks: 5
Open Issues: 0
Requires
- php: >=5.3.3
Requires (Dev)
- phpstan/phpstan: ^0.10.5
- phpunit/phpunit: ~4.0
README
simple & minimal geodistance php library to calculate geo distance between two points (latitude, longitude) using Harvesine formula
Installation
composer require 0x13a/geodistance-php
Usage
<?php require_once __DIR__ . '/vendor/autoload.php'; use function Geodistance\centimeters; use function Geodistance\feet; use function Geodistance\kilometers; use function Geodistance\miles; use function Geodistance\meters; use function Geodistance\yards; use Geodistance\Location; $new_york = new Location(40.7128, 74.0059); $los_angeles = new Location(34.0522, 118.2437); $decimal_precision = 3; echo kilometers($new_york, $los_angeles); // 3936 echo miles($new_york, $los_angeles, $decimal_precision); // 2445.564 echo yards($new_york, $los_angeles); // 4304181 echo feet($new_york, $los_angeles); // 12912543 echo centimeters($new_york, $los_angeles); // 393575500 echo meters($new_york, $los_angeles); // 3935755
License
Geodistance PHP is licensed under the MIT license. See License File for more information.