Example #1
0
 public function forward($p)
 {
     $lon = $p->x;
     $lat = $p->y;
     /* Forward equations
     		-----------------*/
     $dlon = Proj4php::$common->adjust_lon($lon - $this->long0);
     $x;
     $y;
     if (abs($lat) <= Proj4php::$common->EPSLN) {
         $x = $this->x0 + $this->R * $dlon;
         $y = $this->y0;
     }
     $theta = Proj4php::$common . asinz(2.0 * abs($lat / Proj4php::$common->PI));
     if (abs($dlon) <= Proj4php::$common->EPSLN || abs(abs($lat) - Proj4php::$common->HALF_PI) <= Proj4php::$common->EPSLN) {
         $x = $this->x0;
         if ($lat >= 0) {
             $y = $this->y0 + Proj4php::$common->PI * $this->R * tan(0.5 * $theta);
         } else {
             $y = $this->y0 + Proj4php::$common->PI * $this->R * -tan(0.5 * $theta);
         }
         //  return(OK);
     }
     $al = 0.5 * abs(Proj4php::$common->PI / $dlon - $dlon / Proj4php::$common->PI);
     $asq = $al * $al;
     $sinth = sin($theta);
     $costh = cos($theta);
     $g = $costh / ($sinth + $costh - 1.0);
     $gsq = $g * $g;
     $m = $g * (2.0 / $sinth - 1.0);
     $msq = $m * $m;
     $con = Proj4php::$common->PI * $this->R * ($al * ($g - $msq) + sqrt($asq * ($g - $sq) * ($g - $msq) - ($msq + $asq) * ($gsq - $msq))) / ($msq + $asq);
     if ($dlon < 0) {
         $con = -$con;
     }
     $x = $this->x0 + $con;
     $con = abs($con / (Proj4php::$common->PI * $this->R));
     if ($lat >= 0) {
         $y = $this->y0 + Proj4php::$common->PI * $this->R * sqrt(1.0 - $con * $con - 2.0 * $al * $con);
     } else {
         $y = $this->y0 - Proj4php::$common->PI * $this->R * sqrt(1.0 - $con * $con - 2.0 * $al * $con);
     }
     $p->x = $x;
     $p->y = $y;
     return $p;
 }
Example #2
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) {
         Proj4php::reportError("orthoInvDataError");
     }
     $z = Proj4php::$common . asinz($rh / $this->a);
     $sinz = sin($z);
     $cosz = cos($z);
     $lon = $this->long0;
     if (abs($rh) <= Proj4php::$common->EPSLN) {
         $lat = $this->lat0;
     }
     $lat = Proj4php::$common . asinz($cosz * $this->sin_p14 + $p->y * $sinz * $this->cos_p14 / $rh);
     $con = abs($this->lat0) - Proj4php::$common->HALF_PI;
     if (abs(con) <= Proj4php::$common->EPSLN) {
         if ($this->lat0 >= 0) {
             $lon = Proj4php::$common->adjust_lon($this->long0 + atan2($p->x, -$p->y));
         } else {
             $lon = Proj4php::$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;
 }