Exemplo n.º 1
0
 public function inverse($p)
 {
     /* 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 = Sourcemap_Proj::adjust_lon($this->long0 + $p->x / (0.900316316158 * $this->a * cos($theta)));
     if ($lon < -Sourcemap_Proj::PI) {
         $lon = -Sourcemap_Proj::PI;
     }
     if ($lon > Sourcemap_Proj::PI) {
         $lon = Sourcemap_Proj::PI;
     }
     $arg = (2.0 * $theta + sin(2.0 * $theta)) / Sourcemap_Proj::PI;
     if (abs($arg) > 1.0) {
         $arg = 1.0;
     }
     $lat = asin($arg);
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Exemplo n.º 2
0
 public function inverse($p)
 {
     $x = $p->x;
     $y = $p->y;
     $p->x = Sourcemap_Proj::adjust_lon($this->long0 + ($x - $this->x0) / ($this->a * $this->rc));
     $p->y = Sourcemap_Proj::adjust_lat($this->lat0 + ($y - $this->y0) / $this->a);
     return $p;
 }
Exemplo n.º 3
0
 public function inverse($p)
 {
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $lon = Sourcemap_Proj::adjust_lon($this->long0 + $p->x / $this->a);
     $lat = 2.5 * (atan(exp(0.8 * $p->y / $this->a)) - Sourcemap_Proj::PI / 4.0);
     $p->x = $lon;
     $p->y = $lat;
     return p;
 }
Exemplo n.º 4
0
 public function inverse($p)
 {
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $lon = Sourcemap_Proj::adjust_lon($this->long0 + $p->x / $this->a / cos($this->lat_ts));
     $lat = asin($p->y / $this->a * cos($this->lat_ts));
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Exemplo n.º 5
0
 public function inverse($p)
 {
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $lat = $p->y / $this->a;
     if (abs($lat) > Sourcemap_Proj::HALF_PI) {
         throw new Exception("Data error: lat out of range.");
     }
     $lon = Sourcemap_Proj::adjust_lon($this->long0 + $p->x / ($this->a * cos($this->lat0)));
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Exemplo n.º 6
0
 public function inverse($p)
 {
     /* Inverse equations
        -----------------*/
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $lat = $p->y / $this->R;
     if (abs($lat) > Sourcemap_Proj::HALF_PI) {
         throw new Exception("Data error.");
     }
     $temp = abs($lat) - Sourcemap_Proj::HALF_PI;
     if (abs($temp) > Sourcemap_Proj::EPSLN) {
         $temp = $this->long0 + $p->x / ($this->R * cos($lat));
         $lon = Sourcemap_Proj::adjust_lon($temp);
     } else {
         $lon = $this->long0;
     }
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Exemplo n.º 7
0
 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 * Sourcemap_Proj::HALF_PI * $this->a) {
         throw new Exception("Data error");
     }
     $z = $rh / $this->a;
     $sinz = sin(z);
     $cosz = cos(z);
     $lon = $this->long0;
     if (abs($rh) <= Sourcemap_Proj::EPSLN) {
         $lat = $this->lat0;
     } else {
         $lat = Sourcemap_Proj::asinz($cosz * $this->sin_p12 + $p->y * $sinz * $this->cos_p12 / $rh);
         $con = abs($this->lat0) - Sourcemap_Proj::HALF_PI;
         if (abs($con) <= Sourcemap_Proj::EPSLN) {
             if ($lat0 >= 0.0) {
                 $lon = Sourcemap_Proj::adjust_lon($this->long0 + atan2($p->x, -$p->y));
             } else {
                 $lon = Sourcemap_Proj::adjust_lon($this->long0 - atan2(-$p->x, $p->y));
             }
         } else {
             $con = $cosz - $this->sin_p12 * sin($lat);
             if (abs($con) < Sourcemap_Proj::EPSLN && abs($p->x) < Sourcemap_Proj::EPSLN) {
                 // pass
             } else {
                 $temp = atan2($p->x * $sinz * $this->cos_p12, $con * $rh);
                 $lon = Sourcemap_Proj::adjust_lon($this->long0 + atan2($p->x * $sinz * $this->cos_p12, $con * $rh));
             }
         }
     }
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Exemplo n.º 8
0
 public function inverse($p)
 {
     $p->x = ($p->x - $this->x0) / $this->a;
     /* descale and de-offset */
     $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 = parent::inverse($p);
     $p->x = Sourcemap_Proj::adjust_lon($p->x + $this->long0);
     /* adjust longitude to CM */
     return $p;
 }
