Esempio n. 1
0
 /**
  * @param type $p
  * @return type 
  */
 public function inverse($p)
 {
     // descale and de-offset
     $p->x = ($p->x - $this->x0) / $this->a;
     $p->y = ($p->y - $this->y0) / $this->a;
     $p->x /= $this->k0;
     $p->y /= $this->k0;
     if ($rho = sqrt($p->x * $p->x + $p->y * $p->y)) {
         $c = 2.0 * atan2($rho, $this->R2);
         $sinc = sin($c);
         $cosc = cos($c);
         $lat = asin($cosc * $this->sinc0 + $p->y * $sinc * $this->cosc0 / $rho);
         $lon = atan2($p->x * $sinc, $rho * $this->cosc0 * $cosc - $p->y * $this->sinc0 * $sinc);
     } else {
         $lat = $this->phic0;
         $lon = 0.0;
     }
     $p->x = $lon;
     $p->y = $lat;
     //$p = Proj4php::$proj['gauss']->inverse($p);
     $p = parent::inverse($p);
     // adjust longitude to CM
     $p->x = Common::adjust_lon($p->x + $this->long0);
     return $p;
 }
Esempio n. 2
0
 public function inverse($p)
 {
     $x = $p->x;
     $y = $p->y;
     $p->x = Common::adjust_lon($this->long0 + ($x - $this->x0) / ($this->a * $this->rc));
     $p->y = Common::adjust_lat($this->lat0 + ($y - $this->y0) / $this->a);
     return $p;
 }
