PHPackages                             roman-franko/proj4php - 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. roman-franko/proj4php

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

roman-franko/proj4php
=====================

A PHP port of Proj4JS. This is still very much work-in-progress.

0.6.5(1y ago)023MITPHPPHP &gt;=5.3.0

Since Oct 15Pushed 1y agoCompare

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

READMEChangelogDependenciesVersions (3)Used By (0)

Proj4JS Port to PHP5.3
======================

[](#proj4js-port-to-php53)

**Note: I'll fix any issues found here by Pull Request, and keep this package here, but it is not being actively developed. There is a full [Proj4JS PHP port here](https://github.com/proj4php/proj4php) - [packagist](https://packagist.org/packages/proj4php/proj4php) - with some great composer-based features, that is derived from [proj4JS](https://github.com/proj4js/proj4js). I am also experimenting with [some alternative approaches here](https://github.com/judgej/Proj4) that will hopefully feed into [proj4php](https://github.com/proj4php/proj4php). This package was started when proj4JS was a lot newer and less complete. Both that and proj4php have kept moving forward and surpassed it in support for a larger range of projections.**

I just wanted some simple conversions and transforms, and ended up with this. I must be a masachist.

Proj4JS has split out the MGRS handling to a separate module, possibly due to licensing issues. It is included in this library for the time-being, but has had a substantial refactor and rewrite from the original.

The main Mgrs classes have a mix of static methods that return new objects (Mgrs, LatLong, Square, Utm objects) and methods that operate on the current object. I intend to make it a little clearer which method does what. It has just inherited much of this from the JavaScript library, and partly from my learning curve in how the JavaScript library works.

Mgrs
----

[](#mgrs)

namespace: Academe\\Proj4Php\\Mgrs

The LatLong and Square classes implement minimal interfaces to support the UTM and MGRS classes as a standalone module (nothing in Academe\\Proj4Php\\Mgrs depends on anything else). This may change, depending on whether Mgrs is split off into a separate library, or coupled more tightly with the other coordinate classes on the main Proj4Php library. It will probably depend on inherited licenses.

The LatLong class holds a latitude and longitude.

```
$latitude = 53.0;
$longitude = -5.5;

$lat_long = new LatLong($latitude, $longitude);
$lat_long = new LatLong(array($latitude, $longitude));

```

The Square class holds two LatLong classes to mark the opposite corners of the bounding box.

```
$square = new Square($lat_long_bottom_left, $lat_long_top_right);

```

The Utm class holds a UTM coordinate.

```
// From base UTM values.
$utm = new Utm($northing, $easting, $zone_number, $zone_letter);

// From latitude/longitude coordinates (WGS84 ellipsoid).
$utm = Utm::fromLatLong($latitude, $longitude);
$utm = Utm::fromLatLong($lat_long);

// Back to lat/long.
$lat_long = $utm->toLatLong();

// To a UTM grid reference string.
$grid_reference = $utm->toGridReference(); // '39L 198447 8893330'
$grid_reference = (string)$utm;
$grid_reference = $utm->toGridReference('%z$l%EE%NN'); // '39L0198447E8893330N'

```

The UTM grid reference formatting fields are:

- %z Zone number
- %l Zone letter
- %h Hemisphere letter (N or S)
- %e Easting
- %n Northing
- %E Easting left-padded to 7 digits
- %N Northing left-padded to 7 digits

The Mgrs class extends Utm with its set of reference conversion methods.

```
// Create from base UTM values.
$mgrs = new Mgrs($northing, $easting, $zone_number, $zone_letter);

// From lat/long (same as for Utm)
$mgrs = Mgrs::fromLatLong($latitude, $longitude);
$mgrs = Mgrs::fromLatLong($lat_long);

// From a MGRS grid reference.
// The accuracy of the reference is noted and stored with the reference.
$mgrs = Mgrs::fromGridReference($mgrs_grid_reference);

// To a MGRS grid reference string.
// Template is optional, defaulting to '%z%l%k%e%n'.
// The accuracy is optional 0 to 5, defaulting to 5.
$grid_reference = $mgrs->toGridReference($template, $accuracy);

// To a single lat/long coordinate in the *centre* of the square according to
// teh accuracy, to one metre.
// $accuracy is optional, and defaults to the accuracy of the current coordinate.
$lat_long = $mgrs->toPoint($accuracy);

// The bottom left coordinate, disregarding the accuracy (like toPoint with the
// maximum accuracy of 5).
$lat_long = $mgrs->toLatLong();

// To a Square region.
// The accuracy is optional 0 to 5, defaulting to 5.
$square = $mgrs->toSquare($accuracy);

```

The MGRS grid reference formatting fields are:

- %z Zone number
- %l Zone letter
- %k 100km zone ID (two letters)
- %e Easting, to the current accuracy
- %n Northing, to the current accuracy

Instantiating a Utm, Mgrs, LatLong or Square class always requires a valid coordiate in some form.

References
==========

[](#references)

-
    Description of the UTM/MGRS grid systems
-
    Good converter site for testing against
- [http://en.wikipedia.org/wiki/Military\_grid\_reference\_system](http://en.wikipedia.org/wiki/Military_grid_reference_system)
    MGRS grid reference format definition and examples.
-
    Great description of how the UTM grid reference works, including the polar regions. Has an emphasis on how the system is used my map readers and users.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 Bus Factor1

Top contributor holds 89.1% 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

Unknown

Total

1

Last Release

580d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2291426b047fc0cd198f50bf65fe2490ead02f7a3e5bb84a033118db0e2dcd17?d=identicon)[roman-franko](/maintainers/roman-franko)

---

Top Contributors

[![judgej](https://avatars.githubusercontent.com/u/395934?v=4)](https://github.com/judgej "judgej (57 commits)")[![pjeweb](https://avatars.githubusercontent.com/u/684458?v=4)](https://github.com/pjeweb "pjeweb (3 commits)")[![roman-franko](https://avatars.githubusercontent.com/u/798373?v=4)](https://github.com/roman-franko "roman-franko (3 commits)")[![sergelavr](https://avatars.githubusercontent.com/u/46926223?v=4)](https://github.com/sergelavr "sergelavr (1 commits)")

---

Tags

proj4jsDatumproj4php

### Embed Badge

![Health badge](/badges/roman-franko-proj4php/health.svg)

```
[![Health](https://phpackages.com/badges/roman-franko-proj4php/health.svg)](https://phpackages.com/packages/roman-franko-proj4php)
```

###  Alternatives

[proj4php/proj4php

A PHP-Class for geographic coordinates transformation using proj4 definitions, thanks to a translation from Proj4JS

1321.7M16](/packages/proj4php-proj4php)

PHPackages © 2026

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