PHPackages                             lootils/geo - 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. lootils/geo

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

lootils/geo
===========

A simple library for dealing with Earth geo coordinate manipulations.

0.1.1(12y ago)1624.7k↓41.7%3[2 issues](https://github.com/lootils/geo/issues)[2 PRs](https://github.com/lootils/geo/pulls)1MITPHPPHP &gt;=5.3.0

Since Dec 31Pushed 9y ago4 watchersCompare

[ Source](https://github.com/lootils/geo)[ Packagist](https://packagist.org/packages/lootils/geo)[ Docs](https://github.com/lootils/geo)[ RSS](/packages/lootils-geo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (1)

GEO
===

[](#geo)

This library, part of [Lootils](https://github.com/lootils), deals with earth coordinate system (geodetic) calculations. For example, finding the distance between two coordinate locations, converting coordinates to Degree Minute Second notation or finding the radius of the Earth at a latitude.

[![Build Status](https://camo.githubusercontent.com/1ca291c00c071b67843651b24487538a671847534cf90381041c19ad39997c28/68747470733a2f2f7472617669732d63692e6f72672f6c6f6f74696c732f67656f2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/lootils/geo)

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

[](#installation)

The recommended method of installation is with [composer](http://getcomposer.org/). Create a composer file with:

```
{
  "require": {
    "lootils/geo": "*"
  }
}

```

Aside from composer, Geo is PSR-0 compatible within the *src* directory. It can be used with any PSR-0 autoloader.

Usage
-----

[](#usage)

Start by including an autoloader to get the class. If you are using composer than it will look like:

```
require_once 'vendor/autoload.php';

```

From here we can start doing fun stuff with the `Location` class.

### Locations

[](#locations)

Locations are the individual places on the Earth to do equations against.

```
$location = new \Lootils\Geo\Location($latitude, $longitude);  // The numbers as dec format floats.
$cartesian = $location->cartesian();  // An array with keys of x, y, z.
$dmsLat = $location->DMSLatitude();  // Get the degrees, minutes, seconds format (e.g., 42 43 6.96 N)

```

See the *Location* class for more details.

### Distances

[](#distances)

There are currently two methods to calculate the distance between two points. The more accurate but more resource intensive to compute Vincenty's formula and the easier to compute but less accurate formula from Yee.

```
$distance = $location1->distance($location2);  // These two objects are instances of Location

```

This method uses the *default* formula. To specify a method you can use:

```
$distance = $location1->distance($location2, 'vincenty');
$distance = $location1->distance($location2, 'yee');

```

### Ranges

[](#ranges)

Ranges are important when we use the glowing rectangles we stare at a lot (e.g., cell phones). If you know your center point and radius a range can show you the edges of your screen. Using these coordinates you can query a database to find all the points in that area.

```
// Arrays with min and max keys for the range are returned.
$latRange = $location->latitudeRange($distance);
$longRange = $location->longitudeRange($distance);

```

### Conversions

[](#conversions)

On `Location` objects or on `Earth` objects calculations can be run. For example:

```
$nauticalMiles = $location->convertMetersToNauticalMiles($meters);
$dms = $location->convertDecToDMS($coordinate); // An array with the degrees, minutes, and seconds.

```

There are a few conversions. See the source of the *Earth* for all the options.

Motivation
----------

[](#motivation)

I was recently reading [*Longitude: The True Story of a Lone Genius Who Solved the Greatest Scientific Problem of His Time*](http://www.amazon.com/Longitude-Genius-Greatest-Scientific-Problem/dp/080271529X/) about how figuring your longitude accurately at sea could mean the difference between life and death. This book talked about how it was a significant technical problem in the past and how it was solved. Reading this book got me thinking about modern day equations for calculating position on the Earth. This is because the Earth is a [Geoid](https://en.wikipedia.org/wiki/Geoid) (similar to an ellipse) rather than a sphere. Instead of just reading the equations and studying them I decided to make a library since I couldn't find one on [Packagist](https://packagist.org/).

License
-------

[](#license)

This library is available under a MIT license.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~160 days

Total

2

Last Release

4725d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e009e68aaa3f72eb836b24c016afc08d8e7da904d10b65ba2982c9bcc6c02c19?d=identicon)[mattfarina](/maintainers/mattfarina)

---

Top Contributors

[![mattfarina](https://avatars.githubusercontent.com/u/62991?v=4)](https://github.com/mattfarina "mattfarina (5 commits)")[![RobLoach](https://avatars.githubusercontent.com/u/25086?v=4)](https://github.com/RobLoach "RobLoach (1 commits)")[![sobit](https://avatars.githubusercontent.com/u/1245542?v=4)](https://github.com/sobit "sobit (1 commits)")

---

Tags

geolocationmathgeocoordinatesgeodetic

### Embed Badge

![Health badge](/badges/lootils-geo/health.svg)

```
[![Health](https://phpackages.com/badges/lootils-geo/health.svg)](https://phpackages.com/packages/lootils-geo)
```

###  Alternatives

[brick/math

Arbitrary-precision arithmetic library

2.1k504.0M277](/packages/brick-math)[ipip/db

IPIP.net officially supported IP database ipdb format parsing library

139204.2k6](/packages/ipip-db)[data-values/geo

Geographical value objects, parsers and formatters

20631.0k18](/packages/data-values-geo)[tastaturberuf/anystores

Location management and geographic search

111.7k](/packages/tastaturberuf-anystores)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
