예제 #1
0
파일: Datum.php 프로젝트: judgej/Proj4
 /**
  * Convert a geocentric point from the WGS84 datum.
  */
 public function fromWgs84(Geocentric $point)
 {
     if ($this->type == static::TYPE_3TERM) {
         $x = $point->x - $this->params[0];
         $y = $point->y - $this->params[1];
         $z = $point->z - $this->params[2];
     } elseif ($this->type == static::TYPE_7TERM) {
         $Dx_BF = $this->params[0];
         $Dy_BF = $this->params[1];
         $Dz_BF = $this->params[2];
         // These need converting from seconds of arc to radians.
         $Rx_BF = $this->params[3] * static::SEC_TO_RAD;
         $Ry_BF = $this->params[4] * static::SEC_TO_RAD;
         $Rz_BF = $this->params[5] * static::SEC_TO_RAD;
         // Convert parts per million to a multiplier
         $M_BF = 1 + $this->params[6] * static::PPM_TO_MULT;
         $x_tmp = ($point->x - $Dx_BF) / $M_BF;
         $y_tmp = ($point->y - $Dy_BF) / $M_BF;
         $z_tmp = ($point->z - $Dz_BF) / $M_BF;
         $x = $x_tmp + $Rz_BF * $y_tmp - $Ry_BF * $z_tmp;
         $y = -$Rz_BF * $x_tmp + $y_tmp + $Rx_BF * $z_tmp;
         $z = $Ry_BF * $x_tmp - $Rx_BF * $y_tmp + $z_tmp;
     } else {
         throw new Excreption('Unknown datum transformation parameter type');
     }
     // Give the point the new datum.
     $new_point = $point->withOrdinates($x, $y, $z)->withDatum($this);
     return $new_point;
 }