PHPackages                             ixnode/php-coordinate - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. ixnode/php-coordinate

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

ixnode/php-coordinate
=====================

PHP Coordinate - This library offers a collection of various PHP coordinate classes like Coordinate, etc.

1.0.1(1y ago)31.1k3MITPHPPHP ^8.2

Since Jul 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ixnode/php-coordinate)[ Packagist](https://packagist.org/packages/ixnode/php-coordinate)[ RSS](/packages/ixnode-php-coordinate/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (25)Used By (3)

PHP Coordinate
==============

[](#php-coordinate)

[![Release](https://camo.githubusercontent.com/f11e05a777ac970b7e77eaf0fa21cecc96a06b6e3ed007e8be709cf253ae7d32/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f69786e6f64652f7068702d636f6f7264696e617465)](https://github.com/ixnode/php-coordinate/releases)[![](https://camo.githubusercontent.com/be7207f071a24c7a86a4a77414fb8f7887460ccf2f50f6e50c87cc0e06282324/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652d646174652f69786e6f64652f7068702d636f6f7264696e617465)](https://github.com/ixnode/php-coordinate/releases)[![](https://camo.githubusercontent.com/6432491cc17b57bafc62978f538816e14c8e80714d535acafb7a2d779cadad11/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f69786e6f64652f7068702d636f6f7264696e6174652e737667)](https://camo.githubusercontent.com/6432491cc17b57bafc62978f538816e14c8e80714d535acafb7a2d779cadad11/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f69786e6f64652f7068702d636f6f7264696e6174652e737667)[![PHP](https://camo.githubusercontent.com/9ffda6c94e9634fafbd5ff0f68f442ccb690a9b88c8613f79b9c2ec14f5e596b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e322d3737376262332e7376673f6c6f676f3d706870266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d353535353535267374796c653d666c6174)](https://www.php.net/supported-versions.php)[![PHPStan](https://camo.githubusercontent.com/29fcb055286f72da2b9c961f987152d1ac26a91d6cea221174abe7e01b5b7857/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c2532304d61782d3737376262332e7376673f7374796c653d666c6174)](https://phpstan.org/user-guide/rule-levels)[![PHPUnit](https://camo.githubusercontent.com/de101a446df383674178b80c404288664983cc6de751737d976d3df023942af9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850556e69742d556e697425323054657374732d3662396264322e7376673f7374796c653d666c6174)](https://phpunit.de)[![PHPCS](https://camo.githubusercontent.com/ee1fdc76b568e414c96c160eb608dd4680475a67d714661b70a3b3c43f6ded54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50485043532d50535231322d3431366434652e7376673f7374796c653d666c6174)](https://www.php-fig.org/psr/psr-12/)[![PHPMD](https://camo.githubusercontent.com/223a2afede2bd4bf4d524b7610277838a5d75504f7087fc6c36847b81a80ab43/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048504d442d414c4c2d3336346138332e7376673f7374796c653d666c6174)](https://github.com/phpmd/phpmd)[![Rector - Instant Upgrades and Automated Refactoring](https://camo.githubusercontent.com/9c119c037099401c8a61bd1ce556a58158eb09bfe452b2d132b94500e6368714/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f526563746f722d504850253230382e322d3733613136352e7376673f7374796c653d666c6174)](https://github.com/rectorphp/rector)[![LICENSE](https://camo.githubusercontent.com/e5ea4c19422baff789692dd36ee83fc11b6dc67d211dd4a56b4c721e509e8b27/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f69786e6f64652f7068702d6170692d76657273696f6e2d62756e646c65)](https://github.com/ixnode/php-api-version-bundle/blob/master/LICENSE)

> This library offers a collection of various PHP coordinate classes like Coordinate, etc. It converts various coordinate strings and values into a unique format.

1. Usage
--------

[](#1-usage)

```
use Ixnode\PhpCoordinate\Coordinate;
```

### 1.1 Converter example

[](#11-converter-example)

```
$coordinate = new Coordinate(51.0504, 13.7373);

print $coordinate->getLatitudeDMS();
// (string) 51°3′1.44″N

print $coordinate->getLongitudeDMS();
// (string) 13°44′14.28″E
```

### 1.2 Parser example

[](#12-parser-example)

```
$coordinate = new Coordinate('51°3′1.44″N 13°44′14.28″E');

print $coordinate->getLatitude();
// (float) 51.0504

print $coordinate->getLongitude();
// (float) 13.7373
```

### 1.3 Distance example

[](#13-distance-example)

```
$coordinateDresden = new Coordinate('51°3′1.44″N 13°44′14.28″E');
$coordinateCordoba = new Coordinate(-31.425299, -64.201743);

/* Distance between Dresden, Germany and Córdoba, Argentina */
print $coordinate->getDistance($coordinateCordoba, Coordinate::RETURN_KILOMETERS);
// (float) 11904.668
```

### 1.4 Direction example (degree)

[](#14-direction-example-degree)

```
$coordinateDresden = new Coordinate('51°3′1.44″N 13°44′14.28″E');
$coordinateCordoba = new Coordinate(-31.425299, -64.201743);

/* Direction in degrees from Dresden, Germany to Córdoba, Argentina */
print $coordinateDresden->getDegree($coordinateCordoba);
// (float) -136.62°
```

### 1.5 Direction example (cardinal direction)

[](#15-direction-example-cardinal-direction)

```
$coordinateDresden = new Coordinate('51°3′1.44″N 13°44′14.28″E');
$coordinateCordoba = new Coordinate(-31.425299, -64.201743);

/* Direction in degrees from Dresden, Germany to Córdoba, Argentina */
print $coordinateDresden->getDirection($coordinateCordoba);
// (string) SW
```

2. Parser
---------

[](#2-parser)

### 2.1 Basic decimal degree parser

[](#21-basic-decimal-degree-parser)

#### 2.1.1 Parser formats

[](#211-parser-formats)

Given value (string)Latitude (float)Longitude (float)Place`"51.0504,13.7373"`*51.0504**13.7373*Dresden, Germany`"51.0504, 13.7373"`*51.0504**13.7373*Dresden, Germany`"51.0504 13.7373"`*51.0504**13.7373*Dresden, Germany`"POINT(-31.425299, -64.201743)"`*-31.425299**-64.201743*Córdoba, Argentina`"POINT(-31.425299 -64.201743)"`*-31.425299**-64.201743*Córdoba, Argentina#### 2.1.2 Code example

[](#212-code-example)

```
$coordinate = new Coordinate('51.0504 13.7373');

print $coordinate->getLatitude();
// (float) 51.0504

print $coordinate->getLongitude();
// (float) 13.7373
```

### 2.2 Basic DMS Parser

[](#22-basic-dms-parser)

#### 2.2.1 Parser formats

[](#221-parser-formats)

Given value (string)Latitude (float)Longitude (float)Place`"51°3′1.44″N,13°44′14.28″E"`*51.0504**13.7373*Dresden, Germany`"51°3′1.44″N, 13°44′14.28″E"`*51.0504**13.7373*Dresden, Germany`"51°3′1.44″N 13°44′14.28″E"`*51.0504**13.7373*Dresden, Germany`"POINT(31°25′31.0764″S, 64°12′6.2748″W)"`*-31.425299**-64.201743*Córdoba, Argentina`"POINT(31°25′31.0764″S 64°12′6.2748″W)"`*-31.425299**-64.201743*Córdoba, Argentina#### 2.2.2 Code example

[](#222-code-example)

```
$coordinate = new Coordinate('51°3′1.44″N 13°44′14.28″E');

print $coordinate->getLatitude();
// (float) 51.0504

print $coordinate->getLongitude();
// (float) 13.7373
```

### 2.3 Google Url Parser Parser

[](#23-google-url-parser-parser)

#### 2.3.1 Parser formats

[](#231-parser-formats)

Given value (string)Latitude (float)Longitude (float)PlaceCopied Google Maps Short Url`1)`*54.07304830**18.992402*Malbork, PolandCopied Google Maps Link`2)`*51.31237**12.4132924*Leipzig, Germany- `1)` [Copied Google Maps Short Url](https://maps.app.goo.gl/PHq5axBaDdgRWj4T6)
- `2)` [Copied Google Maps Link](https://www.google.com/maps/place/V%C3%B6lkerschlachtdenkmal,+04277+Leipzig/@51.3123709,12.4132924,17z/data=!3m1!4b1!4m6!3m5!1s0x47a6f9a9d013ca23:0x277b49a142da988c!8m2!3d51.3123709!4d12.4132924!16s%2Fg%2F12ls2f87w?entry=ttu)

#### 2.3.2 Code example

[](#232-code-example)

```
$coordinate = new Coordinate('https://maps.app.goo.gl/PHq5axBaDdgRWj4T6');

print $coordinate->getLatitude();
// (float) 54.07304830

print $coordinate->getLongitude();
// (float) 18.992402
```

3. Converter
------------

[](#3-converter)

### 3.1 Methods of class `Coordinate`

[](#31-methods-of-class-coordinate)

MethodTypeParameter(s)DescriptionExample`getLatitude`*float*---Returns the decimal degree presentation of latitude value.*-31.425299*`getLongitude`*float*---Returns the decimal degree presentation of longitude value.*-64.201743*`getLatitudeDD`*float*---Alias of `getLatitude`.*-31.425299*`getLongitudeDD`*float*---Alias of `getLongitude`.*-64.201743*`getLatitudeDMS`*string*---Returns the dms representation of the latitude value.`"31°25′31.0764″S"``getLongitudeDMS`*string*---Returns the dms representation of the longitude value.`"64°12′6.2748″W"``getLatitudeDMS`*string*`CoordinateValue::FORMAT_DMS_SHORT_2`Returns the dms representation of the latitude value (v2).`"S31°25′31.0764″"``getLongitudeDMS`*string*`CoordinateValue::FORMAT_DMS_SHORT_2`Returns the dms representation of the longitude value (v2).`"W64°12′6.2748″"``getDistance`*float*`new Coordinate()`, `meters` (default) or `kilometers`Returns the distance to given second Coordinate instance.*11904.668*`getDegree`*float*`new Coordinate()`Returns the direction (degree) to given second Coordinate instance (0° - North, 90° - East, etc.).*-136.62*`getDirection`*string*`new Coordinate()`Returns the cardinal direction to given second Coordinate instance (`N`, `NE`, `E`, `SE`, `S`, `SW`, `W`, `NW`).`"SW"``getLinkGoogle`*string*`false` (default - as decimal) or `true` (as DMS)Returns the link to Google.[Google](https://www.google.de/maps/place/51.050400+13.737300)`getLinkOpenStreetMap`*string*---Returns the link to OpenStreetMap.[OpenStreetMap](https://www.openstreetmap.org/?lat=51.050400&lon=13.737300&mlat=51.050400&mlon=13.737300&zoom=14&layers=M)### 3.2 Code example

[](#32-code-example)

```
$coordinate = new Coordinate('-31.425299, -64.201743');

print $coordinate->getLatitudeDMS();
// (string) "31°25′31.0764″S"

print $coordinate->getLongitudeDMS();
// (string) "64°12′6.2748″W"
```

4. Installation
---------------

[](#4-installation)

```
composer require ixnode/php-coordinate
```

```
vendor/bin/php-coordinate -V
```

```
php-coordinate 0.1.0 (03-07-2023 01:17:26) - Björn Hempel
```

5. Command line tool
--------------------

[](#5-command-line-tool)

> Used to quickly check two given coordinates.

Check *Dresden, Germany* and *New York, United States*:

```
bin/console pc "51°3′1.44″N, 13°44′14.28″E" "40.712784, -74.005941"
```

or within your composer project:

```
vendor/bin/php-coordinate pc "51°3′1.44″N, 13°44′14.28″E" "40.712784, -74.005941"
```

```
Source coordinate (51°3′1.44″N, 13°44′14.28″E):

+---------+------------------+--------------------+
| Value   | Latitude         | Longitude          |
+---------+------------------+--------------------+
| Decimal | 51.0504          | 13.7373            |
| DMS     | 51°3′1.44″N      | 13°44′14.28″E      |
+---------+------------------+--------------------+

Target coordinate (40.712784, -74.005941):

+---------+----------------------+---------------------+
| Value   | Latitude             | Longitude           |
+---------+----------------------+---------------------+
| Decimal | 40.712784            | -74.005941          |
| DMS     | 40°42′46.0224″N      | 74°0′21.3876″W      |
+---------+----------------------+---------------------+

Distance:

+-----------+-------------+
| Key       | Value       |
+-----------+-------------+
| Distance  | 6478.472 km |
| Degree    | -96.720°    |
| Direction | W           |
+-----------+-------------+

+--------------------------------------------------------------------------------+
|                                   World map                                    |
+--------------------------------------------------------------------------------+
|                                                                                |
|                     ▄▄▄▄▀▄▄▄▄▄▄▄▄▄▄                                            |
|       ▄▄    ▄▄▄▄▄▄▄▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀                ▄▄▄▄▀▀▀▀▀▄▄▄▄▄▄▄▄▄▄          |
|  ▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀      ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀  |
| ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀   ▀▀          ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀   |
|       ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀           ▄▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄ ▀▀    |
|     ▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀            ▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀       |
|     ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀               ▀▀▀▀▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄        |
|     ▀▀▀▀▀▀▀▀▀▀▀▀                 ▀▀▀▀▀▀▀▀▀▀▄▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀        |
|      ▀▀▀▀▀▀▄▄ ▀                ▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀         |
|        ▀▀▀▀▀▀                  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀▀▀▀▀▀           |
|           ▀▀▀▄▄▀▀▄▄▄           ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀      ▀▀    ▀▀▀▀            |
|              ▀▀▀▀▀▀▀▀▀▄         ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀            ▀▄  ▄▀▀         |
|              ▀▀▀▀▀▀▀▀▀▀▀▄▄▄           ▀▀▀▀▀▀▀▀▀▀▀              ▀▀▀▀▀▀▀   ▀▄▄▄▄ |
|              ▀▀▀▀▀▀▀▀▀▀▀▀▀▀            ▀▀▀▀▀▀▀▀▀                 ▀        ▀▀▀▀▄|
|               ▀▀▀▀▀▀▀▀▀▀▀▀             ▀▀▀▀▀▀▀▀▀▄▀▀                   ▄▀▀▀▀▀▀  |
|                  ▀▀▀▀▀▀▀▀▀             ▀▀▀▀▀▀▀▀ ▀▀                 ▀▀▀▀▀▀▀▀▀▀▀ |
|                  ▀▀▀▀▀▀▀                ▀▀▀▀▀▀  ▀                  ▀▀▀▀▀▀▀▀▀▀▀ |
|                  ▀▀▀▀▀▀                  ▀▀▀                       ▀▀▀▀▀▀▀▀▀▀▀ |
|                  ▀▀▀▀                                                     ▀    |
|                   ▀▀▀                                                          |
+--------------------------------------------------------------------------------+

+------------------------------------+   +---------------------------------------+
|         Cardinal direction         |   |         Longitude / Langitude         |
+------------------------------------|   +---------------------------------------|
|                                    |   |          lat                          |
|                  0°                |   |                                       |
|                                    |   |       90° ⯅                           |
|                 ___                |   |           |                           |
|    -45°         ───        45°     |   |           |                           |
|          //      N      \\         |   |           |   • Oslo (59.91°, 10.75°) |
|             NW       NE            |   |           | • London (51.51°, -0.13°) |
|                  |                 |   |    • New York (40.71°, -74.01°)       |
|  -90°  || W    --+--    E ||  90°  |   |           |                           |
|                  |                 |   |           |                           |
|             SW       SE            |   |           |                           |
|          \\      S      //         |   |           | • Null Island (0°, 0°)    |
|    -135°        ───        135°    |   |   ⯇-------+-------------------⯈  lon  |
|                 ‾‾‾                |   |  -180°    |                 180°      |
|                                    |   |           |                           |
|                 180°               |   |           |       • Cape Agulhas      |
|                                    |   |      -90° ⯆         (-34.82°, 20.02°) |
+------------------------------------+   +---------------------------------------+
```

[![Services](docs/image/world-map-cli.png)](docs/image/world-map-cli.png)

6. Library development
----------------------

[](#6-library-development)

```
git clone git@github.com:ixnode/php-coordinate.git && cd php-coordinate
```

```
composer install
```

```
composer test
```

7. License
----------

[](#7-license)

This library is licensed under the MIT License - see the [LICENSE](/LICENSE) file for details.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~23 days

Recently: every ~120 days

Total

24

Last Release

527d ago

Major Versions

0.1.21 → 1.0.02024-12-07

### Community

Maintainers

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

---

Top Contributors

[![bjoern-hempel](https://avatars.githubusercontent.com/u/5531245?v=4)](https://github.com/bjoern-hempel "bjoern-hempel (54 commits)")

---

Tags

phpparserconversionlatitudelongitudecoordinate

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ixnode-php-coordinate/health.svg)

```
[![Health](https://phpackages.com/badges/ixnode-php-coordinate/health.svg)](https://phpackages.com/packages/ixnode-php-coordinate)
```

###  Alternatives

[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k910.8M118](/packages/doctrine-lexer)[simplehtmldom/simplehtmldom

A fast, simple and reliable HTML document parser for PHP.

1921.3M14](/packages/simplehtmldom-simplehtmldom)[creof/geo-parser

Parser for geography coordinate strings

624.4M15](/packages/creof-geo-parser)[corveda/php-sandbox

A PHP library that can be used to run PHP code in a sandboxed environment

23483.5k2](/packages/corveda-php-sandbox)[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6115.6k](/packages/sbsaga-toon)[leonelquinteros/php-toml

PHP parser for TOML language ( https://github.com/toml-lang/toml )

266.7k](/packages/leonelquinteros-php-toml)

PHPackages © 2026

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