PHPackages                             patrickkempff/location - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. patrickkempff/location

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

patrickkempff/location
======================

A simple library for dealing with (geographical) locations.

6211PHP

Since Aug 15Pushed 9y ago2 watchersCompare

[ Source](https://github.com/patrickkempff/Location)[ Packagist](https://packagist.org/packages/patrickkempff/location)[ RSS](/packages/patrickkempff-location/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Location
========

[](#location)

[![Latest Unstable Version](https://camo.githubusercontent.com/010f990581165247848a6d3473a7e3fd62d98a454c86222d94016c20e60e2949/68747470733a2f2f706f7365722e707567782e6f72672f7061747269636b6b656d7066662f6c6f636174696f6e2f762f756e737461626c65)](https://packagist.org/packages/patrickkempff/location)[![License](https://camo.githubusercontent.com/faf6ed1fc4d2b03c1434d4a5b2cece9a8c6ee5c607f7efb89811865334d567a9/68747470733a2f2f706f7365722e707567782e6f72672f7061747269636b6b656d7066662f6c6f636174696f6e2f6c6963656e7365)](https://packagist.org/packages/patrickkempff/location)[![Build Status](https://camo.githubusercontent.com/a12a54bbc124caa3a5990b519a1eb03ae6fc83d9d11eae42c416992778139298/68747470733a2f2f7472617669732d63692e6f72672f7061747269636b6b656d7066662f4c6f636174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/patrickkempff/Location)[![Coverage Status](https://camo.githubusercontent.com/5be92ca85ebdfdb708f6ea2fea84f1a19bf3541d48221efc088cc5ea44d49c6b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7061747269636b6b656d7066662f4c6f636174696f6e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/patrickkempff/Location?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/b9df0be2f220d70e102b28ebe3a2625a65c74316e74d469eca17c243ce51c878/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f62353162656334392d623534372d346634332d626661662d3164633334373935336562332f6d696e692e706e67)](https://insight.sensiolabs.com/projects/b51bec49-b547-4f43-bfaf-1dc347953eb3)

A simple library for dealing with (geographical) locations.

```
use Location\Location;
use Location\Coordinate\Coordinate2d;
use Location\Distance\Haversine;

// Amsterdam, NL.
$amsterdam = new Location(new Coordinate2d(52.3079989, 4.9715451));

// Venlo, NL.
$venlo = new Location(new Coordinate2d(51.3703748, 6.1724031));

// The distance between Venlo and Amsterdam is 132950 meters (132km 950m)
// using the Haversine formula.
$distance = $amsterdam->calculateDistanceFromLocation($venlo, new Haversine());
```

*Please note that [UTM](https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system), [MGRS](https://en.wikipedia.org/wiki/Military_grid_reference_system) and [USNG](https://en.wikipedia.org/wiki/United_States_National_Grid) coordinate systems are not yet supported.*

Installation
------------

[](#installation)

### With Composer

[](#with-composer)

```
$ composer require patrickkempff/location

```

```
{
    "require": {
        "patrickkempff/location": "dev-master"
    }
}
```

```