Exemplo n.º 9
0
 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 = Sourcemap_Proj::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 = Sourcemap_Proj::adjust_lon($this->long0 + lon);
     } else {
         $lat = $this->phic0;
         $lon = 0.0;
     }
     $p->x = $lon;
     $p->y = $lat;
     return p;
 }
Exemplo n.º 10
0
 public function inverse($p)
 {
     /* inverse equations
       	-----------------*/
     $p->x -= $this->x0;
     $p->y -= $this->y0;
     $con = Sourcemap_Proj::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;
     // seriously?
     $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 + Sourcemap_Proj::PI / 3.0) - $c2 / 3.0 / $c3) * Sourcemap_Proj::PI;
     } else {
         $lat = -(-$m1 * cos($th1 + PI / 3.0) - $c2 / 3.0 / $c3) * Sourcemap_Proj::PI;
     }
     if (abs($xx) < Sourcemap_Proj::EPSLN) {
         $lon = $this->long0;
     }
     $lon = Sourcemap_Proj::adjust_lon($this->long0 + Sourcemap_Proj::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;
 }
Exemplo n.º 11
0
 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) <= Sourcemap_Proj::EPSLN) {
         $lon = $this->longc;
         if ($ul >= 0.0) {
             $lat = Sourcemap_Proj::HALF_PI;
         } else {
             $lat = -Sourcemap_Proj::HALF_PI;
         }
     } else {
         $con = 1.0 / $this->bl;
         $ts1 = pow($this->el / sqrt((1.0 + $ul) / (1.0 - $ul)), $con);
         $lat = Sourcemap_Proj::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 = Sourcemap_Proj::adjust_lon($theta);
     }
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Exemplo n.º 12
0
 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 * pi();
             } else {
                 $lat = -0.5 * pi();
             }
         }
     } else {
         $lat = $this->phi1z($e3, $qs);
     }
     $lon = Sourcemap_Proj::adjust_lon($theta / $this->ns0 + $this->long0);
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Exemplo n.º 13
0
 public function inverse($pt)
 {
     $x = $pt->x - $this->_proj->x0;
     $y = $pt->y - $this->_proj->y0;
     if ($this->_proj->sphere) {
         $lat = Sourcemap_Proj::HALF_PI - 2.0 * atan(exp(-$y / $this->_proj->a * $this->_proj->k0));
     } else {
         $ts = exp(-$y / ($this->_proj->a * $this->_proj->k0));
         $lat = Sourcemap_Proj::phi2z($this->_proj->e, $ts);
         if ($lat == -9999) {
             throw new Exception("Lat = -9999");
         }
     }
     $lon = Sourcemap_Proj::adjust_lon($this->_proj->long0 + $x / ($this->_proj->a * $this->_proj->k0));
     $pt->x = $lon;
     $pt->y = $lat;
     return $pt;
 }
