0x13a/geodistance-php

Calculate geodistance between two points, latitude and longitude

0.4 2017-05-28 13:41 UTC

README

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

Extra

you can find the same php implementation here using functional approach

License

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