Ejemplo n.º 1
0
 public function forward($pt)
 {
     $lon = $pt->x;
     $lat = $pt->y;
     // convert to radians
     if ($lat * Sourcemap_Proj::R2D > 90.0 && $lat * Sourcemap_Proj::R2D < -90.0 && $lon * Sourcemap_Proj::R2D > 180.0 && $lon * Sourcemap_Proj::R2D < -180.0) {
         throw new Exception('Lat/Lon input out of range.');
     }
     if (abs(abs($lat) - Sourcemap_Proj::HALF_PI) <= Sourcemap_Proj::EPSLN) {
         throw new Exception('Lat/Long at poles.');
     } else {
         if ($this->_proj->sphere) {
             $x = $this->_proj->x0 + $this->_proj->a * $this->_proj->k0 * Sourcemap_Proj::adjust_lon($lon - $this->_proj->long0);
             $y = $this->_proj->y0 + $this->_proj->a * $this->_proj->k0 * log(tan(Sourcemap_Proj::FORTPI + 0.5 * $lat));
         } else {
             $sinphi = sin($lat);
             $ts = Sourcemap_Proj::tsfnz($this->_proj->e, $lat, $sinphi);
             $x = $this->_proj->x0 + $this->_proj->a * $this->_proj->k0 * Sourcemap_Proj::adjust_lon($lon - $this->_proj->long0);
             $y = $this->_proj->y0 - $this->_proj->a * $this->_proj->k0 * log($ts);
         }
         $pt->x = $x;
         $pt->y = $y;
         return $pt;
     }
 }
Ejemplo n.º 2
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 = Sourcemap_Proj::adjust_lon($lon - $this->longc);
     $vl = sin($this->bl * $dlon);
     if (abs(abs($lat) - Sourcemap_Proj::HALF_PI) > Sourcemap_Proj::EPSLN) {
         $ts1 = Sourcemap_Proj::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 + Sourcemap_Proj::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) <= Sourcemap_Proj::EPSLN) {
         throw new Exception("Infinity...");
     }
     $vs = 0.5 * $this->al * log((1.0 - $ul) / (1.0 + $ul)) / $this->bl;
     $us = $us - $this->u;
     $x = $this->x0 + $vs * $this->cosaz + $us * $this->sinaz;
     $y = $this->y0 + $us * $this->cosaz - $vs * $this->sinaz;
     $p->x = $x;
     $p->y = $y;
     return $p;
 }
Ejemplo n.º 3
0
 public function forward($pt)
 {
     $lon = $pt->x;
     $lat = $pt->y;
     // convert to radians
     if ($lat <= 90.0 && $lat >= -90.0 && $lon <= 180.0 && $lon >= -180.0) {
         //lon = lon * Sourcemap_Proj::D2R;
         //lat = lat * Sourcemap_Proj::D2R;
         // holdover from proj4js
     } else {
         throw new Exception('Lat/Lon input out of range.');
     }
     $con = abs(abs($lat) - Sourcemap_Proj::HALF_PI);
     if ($con > Sourcemap_Proj::EPSLN) {
         $ts = Sourcemap_Proj::tsfnz($this->_proj->e, $lat, sin($lat));
         $rh1 = $this->_proj->a * $this->_proj->f0 * pow($ts, $this->_proj->ns);
     } else {
         $con = $lat * $this->_proj->ns;
         if ($con <= 0) {
             throw new Exception('No projection.');
         }
         $rh1 = 0;
     }
     $theta = $this->_proj->ns * Sourcemap_Proj::adjust_lon($lon - $this->_proj->long0);
     $pt->x = $this->_proj->k0 * (rh1 * sin(theta)) + $this->_proj->x0;
     $pt->y = $this->_proj->k0 * ($this->_proj->rh - $rh1 * cos($theta)) + $this->_proj->y0;
     return $pt;
 }
Ejemplo n.º 4
0
 public function forward($p)
 {
     $lon = $p->x;
     $lon = Sourcemap_Proj::adjust_lon($lon - $this->long0);
     $lat = $p->y;
     if ($this->sphere) {
         $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 <= Sourcemap_Proj::EPSLN) {
                     throw new Exception("Bad y.");
                 }
                 $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 <= Sourcemap_Proj::EPSLN) {
                     throw new Exception("Bad y.");
                 }
                 $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 - Sourcemap_Proj::HALF_PI) < $this->TOL) {
                     throw new Exception("Bad value.");
                 }
                 $y = $this->akm1 * tan(Sourcemap_Proj::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) {
             $X = 2.0 * atan($this->ssfn_($lat, $sinphi, $this->e));
             $sinX = sin($X - Sourcemap_Proj::HALF_PI);
             $cosX = cos($X);
         }
         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 * Sourcemap_Proj::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;
 }