php-coord/php-coord

PHPCoord is a set of PHP functions for handling various co-ordinate systems and converting between them

Fund package maintenance!
dvdoug

v3.1.2 2020-08-14 18:03 UTC

This package is auto-updated.

Last update: 2020-10-06 10:56:05 UTC


README

Conversion/modernisation/enhancement of phpcoord. Build Status Scrutinizer Code Quality Download count Current version

The original code by Jonathan Stott can be found at http://www.jstott.me.uk/phpcoord/

PHPCoord is a set of PHP functions for handling various co-ordinate systems and converting between them. Currently, OSGB (Ordnance Survey of Great Britain) grid references, traditional Irish Grid references, the newer ITM (Irish Transverse Mercator) system, UTM (Universal Transverse Mercator) references and latitude/longitude are supported.

Conversions between latitudes/longitudes in WGS84 (GPS), OSGB36, ED50 and NAD27 datums are built-in, and helper functions exist to ease conversion between other datums.

A function is also provided to find the surface distance between two points of latitude and longitude.

Usage

namespace PHPCoord;

$OSRef = new OSRef(500000, 200000); //Easting, Northing
$LatLng = $OSRef->toLatLng();
$GPSLatLng = $LatLng->toWGS84(); //optional, for GPS compatibility

$lat =  $LatLng->getLat();
$long = $LatLng->getLng();

$LatLng = new LatLng(50.12345, 1.23456, 0, RefEll::wgs84()); //Latitude, Long, height
$OSRef = $LatLng->toOSRef(); 

$easting = $OSRef->getX();
$northing = $OSRef->getY();

Installation

If you use Composer, just add php-coord/php-coord to your project's composer.json file:

    composer require php-coord/php-coord

Otherwise, the library is PSR-4 compliant, so will work with the autoloader of your choice.

License

The original PHPcoord is GPL-licensed, and this version inherits that. Terms can be found at http://www.gnu.org/licenses/gpl.html