Esempio n. 3
0
 public function inverse($p)
 {
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $lon = Common::adjust_lon($this->long0 + $p->x / $this->a);
     $lat = 2.5 * (atan(exp(0.8 * $p->y / $this->a)) - Common::PI / 4.0);
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Esempio n. 4
0
 public function inverse($p)
 {
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $lat = $p->y / $this->a;
     if (abs($lat) > Common::HALF_PI) {
         Proj4php::reportError("equi:Inv:DataError");
     }
     $lon = Common::adjust_lon($this->long0 + $p->x / ($this->a * cos($this->lat0)));
     $p->x = $lon;
     $p->y = $lat;
 }
Esempio n. 5
0
 /**
  *
  * @param type $p
  * @return type 
  */
 public function inverse($p)
 {
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $rh = sqrt($p->x * $p->x + $p->y * $p->y);
     if ($rh > 2.0 * Common::HALF_PI * $this->a) {
         Proj4php::reportError("aeqdInvDataError");
         return;
     }
     $z = $rh / $this->a;
     $sinz = sin($z);
     $cosz = cos($z);
     $lon = $this->long0;
     #$lat;
     if (abs($rh) <= Common::EPSLN) {
         $lat = $this->lat0;
     } else {
         $lat = Common::asinz($cosz * $this->sin_p12 + $p->y * $sinz * $this->cos_p12 / $rh);
         $con = abs($this->lat0) - Common::HALF_PI;
         if (abs($con) <= Common::EPSLN) {
             if ($this->lat0 >= 0.0) {
                 $lon = Common::adjust_lon($this->long0 + atan2($p->x, -$p->y));
             } else {
                 $lon = Common::adjust_lon($this->long0 - atan2(-$p->x, $p->y));
             }
         } else {
             $con = $cosz - $this->sin_p12 * sin($lat);
             if (abs($con) < Common::EPSLN && abs($p->x) < Common::EPSLN) {
                 //no-op, just keep the lon value as is
             } else {
                 #$temp = atan2( ($p->x * $sinz * $this->cos_p12 ), ($con * $rh ) ); // $temp is unused !?!
                 $lon = Common::adjust_lon($this->long0 + atan2($p->x * $sinz * $this->cos_p12, $con * $rh));
             }
         }
     }
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Esempio n. 6
0
 public function inverse($p)
 {
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $x = $p->x / $this->a;
     $y = $p->y / $this->a;
     if ($this->sphere) {
         $cosz = 0.0;
         #$rh;
         $sinz = 0.0;
         $rh = sqrt($x * $x + $y * $y);
         $phi = $rh * 0.5;
         if ($phi > 1.0) {
             Proj4php::reportError("laea:Inv:DataError");
             return null;
         }
         $phi = 2.0 * asin($phi);
         if ($this->mode == $this->OBLIQ || $this->mode == $this->EQUIT) {
             $sinz = sin($phi);
             $cosz = cos($phi);
         }
         switch ($this->mode) {
             case $this->EQUIT:
                 $phi = abs($rh) <= Common::EPSLN ? 0.0 : asin($y * $sinz / $rh);
                 $x *= $sinz;
                 $y = $cosz * $rh;
                 break;
             case $this->OBLIQ:
                 $phi = abs($rh) <= Common::EPSLN ? $this->phi0 : asin($cosz * $this->sinph0 + $y * $sinz * $this->cosph0 / $rh);
                 $x *= $sinz * $this->cosph0;
                 $y = ($cosz - sin($phi) * $this->sinph0) * $rh;
                 break;
             case $this->N_POLE:
                 $y = -$y;
                 $phi = Common::HALF_PI - $phi;
                 break;
             case $this->S_POLE:
                 $phi -= Common::HALF_PI;
                 break;
         }
         $lam = $y == 0.0 && ($this->mode == $this->EQUIT || $this->mode == $this->OBLIQ) ? 0.0 : atan2($x, $y);
     } else {
         /*
         $cCe;
         $sCe;
         $q;
         $rho;
         */
         $ab = 0.0;
         switch ($this->mode) {
             case $this->EQUIT:
             case $this->OBLIQ:
                 $x /= $this->dd;
                 $y *= $this->dd;
                 $rho = sqrt($x * $x + $y * $y);
                 if ($rho < Common::EPSLN) {
                     $p->x = 0.0;
                     $p->y = $this->phi0;
                     return $p;
                 }
                 $sCe = 2.0 * asin(0.5 * $rho / $this->rq);
                 $cCe = cos($sCe);
                 $x *= $sCe = sin($sCe);
                 if ($this->mode == $this->OBLIQ) {
                     $ab = $cCe * $this->sinb1 + $y * $sCe * $this->cosb1 / $rho;
                     $q = $this->qp * $ab;
                     $y = $rho * $this->cosb1 * $cCe - $y * $this->sinb1 * $sCe;
                 } else {
                     $ab = $y * $sCe / $rho;
                     $q = $this->qp * $ab;
                     $y = $rho * $cCe;
                 }
                 break;
             case $this->N_POLE:
                 $y = -$y;
             case $this->S_POLE:
                 $q = $x * $x + $y * $y;
                 if (!$q) {
                     $p->x = 0.0;
                     $p->y = $this->phi0;
                     return $p;
                 }
                 /*
                  q = $this->qp - q;
                 */
                 $ab = 1.0 - $q / $this->qp;
                 if ($this->mode == $this->S_POLE) {
                     $ab = -$ab;
                 }
                 break;
         }
         $lam = atan2($x, $y);
         $phi = $this->authlat(asin($ab), $this->apa);
     }
     /*
      $Rh = sqrt($p->x *$p->x +$p->y * $p->y);
      $temp = Rh / (2.0 * $this->a);
     
      if (temp > 1) {
      Proj4php::reportError("laea:Inv:DataError");
      return null;
      }
     
      $z = 2.0 * Common::asinz(temp);
      $sin_z=sin(z);
      $cos_z=cos(z);
     
      $lon =$this->long0;
      if (abs(Rh) > Common::EPSLN) {
      $lat = Common::asinz($this->sin_lat_o * cos_z +$this-> cos_lat_o * sin_z *$p->y / Rh);
      $temp =abs($this->lat0) - Common::HALF_PI;
      if (abs(temp) > Common::EPSLN) {
      temp = cos_z -$this->sin_lat_o * sin(lat);
      if(temp!=0.0) lon=Common::adjust_lon($this->long0+atan2($p->x*sin_z*$this->cos_lat_o,temp*Rh));
      } else if ($this->lat0 < 0.0) {
      lon = Common::adjust_lon($this->long0 - atan2(-$p->x,$p->y));
      } else {
      lon = Common::adjust_lon($this->long0 + atan2($p->x, -$p->y));
      }
      } else {
      lat = $this->lat0;
      }
     */
     //return(OK);
     $p->x = Common::adjust_lon($this->long0 + $lam);
     $p->y = $phi;
     return $p;
 }
Esempio n. 7
0
 /**
  *
  * @param type $p
  * @return type 
  */
 public function inverse($p)
 {
     /*
     $delta_lon; /* Delta longitude (Given longitude - center 
     $theta;  /* angle
     $delta_theta; /* adjusted longitude
     $sin_phi;
     $cos_phi; /* sin and cos value	
     $b;  /* temporary values
     $c;
     $t;
     $tq; /* temporary values
     $con;
     $n;
     $ml; /* cone constant, small m	
     $vs;
     $us;
     $q;
     $s;
     $ts1;
     $vl;
     $ul;
     $bs;
     $dlon;
     $flag;
     */
     /* Inverse equations
        ----------------- */
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     #$flag = 0;
     $vs = $p->x * $this->cosaz - $p->y * $this->sinaz;
     $us = $p->y * $this->cosaz + $p->x * $this->sinaz;
     $us = $us + $this->u;
     $q = exp(-$this->bl * $vs / $this->al);
     $s = 0.5 * ($q - 1.0 / $q);
     $t = 0.5 * ($q + 1.0 / $q);
     $vl = sin($this->bl * $us / $this->al);
     $ul = ($vl * $this->cosgam + $s * $this->singam) / $t;
     if (abs(abs($ul) - 1.0) <= Common::EPSLN) {
         $lon = $this->longc;
         if (ul >= 0.0) {
             $lat = Common::HALF_PI;
         } else {
             $lat = -Common::HALF_PI;
         }
     } else {
         $con = 1.0 / $this->bl;
         $ts1 = pow($this->el / sqrt((1.0 + $ul) / (1.0 - $ul)), $con);
         $lat = Common::phi2z($this->e, $ts1);
         //if ($flag != 0)
         //return($flag);
         //~ con = cos($this->bl * us /al);
         $theta = $this->longc - atan2($s * $this->cosgam - $vl * $this->singam, $con) / $this->bl;
         $lon = Common::adjust_lon($theta);
     }
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Esempio n. 8
0
 /**
  * Lambert Conformal Conic inverse equations--mapping x,y to lat/long
  * 
  * @param type $p
  * @return null 
  */
 public function inverse($p)
 {
     $x = ($p->x - $this->x0) / $this->k0;
     $y = $this->rh - ($p->y - $this->y0) / $this->k0;
     if ($this->ns > 0) {
         $rh1 = sqrt($x * $x + $y * $y);
         $con = 1.0;
     } else {
         $rh1 = -sqrt($x * $x + $y * $y);
         $con = -1.0;
     }
     $theta = 0.0;
     if ($rh1 != 0) {
         $theta = atan2($con * $x, $con * $y);
     }
     if ($rh1 != 0 || $this->ns > 0.0) {
         $con = 1.0 / $this->ns;
         $ts = pow($rh1 / ($this->a * $this->f0), $con);
         $lat = Common::phi2z($this->e, $ts);
         if ($lat == -9999) {
             return null;
         }
     } else {
         $lat = -Common::HALF_PI;
     }
     $lon = Common::adjust_lon($theta / $this->ns + $this->long0);
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Esempio n. 9
0
 /**
  Transverse Mercator Inverse  -  x/y to long/lat
 */
 public function inverse($p)
 {
     #$phi;  /* temporary angles       */
     #$delta_phi; /* difference between longitudes    */
     $max_iter = 6;
     /* maximun number of iterations */
     if (isset($this->sphere) && $this->sphere === true) {
         /* spherical form */
         $f = exp($p->x / ($this->a * $this->k0));
         $g = 0.5 * ($f - 1 / $f);
         $temp = $this->lat0 + $p->y / ($this->a * $this->k0);
         $h = cos($temp);
         $con = sqrt((1.0 - $h * $h) / (1.0 + $g * $g));
         $lat = Common::asinz($con);
         if ($temp < 0) {
             $lat = -$lat;
         }
         if ($g == 0 && $h == 0) {
             $lon = $this->long0;
         } else {
             $lon = Common::adjust_lon(atan2($g, $h) + $this->long0);
         }
     } else {
         // ellipsoidal form
         $x = $p->x - $this->x0;
         $y = $p->y - $this->y0;
         $con = ($this->ml0 + $y / $this->k0) / $this->a;
         $phi = $con;
         for ($i = 0; true; $i++) {
             $delta_phi = ($con + $this->e1 * sin(2.0 * $phi) - $this->e2 * sin(4.0 * $phi) + $this->e3 * sin(6.0 * $phi)) / $this->e0 - $phi;
             $phi += $delta_phi;
             if (abs($delta_phi) <= Common::EPSLN) {
                 break;
             }
             if ($i >= $max_iter) {
                 Proj4php::reportError("tmerc:inverse: Latitude failed to converge");
                 return 95;
             }
         }
         // for()
         if (abs($phi) < Common::HALF_PI) {
             // sincos(phi, &sin_phi, &cos_phi);
             $sin_phi = sin($phi);
             $cos_phi = cos($phi);
             $tan_phi = tan($phi);
             $c = $this->ep2 * pow($cos_phi, 2);
             $cs = pow($c, 2);
             $t = pow($tan_phi, 2);
             $ts = pow($t, 2);
             $con = 1.0 - $this->es * pow($sin_phi, 2);
             $n = $this->a / sqrt($con);
             $r = $n * (1.0 - $this->es) / $con;
             $d = $x / ($n * $this->k0);
             $ds = pow($d, 2);
             $lat = $phi - $n * $tan_phi * $ds / $r * (0.5 - $ds / 24.0 * (5.0 + 3.0 * $t + 10.0 * $c - 4.0 * $cs - 9.0 * $this->ep2 - $ds / 30.0 * (61.0 + 90.0 * $t + 298.0 * $c + 45.0 * $ts - 252.0 * $this->ep2 - 3.0 * $cs)));
             $lon = Common::adjust_lon($this->long0 + $d * (1.0 - $ds / 6.0 * (1.0 + 2.0 * $t + $c - $ds / 20.0 * (5.0 - 2.0 * $c + 28.0 * $t - 3.0 * $cs + 8.0 * $this->ep2 + 24.0 * $ts))) / $cos_phi);
         } else {
             $lat = Common::HALF_PI * Common::sign($y);
             $lon = $this->long0;
         }
     }
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Esempio n. 10
0
 /**
  * Stereographic inverse equations--mapping x,y to lat/long
  *
  * @param type $p
  * @return type 
  */
 public function inverse($p)
 {
     $x = ($p->x - $this->x0) / $this->a;
     /* descale and de-offset */
     $y = ($p->y - $this->y0) / $this->a;
     /*
     $lon;
     $lat;
     $cosphi;
     $sinphi;
     $rho;
     $tp = 0.0;
     $phi_l = 0.0;
     $i;
     */
     $halfe = 0.0;
     $pi2 = 0.0;
     if ($this->sphere) {
         /*
         $c;
         $rh;
         $sinc;
         $cosc;
         */
         $rh = sqrt($x * $x + $y * $y);
         $c = 2.0 * atan($rh / $this->akm1);
         $sinc = sin($c);
         $cosc = cos($c);
         $lon = 0.0;
         switch ($this->mode) {
             case $this->EQUIT:
                 if (abs($rh) <= Common::EPSLN) {
                     $lat = 0.0;
                 } else {
                     $lat = asin($y * $sinc / $rh);
                 }
                 if ($cosc != 0.0 || $x != 0.0) {
                     $lon = atan2($x * $sinc, $cosc * $rh);
                 }
                 break;
             case $this->OBLIQ:
                 if (abs($rh) <= Common::EPSLN) {
                     $lat = $this->phi0;
                 } else {
                     $lat = asin($cosc * $this->sinph0 + $y * $sinc * $this->cosph0 / $rh);
                 }
                 $c = $cosc - $this->sinph0 * sin($lat);
                 if ($c != 0.0 || $x != 0.0) {
                     $lon = atan2($x * $sinc * $this->cosph0, $c * $rh);
                 }
                 break;
             case $this->N_POLE:
                 $y = -$y;
             case $this->S_POLE:
                 if (abs($rh) <= Common::EPSLN) {
                     $lat = $this->phi0;
                 } else {
                     $lat = asin($this->mode == $this->S_POLE ? -$cosc : $cosc);
                 }
                 $lon = $x == 0.0 && $y == 0.0 ? 0.0 : atan2($x, $y);
                 break;
         }
         $p->x = Common::adjust_lon($lon + $this->long0);
         $p->y = $lat;
     } else {
         $rho = sqrt($x * $x + $y * $y);
         switch ($this->mode) {
             case $this->OBLIQ:
             case $this->EQUIT:
                 $tp = 2.0 * atan2($rho * $this->cosX1, $this->akm1);
                 $cosphi = cos($tp);
                 $sinphi = sin($tp);
                 if ($rho == 0.0) {
                     $phi_l = asin($cosphi * $this->sinX1);
                 } else {
                     $phi_l = asin($cosphi * $this->sinX1 + $y * $sinphi * $this->cosX1 / $rho);
                 }
                 $tp = tan(0.5 * (Common::HALF_PI + $phi_l));
                 $x *= $sinphi;
                 $y = $rho * $this->cosX1 * $cosphi - $y * $this->sinX1 * $sinphi;
                 $pi2 = Common::HALF_PI;
                 $halfe = 0.5 * $this->e;
                 break;
             case $this->N_POLE:
                 $y = -$y;
             case $this->S_POLE:
                 $tp = -$rho / $this->akm1;
                 $phi_l = Common::HALF_PI - 2.0 * atan($tp);
                 $pi2 = -Common::HALF_PI;
                 $halfe = -0.5 * $this->e;
                 break;
         }
         for ($i = $this->NITER; $i--; $phi_l = $lat) {
             //check this
             $sinphi = $this->e * sin($phi_l);
             $lat = 2.0 * atan($tp * pow((1.0 + $sinphi) / (1.0 - $sinphi), $halfe)) - $pi2;
             if (abs(phi_l - lat) < $this->CONV) {
                 if ($this->mode == $this->S_POLE) {
                     $lat = -$lat;
                 }
                 $lon = $x == 0.0 && $y == 0.0 ? 0.0 : atan2($x, $y);
                 $p->x = Common::adjust_lon($lon + $this->long0);
                 $p->y = $lat;
                 return $p;
             }
         }
     }
 }
Esempio n. 11
0
 /**
  *
  * @param type $p
  * @return type 
  */
 public function inverse($p)
 {
     #$lat;
     #$temp;
     #$lon;
     /* Inverse equations
        ----------------- */
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $lat = $p->y / $this->a;
     if (isset($this->sphere)) {
         $p->y /= $this->C_y;
         $lat = $this->m ? asin(($this->m * $p->y + sin($p->y)) / $this->n) : ($this->n != 1.0 ? asin(sin($p->y) / $this->n) : $p->y);
         $lon = $p->x / ($this->C_x * ($this->m + cos($p->y)));
     } else {
         $lat = Common::pj_inv_mlfn($p->y / $this->a, $this->es, $this->en);
         $s = abs($lat);
         if ($s < Common::HALF_PI) {
             $s = sin($lat);
             $temp = $this->long0 + $p->x * sqrt(1.0 - $this->es * $s * $s) / ($this->a * cos($lat));
             //temp = $this->long0 + $p->x / ($this->a * cos($lat));
             $lon = Common::adjust_lon($temp);
         } else {
             if ($s - Common::EPSLN < Common::HALF_PI) {
                 $lon = $this->long0;
             }
         }
     }
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Esempio n. 12
0
 public function inverse($p)
 {
     /*
     $dlon;
     $xx;
     $yy;
     $xys;
     $c1;
     $c2;
     $c3;
     $al;
     $asq;
     $a1;
     $m1;
     $con;
     $th1;
     $d;
     */
     /* inverse equations
        ----------------- */
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $con = Common::PI * $this->R;
     $xx = $p->x / $con;
     $yy = $p->y / $con;
     $xys = $xx * $xx + $yy * $yy;
     $c1 = -abs($yy) * (1.0 + $xys);
     $c2 = $c1 - 2.0 * $yy * $yy + $xx * $xx;
     $c3 = -2.0 * $c1 + 1.0 + 2.0 * $yy * $yy + $xys * $xys;
     $d = $yy * $yy / $c3 + (2.0 * $c2 * $c2 * $c2 / $c3 / $c3 / $c3 - 9.0 * $c1 * $c2 / $c3 / $c3) / 27.0;
     $a1 = ($c1 - $c2 * $c2 / 3.0 / $c3) / $c3;
     $m1 = 2.0 * sqrt(-$a1 / 3.0);
     $con = 3.0 * $d / $a1 / $m1;
     if (abs($con) > 1.0) {
         if ($con >= 0.0) {
             $con = 1.0;
         } else {
             $con = -1.0;
         }
     }
     $th1 = acos($con) / 3.0;
     if ($p->{$y} >= 0) {
         $lat = (-$m1 * cos($th1 + Common::PI / 3.0) - $c2 / 3.0 / $c3) * Common::PI;
     } else {
         $lat = -(-m1 * cos($th1 + Common::PI / 3.0) - $c2 / 3.0 / $c3) * Common::PI;
     }
     if (abs($xx) < Common::EPSLN) {
         $lon = $this->{$long0};
     }
     $lon = Common::adjust_lon($this->long0 + Common::PI * ($xys - 1.0 + sqrt(1.0 + 2.0 * ($xx * $xx - $yy * $yy) + $xys * $xys)) / 2.0 / $xx);
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Esempio n. 13
0
 /**
  *
  * @param type $p
  * @return type 
  */
 public function inverse($p)
 {
     #$theta;
     #$arg;
     /* Inverse equations
        ----------------- */
     $p->x -= $this->x0;
     //~ $p->y -= $this->y0;
     $arg = $p->y / (1.4142135623731 * $this->a);
     /* Because of division by zero problems, 'arg' can not be 1.0.  Therefore
        a number very close to one is used instead.
        ------------------------------------------------------------------- */
     if (abs($arg) > 0.999999999999) {
         $arg = 0.999999999999;
     }
     $theta = asin($arg);
     $lon = Common::adjust_lon($this->long0 + $p->x / (0.900316316158 * $this->a * cos($theta)));
     if ($lon < -Common::PI) {
         $lon = -Common::PI;
     }
     if ($lon > Common::PI) {
         $lon = Common::PI;
     }
     $arg = (2.0 * $theta + sin(2.0 * $theta)) / Common::PI;
     if (abs($arg) > 1.0) {
         $arg = 1.0;
     }
     $lat = asin($arg);
     //return(OK);
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Esempio n. 14
0
 /**
  *
  * @param type $p
  * @return type 
  */
 public function inverse($p)
 {
     /*
     $rh;  // height above ellipsoid	
     $z;  // angle
     $sinz;
     $cosz; // sin of z and cos of z	
     $temp;
     $con;
     $lon;
     $lat;
     */
     /* Inverse equations
        ----------------- */
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $rh = sqrt($p->x * $p->x + $p->y * $p->y);
     if ($rh > $this->a + 1.0E-7) {
         Proj4php::reportError("orthoInvDataError");
     }
     $z = Common::asinz($rh / $this->a);
     $sinz = sin($z);
     $cosz = cos($z);
     $lon = $this->long0;
     if (abs($rh) <= Common::EPSLN) {
         $lat = $this->lat0;
     }
     $lat = Common::asinz($cosz * $this->sin_p14 + $p->y * $sinz * $this->cos_p14 / $rh);
     $con = abs($this->lat0) - Common::HALF_PI;
     if (abs(con) <= Common::EPSLN) {
         if ($this->lat0 >= 0) {
             $lon = Common::adjust_lon($this->long0 + atan2($p->x, -$p->y));
         } else {
             $lon = Common::adjust_lon($this->long0 - atan2(-$p->x, $p->y));
         }
     }
     $con = $cosz - $this->sin_p14 * sin($lat);
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Esempio n. 15
0
 /**
  * ellipsoid
  * calculate xy from lat/lon
  * Constants, identical to inverse transform function
  *
  * @param type $p
  * @return type 
  */
 public function forward($p)
 {
     $lon = $p->x;
     $lat = $p->y;
     $delta_lon = Common::adjust_lon($lon - $this->long0);
     // Delta longitude
     /* Transformation */
     $gfi = pow((1.0 + $this->e * sin($lat)) / (1.0 - $this->e * sin($lat)), $this->alfa * $this->e / 2.0);
     $u = 2.0 * (atan($this->k * pow(tan($lat / 2.0 + $this->s45), $this->alfa) / $gfi) - $this->s45);
     $deltav = -$delta_lon * $this->alfa;
     $s = asin(cos($this->ad) * sin($u) + sin($this->ad) * cos($u) * cos($deltav));
     $d = asin(cos($u) * sin($deltav) / cos($s));
     $eps = $this->n * $d;
     $ro = $this->ro0 * pow(tan($this->s0 / 2.0 + $this->s45), $this->n) / pow(tan($s / 2.0 + $this->s45), $this->n);
     /* x and y are reverted! */
     //$p->y = ro * cos(eps) / a;
     //$p->x = ro * sin(eps) / a;
     $p->y = $ro * cos($eps) / 1.0;
     $p->x = $ro * sin($eps) / 1.0;
     if ($this->czech) {
         $p->y *= -1.0;
         $p->x *= -1.0;
     }
     return $p;
 }
Esempio n. 16
0
 public function inverse($p)
 {
     $p->x -= $this->x0;
     $p->y = $this->rh - $p->y + $this->y0;
     if ($this->ns >= 0) {
         $rh1 = sqrt($p->x * $p->x + $p->y * $p->y);
         $con = 1.0;
     } else {
         $rh1 = -sqrt($p->x * $p->x + $p->y * $p->y);
         $con = -1.0;
     }
     $theta = 0.0;
     if ($rh1 != 0.0) {
         $theta = atan2($con * $p->x, $con * $p->y);
     }
     $ml = $this->g - $rh1 / $this->a;
     $lat = $this->phi3z($ml, $this->e0, $this->e1, $this->e2, $this->e3);
     $lon = Common::adjust_lon($this->long0 + $theta / $this->ns);
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Esempio n. 17
0
 /**
  *
  * @param Point $p
  * @return Point $p
  */
 public function inverse($p)
 {
     $p->x -= $this->x0;
     $p->y = $this->rh - $p->y + $this->y0;
     if ($this->ns0 >= 0) {
         $rh1 = sqrt($p->x * $p->x + $p->y * $p->y);
         $con = 1.0;
     } else {
         $rh1 = -sqrt($p->x * $p->x + $p->y * $p->y);
         $con = -1.0;
     }
     $theta = 0.0;
     if ($rh1 != 0.0) {
         $theta = atan2($con * $p->x, $con * $p->y);
     }
     $con = $rh1 * $this->ns0 / $this->a;
     $qs = ($this->c - $con * $con) / $this->ns0;
     if ($this->e3 >= 1.0E-10) {
         $con = 1 - 0.5 * (1.0 - $this->es) * log((1.0 - $this->e3) / (1.0 + $this->e3)) / $this->e3;
         if (abs(abs($con) - abs($qs)) > 1.0E-10) {
             $lat = $this->phi1z($this->e3, $qs);
         } else {
             if ($qs >= 0) {
                 $lat = 0.5 * Common::PI;
             } else {
                 $lat = -0.5 * Common::PI;
             }
         }
     } else {
         $lat = $this->phi1z($this->e3, $qs);
     }
     $lon = Common::adjust_lon($theta / $this->ns0 + $this->long0);
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Esempio n. 18
0
 /**
  * Cylindrical Equal Area inverse equations--mapping x,y to lat/long
  * 
  * @param type $p
  * @return type 
  */
 public function inverse($p)
 {
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $p->x = Common::adjust_lon($this->long0 + $p->x / $this->a / cos($this->lat_ts));
     $p->y = asin($p->y / $this->a * cos($this->lat_ts));
     return $p;
 }
Esempio n. 19
0
 /**
  *
  * @param type $p
  * @return type 
  */
 public function inverse($p)
 {
     /*
     $rh;  // Rho 
     $z;  // angle 
     $sinc;
     $cosc;
     $c;
     $lon;
     $lat;
     */
     /* Inverse equations
        ----------------- */
     $p->x = ($p->x - $this->x0) / $this->a;
     $p->y = ($p->y - $this->y0) / $this->a;
     $p->x /= $this->k0;
     $p->y /= $this->k0;
     if ($rh = sqrt($p->x * $p->x + $p->y * $p->y)) {
         $c = atan2($rh, $this->rc);
         $sinc = sin($c);
         $cosc = cos($c);
         $lat = Common::asinz($cosc * $this->sin_p14 + $p->y * $sinc * $this->cos_p14 / $rh);
         $lon = atan2($p->x * sinc, rh * $this->cos_p14 * $cosc - $p->y * $this->sin_p14 * $sinc);
         $lon = Common::adjust_lon($this->long0 + $lon);
     } else {
         $lat = $this->phic0;
         $lon = 0.0;
     }
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Esempio n. 20
0
 public function inverse($p)
 {
     $x = $p->x - $this->x0;
     $y = $p->y - $this->y0;
     if ($this->sphere) {
         $lat = Common::HALF_PI - 2.0 * atan(exp(-$y / $this->a * $this->k0));
     } else {
         $ts = exp(-$y / ($this->a * $this->k0));
         $lat = Common::phi2z($this->e, $ts);
         if ($lat == -9999) {
             Proj4php::reportError("merc:inverse: lat = -9999");
             return null;
         }
     }
     $lon = Common::adjust_lon($this->long0 + $x / ($this->a * $this->k0));
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Esempio n. 21
0
 public function inverse($p)
 {
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $x = $p->x / $this->a;
     $y = $p->y / $this->a;
     if ($this->sphere) {
         $this->dd = $y + $this->lat0;
         $phi = asin(sin($this->dd) * cos($x));
         $lam = atan2(tan($x), cos($this->dd));
     } else {
         // ellipsoid
         $ph1 = Common::pj_inv_mlfn($this->m0 + $y, $this->es, $this->en);
         $this->tn = tan($ph1);
         $this->t = $this->tn * $this->tn;
         $this->n = sin($ph1);
         $this->r = 1.0 / (1.0 - $this->es * $this->n * $this->n);
         $this->n = sqrt($this->r);
         $this->r *= (1.0 - $this->es) * $this->n;
         $this->dd = $x / $this->n;
         $this->d2 = $this->dd * $this->dd;
         $phi = $ph1 - $this->n * $this->tn / $this->r * $this->d2 * (0.5 - (1.0 + 3.0 * $this->t) * $this->d2 * $this->C3);
         $lam = $this->dd * (1.0 + $this->t * $this->d2 * (-$this->C4 + (1.0 + 3.0 * $this->t) * $this->d2 * $this->C5)) / cos($ph1);
     }
     $p->x = Common::adjust_lon($this->long0 + $lam);
     $p->y = $phi;
     return $p;
 }
Esempio n. 22
0
 public function inverse($p)
 {
     /*
     $sin_phi;
     $cos_phi; // sin and cos values
     $al;     // temporary values
     $b;     // temporary values
     $c;     // temporary values
     $con;
     $ml;   // cone constant, small m
     $iflg;    // error flag	
     $lon;
     $lat;
     */
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $al = $this->ml0 + $p->y / $this->a;
     $iflg = 0;
     if (abs($al) <= 1.0E-7) {
         $lon = $p->x / $this->a + $this->long0;
         $lat = 0.0;
     } else {
         $b = $al * $al + $p->x / $this->a * ($p->x / $this->a);
         $iflg = phi4z($this->es, $this->e0, $this->e1, $this->e2, $this->e3, $this->al, $b, $c, $lat);
         if ($iflg != 1) {
             return $iflg;
         }
         $lon = Common::adjust_lon(Common::asinz($p->x * $c / $this->a) / sin($lat) + $this->long0);
     }
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }