Exemple #1
0
 /**
  * Albers Conical Equal Area forward equations--mapping lat,long to x,y
  *
  * @param Point $p
  * @return Point $p 
  */
 public function forward($p)
 {
     $lon = $p->x;
     $lat = $p->y;
     $this->sin_phi = sin($lat);
     $this->cos_phi = cos($lat);
     $qs = Common::qsfnz($this->e3, $this->sin_phi, $this->cos_phi);
     $rh1 = $this->a * sqrt($this->c - $this->ns0 * $qs) / $this->ns0;
     $theta = $this->ns0 * Common::adjust_lon($lon - $this->long0);
     $x = rh1 * sin($theta) + $this->x0;
     $y = $this->rh - $rh1 * cos($theta) + $this->y0;
     $p->x = $x;
     $p->y = $y;
     return $p;
 }
Exemple #2
0
 public function forward($p)
 {
     /* Forward equations
        ----------------- */
     #$x;
     #$y;
     $lam = $p->x;
     $phi = $p->y;
     $lam = Common::adjust_lon($lam - $this->long0);
     if ($this->sphere) {
         /*
         $coslam;
         $cosphi;
         $sinphi;
         */
         $sinphi = sin($phi);
         $cosphi = cos($phi);
         $coslam = cos($lam);
         switch ($this->mode) {
             case $this->OBLIQ:
             case $this->EQUIT:
                 $y = $this->mode == $this->EQUIT ? 1.0 + $cosphi * $coslam : 1.0 + $this->sinph0 * $sinphi + $this->cosph0 * $cosphi * $coslam;
                 if (y <= Common::EPSLN) {
                     Proj4php::reportError("laea:fwd:y less than eps");
                     return null;
                 }
                 $y = sqrt(2.0 / $y);
                 $x = $y * cosphi * sin($lam);
                 $y *= $this->mode == $this->EQUIT ? $sinphi : $this->cosph0 * $sinphi - $this->sinph0 * $cosphi * $coslam;
                 break;
             case $this->N_POLE:
                 $coslam = -$coslam;
             case $this->S_POLE:
                 if (abs($phi + $this->phi0) < Common::EPSLN) {
                     Proj4php::reportError("laea:fwd:phi < eps");
                     return;
                 }
                 $y = Common::FORTPI - $phi * 0.5;
                 $y = 2.0 * ($this->mode == $this->S_POLE ? cos($y) : sin($y));
                 $x = $y * sin($lam);
                 $y *= $coslam;
                 break;
         }
     } else {
         /*
         $coslam;
         $sinlam;
         $sinphi;
         $q;
         */
         $sinb = 0.0;
         $cosb = 0.0;
         $b = 0.0;
         $coslam = cos($lam);
         $sinlam = sin($lam);
         $sinphi = sin($phi);
         $q = Common::qsfnz($this->e, $sinphi);
         if ($this->mode == $this->OBLIQ || $this->mode == $this->EQUIT) {
             $sinb = $q / $this->qp;
             $cosb = sqrt(1.0 - $sinb * $sinb);
         }
         switch ($this->mode) {
             case $this->OBLIQ:
                 $b = 1.0 + $this->sinb1 * $sinb + $this->cosb1 * $cosb * $coslam;
                 break;
             case $this->EQUIT:
                 $b = 1.0 + $cosb * $coslam;
                 break;
             case $this->N_POLE:
                 $b = Common::HALF_PI + $phi;
                 $q = $this->qp - $q;
                 break;
             case $this->S_POLE:
                 $b = $phi - Common::HALF_PI;
                 $q = $this->qp + $q;
                 break;
         }
         if (abs($b) < Common::EPSLN) {
             Proj4php::reportError("laea:fwd:b < eps");
             return null;
         }
         switch ($this->mode) {
             case $this->OBLIQ:
             case $this->EQUIT:
                 $b = sqrt(2.0 / $b);
                 if ($this->mode == $this->OBLIQ) {
                     $y = $this->ymf * $b * ($this->cosb1 * $sinb - $this->sinb1 * $cosb * $coslam);
                 } else {
                     $y = ($b = sqrt(2.0 / (1.0 + $cosb * $coslam))) * $sinb * $this->ymf;
                 }
                 $x = $this->xmf * $b * $cosb * $sinlam;
                 break;
             case $this->N_POLE:
             case $this->S_POLE:
                 if (q >= 0.0) {
                     $x = ($b = sqrt($q)) * $sinlam;
                     $y = $coslam * ($this->mode == $this->S_POLE ? $b : -$b);
                 } else {
                     $x = $y = 0.0;
                 }
                 break;
         }
     }
     //v 1.0
     /*
      $sin_lat=sin(lat);
      $cos_lat=cos(lat);
     
      $sin_delta_lon=sin(delta_lon);
      $cos_delta_lon=cos(delta_lon);
     
      $g =$this->sin_lat_o * sin_lat +$this->cos_lat_o * cos_lat * cos_delta_lon;
      if (g == -1.0) {
      Proj4php::reportError("laea:fwd:Point projects to a circle of radius "+ 2.0 * R);
      return null;
      }
      $ksp = $this->a * sqrt(2.0 / (1.0 + g));
      $x = ksp * cos_lat * sin_delta_lon + $this->x0;
      $y = ksp * ($this->cos_lat_o * sin_lat - $this->sin_lat_o * cos_lat * cos_delta_lon) + $this->y0;
     */
     $p->x = $this->a * $x + $this->x0;
     $p->y = $this->a * $y + $this->y0;
     return $p;
 }