예제 #1
0
 public function forward($p)
 {
     $lon = $p->x;
     $lat = $p->y;
     $this->sin_phi = sin($lat);
     $this->cos_phi = cos($lat);
     $qs = Sourcemap_Proj::qsfnz($this->e3, $this->sin_phi, $this->cos_phi);
     $rh1 = $this->a * sqrt($this->c - $this->ns0 * qs) / $this->ns0;
     $theta = $this->ns0 * Sourcemap_Proj::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;
 }
예제 #2
0
 public function forward($p)
 {
     /* Forward equations
        -----------------*/
     $lam = $p->x;
     $phi = $p->y;
     $lam = Sourcemap_Proj::adjust_lon($lam - $this->long0);
     if ($this->sphere) {
         $sinphi = sin($phi);
         $cosphi = cos($phi);
         $coslam = cos($lam);
         switch ($this->mode) {
             case $this->EQUIT:
                 $y = $this->mode == $this->EQUIT ? 1.0 + $cosphi * $coslam : 1.0 + $this->sinph0 * $sinphi + $this->cosph0 * $cosphi * $coslam;
                 if ($y <= Sourcemap_Proj::EPSLN) {
                     throw new Exception('Y less than eps.');
                 }
                 $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) < Sourcemap_Proj::EPSLN) {
                     throw new Exception("Phi < eps.");
                 }
                 $y = Sourcemap_Proj::FORTPI - $phi * 0.5;
                 $y = 2.0 * ($this->mode == $this->S_POLE ? cos($y) : sin($y));
                 $x = $y * sin($lam);
                 $y *= $coslam;
                 break;
         }
     } else {
         $sinb = 0.0;
         $cosb = 0.0;
         $b = 0.0;
         $coslam = cos($lam);
         $sinlam = sin($lam);
         $sinphi = sin($phi);
         $q = Sourcemap_Proj::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 = Sourcemap_Proj::HALF_PI + $phi;
                 $q = $this->qp - $q;
                 break;
             case $this->S_POLE:
                 $b = $phi - Sourcemap_Proj::HALF_PI;
                 $q = $this->qp + $q;
                 break;
         }
         if (abs($b) < Sourcemap_Proj::EPSLN) {
             throw new Exception("B < eps.");
         }
         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) {
       Proj4js.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;
 }