Example #1
0
 public function forward($p)
 {
     //alert("ll2m coords : ".coords);
     $lon = $p->x;
     $lat = $p->y;
     // convert to radians
     if (lat * Proj4php::$common->R2D > 90.0 && lat * Proj4php::$common->R2D < -90.0 && lon * Proj4php::$common->R2D > 180.0 && lon * Proj4php::$common->R2D < -180.0) {
         Proj4php::reportError("merc:forward: llInputOutOfRange: " . $lon . " : " . $lat);
         return null;
     }
     $x;
     $y;
     if (abs(abs($lat) - Proj4php::$common->HALF_PI) <= Proj4php::$common->EPSLN) {
         Proj4php::reportError("merc:forward: ll2mAtPoles");
         return null;
     } else {
         if ($this->sphere) {
             $x = $this->x0 + $this->a * $this->k0 * Proj4php::$common->adjust_lon($lon - $this->long0);
             $y = $this->y0 + $this->a * $this->k0 * log(tan(Proj4php::$common . FORTPI + 0.5 * lat));
         } else {
             $sinphi = sin(lat);
             $ts = Proj4php::$common . tsfnz($this->e, $lat, $sinphi);
             $x = $this->x0 + $this->a * $this->k0 * Proj4php::$common->adjust_lon($lon - $this->long0);
             $y = $this->y0 - $this->a * $this->k0 * log($ts);
         }
         $p->x = $x;
         $p->y = $y;
         return $p;
     }
 }
Example #2
0
 public function ll2lcc($coords)
 {
     $lon = $coords[0];
     $lat = $coords[1];
     // convert to radians
     if ($lat <= 90.0 && $lat >= -90.0 && $lon <= 180.0 && $lon >= -180.0) {
         $lat *= D2R;
         $lon *= D2R;
     } else {
         die("*** Input out of range ***: lon: " + lon + " - lat: " + lat);
         return null;
     }
     $con = abs(abs($lat) - HALF_PI);
     $ts;
     if ($con > EPSLN) {
         $ts = tsfnz($this->e, $lat, sin($lat));
         $rh1 = $this->r_major * $this->f0 * pow($ts, $this->ns);
     } else {
         $con = $lat * $this->ns;
         if ($con <= 0) {
             die("Point can not be projected - ll2lcc");
             return null;
         }
         $rh1 = 0;
     }
     $theta = $this->ns * adjust_lon($lon - $this->center_lon);
     $x = $rh1 * sin($theta) + $this->false_easting;
     $y = $this->rh - $rh1 * cos($theta) + $this->false_northing;
     return array($x, $y);
 }