Esempio n. 1
0
 public function forward($p)
 {
     // Forward equations
     $lam = $p->x;
     $phi = $p->y;
     $lam = Common::adjust_lon($lam - $this->long0);
     if ($this->sphere) {
         $x = asin(cos($phi) * sin($lam));
         $y = atan2(tan($phi), cos($lam)) - $this->phi0;
     } else {
         // ellipsoid
         $this->n = sin($phi);
         $this->c = cos($phi);
         $y = Common::pj_mlfn($phi, $this->n, $this->c, $this->en);
         $this->n = 1.0 / sqrt(1.0 - $this->es * $this->n * $this->n);
         $this->tn = tan($phi);
         $this->t = $this->tn * $this->tn;
         $this->a1 = $lam * $this->c;
         $this->c *= $this->es * $this->c / (1 - $this->es);
         $this->a2 = $this->a1 * $this->a1;
         $x = $this->n * $this->a1 * (1.0 - $this->a2 * $this->t * ($this->C1 - (8.0 - $this->t + 8.0 * $this->c) * $this->a2 * $this->C2));
         $y -= $this->m0 - $this->n * $this->tn * $this->a2 * (0.5 + (5.0 - $this->t + 6.0 * $this->c) * $this->a2 * $this->C3);
     }
     $p->x = $this->a * $x + $this->x0;
     $p->y = $this->a * $y + $this->y0;
     return $p;
 }
Esempio n. 2
0
 public function forward($p)
 {
     #$x,y,delta_lon;
     $lon = $p->x;
     $lat = $p->y;
     /* Forward equations
        ----------------- */
     $lon = Common::adjust_lon($lon - $this->long0);
     if (isset($this->sphere)) {
         if (!$this->m) {
             $lat = $this->n != 1.0 ? asin($this->n * sin($lat)) : $lat;
         } else {
             $k = $this->n * sin($lat);
             for ($i = Common::MAX_ITER; $i; --$i) {
                 $V = ($this->m * $lat + sin($lat) - $k) / ($this->m + cos($lat));
                 $lat -= $V;
                 if (abs($V) < Common::EPSLN) {
                     break;
                 }
             }
         }
         $x = $this->a * $this->C_x * $lon * ($this->m + cos($lat));
         $y = $this->a * $this->C_y * $lat;
     } else {
         $s = sin($lat);
         $c = cos($lat);
         $y = $this->a * Common::pj_mlfn($lat, $s, $c, $this->en);
         $x = $this->a * $lon * $c / sqrt(1.0 - $this->es * $s * $s);
     }
     $p->x = $x;
     $p->y = $y;
     return $p;
 }