Skip to content

Commit

Permalink
Allow ITM to WGS84. Fixes #24
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Apr 16, 2020
1 parent 4e11762 commit 1642c91
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/LatLng.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ public function toWGS84(): self
case RefEll::wgs84():
return $this; //do nothing

case RefEll::grs80(): //assumes ITM, GRS80 vs WGS84 is well within accuracy tolerance (<1mm) so don't need to do a Helmert
$this->refEll = RefEll::wgs84();
return $this;

case RefEll::airy1830(): // values from OSGB document "A Guide to Coordinate Systems in Great Britain"
$tx = 446.448;
$ty = -125.157;
Expand Down Expand Up @@ -269,9 +273,15 @@ public function toWGS84(): self
/**
* Transform co-ordinates from one datum to another using a Helmert transformation.
*
* @param float $rotX rotation about x-axis in seconds
* @param float $rotY rotation about y-axis in seconds
* @param float $rotZ rotation about z-axis in seconds
* @param RefEll $toRefEll Reference Ellipsoid
* @param float $tranX Translation in x-axis in metres
* @param float $tranY Translation in y-axis in metres
* @param float $tranZ Translation in z-axis in metres
* @param float $scale Scale factor
* @param float $rotX rotation about x-axis in seconds
* @param float $rotY rotation about y-axis in seconds
* @param float $rotZ rotation about z-axis in seconds
* @return LatLng
*/
public function transformDatum(RefEll $toRefEll, float $tranX, float $tranY, float $tranZ, float $scale, float $rotX, float $rotY, float $rotZ): self
{
Expand Down
10 changes: 10 additions & 0 deletions tests/ITMRefTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,14 @@ public function testFromLatLng(): void

self::assertEquals($expected, $ITMRef->__toString());
}

public function testToWGS84(): void
{
$ITMRef = new ITMRef(715830, 734697);
$LatLng = $ITMRef->toLatLng()->toWGS84();

$expected = '(53.34979, -6.26025)';

self::assertEquals($expected, $LatLng->__toString());
}
}

0 comments on commit 1642c91

Please sign in to comment.