Calculate geodistance between two points, latitude and longitude using haversine formula
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
tests
.gitignore
.travis.yml
LICENSE
README.md
composer.json
composer.lock
phpunit.xml.dist

README.md

Geodistance

Build Status Latest Stable Version Total Downloads License composer.lock

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';

$new_york          = new \Geodistance\Location(40.7128, 74.0059);
$los_angeles       = new \Geodistance\Location(34.0522, 118.2437);
$decimal_precision = 3;

echo \Geodistance\kilometers($new_york, $los_angeles); // 3936
echo \Geodistance\miles($new_york, $los_angeles, $decimal_precision); // 2445.564
echo \Geodistance\yards($new_york, $los_angeles); // 4304181
echo \Geodistance\feet($new_york, $los_angeles); // 12912543
echo \Geodistance\centimeters($new_york, $los_angeles); // 393575500
echo \Geodistance\meters($new_york, $los_angeles); // 3935755

License

Geodistance PHP is licensed under the MIT license. See License File for more information.