/** * @expectedException \PHPUnit_Framework_Error_Warning */ public function testDistanceDifferentEllipsoids() { $work = new LatLng(51.54105, -0.12319, RefEll::Airy1830()); $charingCross = new LatLng(51.507977, -0.124588, RefEll::WGS84()); $expected = 3678.49665; self::assertEquals($expected, $work->distance($charingCross)); }
public function getReferenceEllipsoid() { return RefEll::WGS84(); }
/** * Convert a WGS84 latitude and longitude to an UTM reference * * Reference values for transformation are taken from OS document * "A Guide to Coordinate Systems in Great Britain" * @return UTMRef */ public function toUTMRef() { if ($this->refEll != RefEll::WGS84()) { trigger_error('Current co-ordinates are in a non-WGS84 datum', E_USER_WARNING); } $longitudeZone = (int) (($this->lng + 180) / 6) + 1; // Special zone for Norway if ($this->lat >= 56 && $this->lat < 64 && $this->lng >= 3 && $this->lng < 12) { $longitudeZone = 32; } // Special zones for Svalbard if ($this->lat >= 72 && $this->lat < 84) { if ($this->lng >= 0 && $this->lng < 9) { $longitudeZone = 31; } else { if ($this->lng >= 9 && $this->lng < 21) { $longitudeZone = 33; } else { if ($this->lng >= 21 && $this->lng < 33) { $longitudeZone = 35; } else { if ($this->lng >= 33 && $this->lng < 42) { $longitudeZone = 37; } } } } } $UTMZone = $this->getUTMLatitudeZoneLetter($this->lat); $UTM = new UTMRef(0, 0, $UTMZone, $longitudeZone); //dummy to get reference data $scale = $UTM->getScaleFactor(); $N0 = $UTM->getOriginNorthing(); $E0 = $UTM->getOriginEasting(); $phi0 = $UTM->getOriginLatitude(); $lambda0 = $UTM->getOriginLongitude(); $coords = $this->toTransverseMercatorEastingNorthing($scale, $E0, $N0, $phi0, $lambda0); if ($this->lat < 0) { $coords['N'] += 10000000; } return new UTMRef($coords['E'], $coords['N'], $UTMZone, $longitudeZone); }