Exemplo n.º 14
0
 public function inverse($p)
 {
     #        $sin_phi, $cos_phi;    /* sin and cos value				*/
     #        $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 = $this->phi4z($this->es, $this->e0, $this->e1, $this->e2, $this->e3, $this->al, $b, $c, $lat);
         if ($iflg != 1) {
             return $iflg;
         }
         $lon = Sourcemap_Proj::adjust_lon(Sourcemap_Proj::asinz($p->x * $c / $this->a) / sin($lat) + $this->long0);
     }
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Exemplo n.º 15
0
 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) {
         throw new Exception("orthoInvDataError");
     }
     $z = Sourcemap_Proj::asinz($rh / $this->a);
     $sinz = sin($z);
     $cosz = cos($z);
     $lon = $this->long0;
     if (abs($rh) <= Sourcemap_Proj::EPSLN) {
         $lat = $this->lat0;
     }
     $lat = Sourcemap_Proj::asinz($cosz * $this->sin_p14 + $p->y * $sinz * $this->cos_p14 / $rh);
     $con = abs($lat0) - Sourcemap_Proj::HALF_PI;
     if (abs($con) <= Sourcemap_Proj::EPSLN) {
         if ($this->lat0 >= 0) {
             $lon = Sourcemap_Proj::adjust_lon($this->long0 + atan2($p->x, -$p->y));
         } else {
             $lon = Sourcemap_Proj::adjust_lon($this->long0 - atan2(-$p->x, $p->y));
         }
     }
     $con = $cosz - $this->sin_p14 * sin($lat);
     if (abs($con) >= Sourcemap_Proj::EPSLN || abs($x) >= Sourcemap_Proj::EPSLN) {
         $lon = Sourcemap_Proj::adjust_lon($this->long0 + atan2($p->x * $sinz * $this->cos_p14, $con * $rh));
     }
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }
Exemplo n.º 16
0
 public function inverse($pt)
 {
     $x = ($pt->x - $this->_proj->x0) / $this->_proj->k0;
     $y = $this->_proj->rh - ($pt->y - $this->_proj->y0) / $this->_proj->k0;
     if ($this->_proj->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->_proj->ns > 0.0) {
         $con = 1.0 / $this->_proj->ns;
         $ts = pow($rh1 / ($this->_proj->a * $this->_proj->f0), $con);
         $lat = Sourcemap_Proj::phi2z($this->_proj->e, $ts);
         if ($lat == -9999) {
             return null;
         }
     } else {
         $lat = -Sourcemap_Proj::HALF_PI;
     }
     $lon = Sourcemap_Proj::adjust_lon($theta / $this->_proj->ns + $this->_proj->long0);
     $pt->x = $lon;
     $pt->y = $lat;
     return $pt;
 }
Exemplo n.º 17
0
 public function inverse($p)
 {
     $x = ($p->x - $this->x0) / $this->a;
     /* descale and de-offset */
     $y = ($p->y - $this->y0) / $this->a;
     $tp = 0.0;
     $phi_l = 0.0;
     $halfe = 0.0;
     $pi2 = 0.0;
     if ($this->sphere) {
         $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) <= Sourcemap_Proj::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) <= Sourcemap_Proj::EPSLN) {
                     $lat = $this->phi0;
                 } else {
                     $lat = asin($cosc * $sinph0 + $y * $sinc * $cosph0 / $rh);
                 }
                 $c = $cosc - $sinph0 * sin($lat);
                 if ($c != 0.0 || $x != 0.0) {
                     $lon = atan2($x * $sinc * $cosph0, $c * $rh);
                 }
                 break;
             case $this->N_POLE:
                 $y = -$y;
             case $this->S_POLE:
                 if (abs($rh) <= Sourcemap_Proj::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;
         }
     } 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 * (Sourcemap_Proj::HALF_PI + $phi_l));
                 $x *= $sinphi;
                 $y = $rho * $this->cosX1 * $cosphi - $y * $this->sinX1 * $sinphi;
                 $pi2 = Sourcemap_Proj::HALF_PI;
                 $halfe = 0.5 * $this->e;
                 break;
             case $this->N_POLE:
                 $y = -$y;
             case $this->S_POLE:
                 $tp = -$rho / $this->akm1;
                 $phi_l = Sourcemap_Proj::HALF_PI - 2.0 * atan($tp);
                 $pi2 = -Sourcemap_Proj::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 = Sourcemap_Proj::adjust_lon($lon + $this->long0);
                 $p->y = $lat;
                 return $p;
             }
         }
     }
 }
