Пример #1
0
 public function testTsfnz()
 {
     $ret = Common::tsfnz(0.12, 0.3, 0.4);
     $this->assertEquals(0.74167840619598, $ret, "", 1.0E-6);
     $ret = Common::tsfnz(0.4, 0.1, 0.8);
     $this->assertEquals(1.0330253798791, $ret, "", 1.0E-6);
 }
Пример #2
0
 public function forward($p)
 {
     //alert("ll2m coords : ".coords);
     $lon = $p->x;
     $lat = $p->y;
     // convert to radians
     if ($lat * Common::R2D > 90.0 && $lat * Common::R2D < -90.0 && $lon * Common::R2D > 180.0 && $lon * Common::R2D < -180.0) {
         Proj4php::reportError("merc:forward: llInputOutOfRange: " . $lon . " : " . $lat);
         return null;
     }
     if (abs(abs($lat) - Common::HALF_PI) <= Common::EPSLN) {
         Proj4php::reportError("merc:forward: ll2mAtPoles");
         return null;
     } else {
         if ($this->sphere) {
             $x = $this->x0 + $this->a * $this->k0 * Common::adjust_lon($lon - $this->long0);
             $y = $this->y0 + $this->a * $this->k0 * log(tan(Common::FORTPI + 0.5 * $lat));
         } else {
             $sinphi = sin(lat);
             $ts = Common::tsfnz($this->e, $lat, $sinphi);
             $x = $this->x0 + $this->a * $this->k0 * Common::adjust_lon($lon - $this->long0);
             $y = $this->y0 - $this->a * $this->k0 * log($ts);
         }
         $p->x = $x;
         $p->y = $y;
         return $p;
     }
 }
Пример #3
0
 public function forward($p)
 {
     /*
     $theta;   // angle					 
     $sin_phi;
     $cos_phi;  // sin and cos value	
     $b;  // temporary values
     $c;
     $t;
     $tq; // temporary values
     $con;
     $n;
     $ml; // cone constant, small m	
     $q;
     $us;
     $vl;
     $ul;
     $vs;
     $s;
     $dlon;
     $ts1;
     */
     $lon = $p->x;
     $lat = $p->y;
     /* Forward equations
        ----------------- */
     $sin_phi = sin($lat);
     $dlon = Common::adjust_lon($lon - $this->longc);
     $vl = sin($this->bl * $dlon);
     if (abs(abs($lat) - Common::HALF_PI) > Common::EPSLN) {
         $ts1 = Common::tsfnz($this->e, $lat, $sin_phi);
         $q = $this->el / pow($ts1, $this->bl);
         $s = 0.5 * ($q - 1.0 / $q);
         $t = 0.5 * ($q + 1.0 / $q);
         $ul = ($s * $this->singam - $vl * $this->cosgam) / $t;
         $con = cos($this->bl * $dlon);
         if (abs(con) < 1.0E-7) {
             $us = $this->al * $this->bl * $dlon;
         } else {
             $us = $this->al * atan(($s * $this->cosgam + $vl * $this->singam) / $con) / $this->bl;
             if ($con < 0) {
                 $us = $us + Common::PI * $this->al / $this->bl;
             }
         }
     } else {
         if ($lat >= 0) {
             $ul = $this->singam;
         } else {
             $ul = -$this->singam;
         }
         $us = $this->al * $lat / $this->bl;
     }
     if (abs(abs($ul) - 1.0) <= Common::EPSLN) {
         //alert("Point projects into infinity","omer-for");
         Proj4php::reportError("omercFwdInfinity");
         //return(205);
     }
     $vs = 0.5 * $this->al * log((1.0 - $ul) / (1.0 + $ul)) / $this->bl;
     $us = $us - $this->u;
     $p->x = $this->x0 + $vs * $this->cosaz + $us * $this->sinaz;
     $p->y = $this->y0 + $us * $this->cosaz - $vs * $this->sinaz;
     return $p;
 }
Пример #4
0
 public function forward(Point $p)
 {
     list($lon, $lat) = $p->toArray();
     // convert to radians
     if ($lat <= 90.0 && $lat >= -90.0 && $lon <= 180.0 && $lon >= -180.0) {
         //lon = lon * Common::D2R;
         //lat = lat * Common::D2R;
     } else {
         Proj4php::reportError('lcc:forward: llInputOutOfRange: ' . $lon . ' : ' . $lat);
         return;
     }
     $con = abs(abs($lat) - Common::HALF_PI);
     if ($con > Common::EPSLN) {
         $ts = Common::tsfnz($this->e, $lat, sin($lat));
         $rh1 = $this->a * $this->f0 * pow($ts, $this->ns);
     } else {
         $con = $lat * $this->ns;
         if ($con <= 0) {
             Proj4php::reportError('lcc:forward: No Projection');
             return;
         }
         $rh1 = 0;
     }
     $theta = $this->ns * Common::adjust_lon($lon - $this->long0);
     $p->x = $this->k0 * ($rh1 * sin($theta)) + $this->x0;
     $p->y = $this->k0 * ($this->rh - $rh1 * cos($theta)) + $this->y0;
     return $p;
 }
