academe / osgb-tools

Ordnance Survey (GB) grid reference conversion tools
MIT License
5 stars 1 forks source link

Convert between datums #1

Open consilience opened 10 years ago

consilience commented 10 years ago

The main one is OSGB to and from WGS84. However, between any two datums would be good.

A JS implementation can be found here:

http://www.movable-type.co.uk/scripts/latlong-convert-coords.html

The rule is generally:

  1. Convert the polar coordinates (lat/long/height) to Cartesian coordinates, taking the source ellipsoid into account.
  2. The Helmert transform is applied, which puts a 3D shift, rotation and scale on the coordinates.
  3. The Cartesian coordinates are converted back to polar, taking the destination ellipsoid parameters into account.

So we are shifting to Cartesian space, transforming (which is easy) in that Cartesian space, then shifting back to polar space.

The example JS library will only convert between WGS84 and any of the other datums. That means WGS84 must always be either the source datum, the destination datum, or a mid-way hop between two other datums.

consilience commented 10 years ago

Other JS libraries from the same author port easily into PHP, so this should not be too difficult. We have a lat/long polar object, a OSGB national grid square, and we will probably also need to create a lat/long cartesian object too.