Exemplo n.º 18
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;
         $sinz = 0.0;
         $rh = sqrt($x * $x + $y * $y);
         $phi = $rh * 0.5;
         if ($phi > 1.0) {
             throw new Exception("Data error.");
         }
         $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) <= Sourcemap_Proj::EPSLN ? 0.0 : asin($y * $sinz / $rh);
                 $x *= $sinz;
                 $y = $cosz * $rh;
                 break;
             case $this->OBLIQ:
                 $phi = abs($rh) <= Sourcemap_Proj::EPSLN ? $this->phi0 : asin($cosz * $sinph0 + $y * $sinz * $cosph0 / $rh);
                 $x *= $sinz * $cosph0;
                 $y = ($cosz - sin($phi) * $sinph0) * $rh;
                 break;
             case $this->N_POLE:
                 $y = -$y;
                 $phi = Sourcemap_Proj::HALF_PI - $phi;
                 break;
             case $this->S_POLE:
                 $phi -= Sourcemap_Proj::HALF_PI;
                 break;
         }
         $lam = $y == 0.0 && ($this->mode == $this->EQUIT || $this->mode == $this->OBLIQ) ? 0.0 : atan2($x, $y);
     } else {
         $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 < Sourcemap_Proj::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) {
       Proj4js.reportError("laea:Inv:DataError");
       return null;
       }
     
       $z = 2.0 * Sourcemap_Proj::asinz(temp);
       $sin_z=sin(z);
       $cos_z=cos(z);
     
       $lon =$this->long0;
       if(abs(Rh) > Sourcemap_Proj::EPSLN) {
       $lat = Sourcemap_Proj::asinz($this->sin_lat_o * cos_z +$this-> cos_lat_o * sin_z *$p->y / Rh);
       $temp =abs($this->lat0) - Sourcemap_Proj::HALF_PI;
       if(abs(temp) > Sourcemap_Proj::EPSLN) {
       temp = cos_z -$this->sin_lat_o * sin(lat);
       if(temp!=0.0) lon=Sourcemap_Proj::adjust_lon($this->long0+atan2($p->x*sin_z*$this->cos_lat_o,temp*Rh));
       } else if($this->lat0 < 0.0) {
       lon = Sourcemap_Proj::adjust_lon($this->long0 - atan2(-$p->x,$p->y));
       } else {
       lon = Sourcemap_Proj::adjust_lon($this->long0 + atan2($p->x, -$p->y));
       }
       } else {
       lat = $this->lat0;
       }
     */
     //return(OK);
     $p->x = Sourcemap_Proj::adjust_lon($this->long0 + $lam);
     $p->y = $phi;
     return $p;
 }
Exemplo n.º 19
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 = $this->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 = Sourcemap_Proj::adjust_lon($this->long0 + $lam);
     $p->y = $phi;
     return $p;
 }
Exemplo n.º 20
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($this->ml, $this->e0, $this->e1, $this->e2, $this->e3);
     $lon = Sourcemap_Proj::adjust_lon($this->long0 + $theta / $this->ns);
     $p->x = lon;
     $p->y = lat;
     return $p;
 }
Exemplo n.º 21
0
 public function inverse($p)
 {
     #$con, $phi;  /* temporary angles       */
     #$delta_phi; /* difference between longitudes    */
     $max_iter = 6;
     /* maximun number of iterations */
     if ($this->sphere) {
         /* 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 = Sourcemap_Proj::asinz($con);
         if ($temp < 0) {
             $lat = -$lat;
         }
         if ($g == 0 && $h == 0) {
             $lon = $this->long0;
         } else {
             $lon = Sourcemap_Proj::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) <= Sourcemap_Proj::EPSLN) {
                 break;
             }
             if ($i >= $max_iter) {
                 throw new Exception("Latitude failed to converge.");
                 #return(95);
             }
         }
         if (abs($phi) < Sourcemap_Proj::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 = Sourcemap_Proj::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 = Sourcemap_Proj::HALF_PI * Sourcemap_Proj::sign($y);
             $lon = $this->long0;
         }
     }
     $p->x = $lon;
     $p->y = $lat;
     return $p;
 }