Пример #5
0
 /**
  * Stereographic forward equations--mapping lat,long to x,y
  *
  * @param type $p
  * @return type 
  */
 public function forward($p)
 {
     $lon = $p->x;
     $lon = Common::adjust_lon($lon - $this->long0);
     $lat = $p->y;
     if ($this->sphere) {
         /*
         $sinphi;
         $cosphi;
         $coslam;
         $sinlam;
         */
         $sinphi = sin($lat);
         $cosphi = cos($lat);
         $coslam = cos($lon);
         $sinlam = sin($lon);
         switch ($this->mode) {
             case $this->EQUIT:
                 $y = 1.0 + $cosphi * $coslam;
                 if (y <= Common::EPSLN) {
                     Proj4php::reportError("stere:forward:Equit");
                 }
                 $y = $this->akm1 / $y;
                 $x = $y * $cosphi * $sinlam;
                 $y *= $sinphi;
                 break;
             case $this->OBLIQ:
                 $y = 1.0 + $this->sinph0 * $sinphi + $this->cosph0 * $cosphi * $coslam;
                 if ($y <= Common::EPSLN) {
                     Proj4php::reportError("stere:forward:Obliq");
                 }
                 $y = $this->akm1 / $y;
                 $x = $y * $cosphi * $sinlam;
                 $y *= $this->cosph0 * $sinphi - $this->sinph0 * $cosphi * $coslam;
                 break;
             case $this->N_POLE:
                 $coslam = -$coslam;
                 $lat = -$lat;
                 //Note  no break here so it conitnues through S_POLE
             //Note  no break here so it conitnues through S_POLE
             case $this->S_POLE:
                 if (abs($lat - Common::HALF_PI) < $this->TOL) {
                     Proj4php::reportError("stere:forward:S_POLE");
                 }
                 $y = $this->akm1 * tan(Common::FORTPI + 0.5 * $lat);
                 $x = $sinlam * $y;
                 $y *= $coslam;
                 break;
         }
     } else {
         $coslam = cos($lon);
         $sinlam = sin($lon);
         $sinphi = sin($lat);
         if ($this->mode == $this->OBLIQ || $this->mode == $this->EQUIT) {
             $Xt = 2.0 * atan($this->ssfn_($lat, $sinphi, $this->e));
             $sinX = sin($Xt - Common::HALF_PI);
             $cosX = cos($Xt);
         }
         switch ($this->mode) {
             case $this->OBLIQ:
                 $A = $this->akm1 / ($this->cosX1 * (1.0 + $this->sinX1 * $sinX + $this->cosX1 * $cosX * $coslam));
                 $y = $A * ($this->cosX1 * $sinX - $this->sinX1 * $cosX * $coslam);
                 $x = $A * $cosX;
                 break;
             case $this->EQUIT:
                 $A = 2.0 * $this->akm1 / (1.0 + $cosX * $coslam);
                 $y = $A * $sinX;
                 $x = $A * $cosX;
                 break;
             case $this->S_POLE:
                 $lat = -$lat;
                 $coslam = -$coslam;
                 $sinphi = -$sinphi;
             case $this->N_POLE:
                 $x = $this->akm1 * Common::tsfnz($this->e, $lat, $sinphi);
                 $y = -$x * $coslam;
                 break;
         }
         $x = $x * $sinlam;
     }
     $p->x = $x * $this->a + $this->x0;
     $p->y = $y * $this->a + $this->y0;
     return $p;
 }
Пример #6
0
 public function debugString()
 {
     $str = "title= {$this->title}\n";
     $str .= "k0={$this->k0}\n";
     $str .= "to_meter={$this->to_meter}\n";
     $str .= "phiF = {$this->lat0}\n";
     $str .= "lamF = {$this->long0}\n";
     $str .= "phi1 = {$this->lat1}\n";
     $str .= "phi2 = {$this->lat2}\n";
     $str .= "EF = {$this->x0}\n";
     $str .= "NF = {$this->y0}\n";
     $str .= "a={$this->a}\n";
     $str .= "e={$this->e}\n";
     $str .= "m1=" . Common::msfnz($this->e, sin($this->lat1), cos($this->lat1)) . "\n";
     $str .= "m2=" . Common::msfnz($this->e, sin($this->lat2), cos($this->lat2)) . "\n";
     $str .= "n={$this->ns}\n";
     $str .= "F={$this->f0}\n";
     $str .= "tF=" . Common::tsfnz($this->e, $this->lat0, sin($this->lat0)) . "\n";
     $str .= "t1=" . Common::tsfnz($this->e, $this->lat1, sin($this->lat1)) . "\n";
     $str .= "t2=" . Common::tsfnz($this->e, $this->lat2, sin($this->lat2)) . "\n";
     $str .= "rF={$this->rh}\n";
     return $str;
 }