Skip to content

Commit

Permalink
Update readme for recent batch of changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Jan 3, 2016
1 parent f7b24fa commit 8984124
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
PHPCoord
========

Conversion/modernisation/enhancement of phpcoord for PHP5.3+/PSR-4. Based on v2.3 of original project.
Conversion/modernisation/enhancement of phpcoord for PHP5.3+/PSR-4.

[![Build Status](https://travis-ci.org/dvdoug/PHPCoord.svg?branch=master)](https://travis-ci.org/dvdoug/PHPCoord)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/dvdoug/PHPCoord/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/dvdoug/PHPCoord/?branch=master)

The original code by Jonathan Stott can be found at http://www.jstott.me.uk/phpcoord/
Backwards compatibility has been maintained with class/function/member naming.

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
Expand All @@ -18,40 +19,38 @@ 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.

Please note that the OSGB conversion functions use the British datum (OSGB36), which is not
the same as used by e.g. GPS (WGS84). Conversion functions are provided and should be
used if <200m accuracy is important.

Output of calculations have been changed from the original code in the following two ways:
* When converting latitude and longitude between WGS84 and OSGB36 or vice-versa,
Output of calculations have been changed from the original code in various ways:
* [BUGFIX] When converting latitude and longitude between WGS84 and OSGB36 or vice-versa,
a wrong constant for the y translation has been corrected (was off by 1 metre)
* Eastings and northings are rounded to 1m, and lat/long to 5dp (approx 1m) to avoid any
misconceptions that precision is the same thing as accuracy
* When calculating surface distances, a more accurate mean radius is now used rather than
* [BUGFIX] Corrected issue with Helmert transform where the resulting co-ordinate could be placed into
the wrong quadrant
* [BUGFIX] When calculating surface distances, a more accurate mean radius is now used rather than
that derived from historical definitions of a nautical mile
* Corrected calculation of OS 6-figure grid references (rounding instead of truncating meant the
* [BUGFIX] Corrected calculation of OS 6-figure grid references (rounding instead of truncating meant the
grid square was sometimes off by 1)
* You must specify the reference ellipsoid when creating a LatLng object to avoid guesses as to what
was actually meant.
* Corrected issue with Helmert transform where the resulting co-ordinate could be placed into
the wrong quadrant
* [CHANGE] Eastings and northings are rounded to 1m, and lat/long to 5dp (approx 1m) to avoid any
misconceptions that precision is the same thing as accuracy
* [CHANGE] You must specify the reference ellipsoid when creating a LatLng object to avoid guesses as to what
was actually meant. If you don't know what that means, you probably want WGS84 which gives GPS
compatibility
* [CHANGE] Added Irish grid and ITM support
* [CHANGE] Co-ordinates are now 3D (i.e. w/height), not 2D

Usage
-----
```php
$OSRef = new OSRef(500000, 200000); //Easting, Northing
$LatLng = $OSRef->toLatLng();
$LatLng->OSGB36ToWGS84(); //optional, see note above

$lat = $LatLng->lat;
$long = $LatLng->lng;
$LatLng->toWGS84(); //optional, for GPS compatibility

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

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

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

```

Expand Down

0 comments on commit 8984124

Please sign in to comment.