示例#1
0
 public function inverse($p)
 {
     $DEL_TOL = 1.0E-14;
     $lon = $p->x / $this->C;
     $lat = $p->y;
     $num = pow(tan(0.5 * $lat + Sourcemap_Proj::FORTPI) / $this->K, 1.0 / $this->C);
     for ($i = Sourcemap_Proj::MAX_ITER; $i > 0; --$i) {
         $lat = 2.0 * atan($num * Sourcemap_Proj::srat($this->e * sin($p->y), -0.5 * $this->e)) - Sourcemap_Proj::HALF_PI;
         if (abs($lat - $p->y) < $DEL_TOL) {
             break;
         }
         $p->y = $lat;
     }
     /* convergence failed */
     if (!$i) {
         throw new Exception("Convergence failed.");
     }
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }