Exemplo n.º 1
0
 public function testLongitudeZoneSvalbard()
 {
     $latitude = 75;
     $longitudeSet = array(8 => 31, 16 => 33, 24 => 35, 40 => 37);
     foreach ($longitudeSet as $longitude => $expectedResult) {
         $zone = UTM::identifyLongitudeZone($latitude, $longitude);
         $this->assertEquals($expectedResult, $zone);
     }
 }
Exemplo n.º 2
0
 /**
  * Convert this Latitude/Longitude to a Univeral Transverse Mercator UTM object using a specified Datum
  *
  * @param     Datum    $datum    The Datum to use for this transform
  * @return    UTF      The Univeral Transverse Mercator UTM object that matches this Latitude/Longitude
  * @throws    Exception
  */
 public function toUTM(Datum $datum = null)
 {
     if (is_null($datum)) {
         throw new Exception('You must specify a datum to use for this conversion');
     }
     $ellipsoid = $datum->getReferenceEllipsoid();
     $eSquared = $ellipsoid->getFirstEccentricitySquared();
     $eSquared2 = $eSquared * $eSquared;
     $eSquared3 = $eSquared * $eSquared * $eSquared;
     $utmF0 = 0.9996;
     $utmLongitudeZone = UTM::identifyLongitudeZone($this->latitude->getValue(), $this->longitude->getValue());
     $utmLatitudeZone = UTM::identifyLatitudeZone($this->latitude->getValue());
     $longitudeOrigin = Angle::convertFromDegrees(($utmLongitudeZone - 1) * 6 - 180 + 3, Angle::RADIANS);
     $ePrimeSquared = $eSquared / (1 - $eSquared);
     $nValue = $ellipsoid->getSemiMajorAxis() / sqrt(1 - $eSquared * sin($this->latitude->getValue(Angle::RADIANS)) * sin($this->latitude->getValue(Angle::RADIANS)));
     $tValue = tan($this->latitude->getValue(Angle::RADIANS)) * tan($this->latitude->getValue(Angle::RADIANS));
     $cValue = $ePrimeSquared * cos($this->latitude->getValue(Angle::RADIANS)) * cos($this->latitude->getValue(Angle::RADIANS));
     $aValue = cos($this->latitude->getValue(Angle::RADIANS)) * ($this->longitude->getValue(Angle::RADIANS) - $longitudeOrigin);
     $mValue = $ellipsoid->getSemiMajorAxis() * ((1 - $eSquared / 4 - 3 * $eSquared2 / 64 - 5 * $eSquared3 / 256) * $this->latitude->getValue(Angle::RADIANS) - (3 * $eSquared / 8 + 3 * $eSquared2 / 32 + 45 * $eSquared3 / 1024) * sin(2 * $this->latitude->getValue(Angle::RADIANS)) + (15 * $eSquared2 / 256 + 45 * $eSquared3 / 1024) * sin(4 * $this->latitude->getValue(Angle::RADIANS)) - 35 * $eSquared3 / 3072 * sin(6 * $this->latitude->getValue(Angle::RADIANS)));
     $UTMEasting = $utmF0 * $nValue * ($aValue + (1 - $tValue + $cValue) * pow($aValue, 3.0) / 6 + (5 - 18 * $tValue + $tValue * $tValue + 72 * $cValue - 58 * $ePrimeSquared) * pow($aValue, 5.0) / 120) + 500000.0;
     $UTMNorthing = $utmF0 * ($mValue + $nValue * tan($this->latitude->getValue(Angle::RADIANS)) * ($aValue * $aValue / 2 + (5 - $tValue + 9 * $cValue + 4 * $cValue * $cValue) * pow($aValue, 4.0) / 24 + (61 - 58 * $tValue + $tValue * $tValue + 600 * $cValue - 330 * $ePrimeSquared) * pow($aValue, 6.0) / 720));
     // Adjust for the southern hemisphere
     if ($this->latitude->getValue(Angle::RADIANS) < 0) {
         $UTMNorthing += 10000000.0;
     }
     return new UTM($UTMNorthing, $UTMEasting, $utmLatitudeZone, $utmLongitudeZone);
 }