| 1001 | delphine | 1 | <?php
 | 
        
           |  |  | 2 | /**
 | 
        
           |  |  | 3 |  * Author : Julien Moquet
 | 
        
           |  |  | 4 |  *
 | 
        
           |  |  | 5 |  * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
 | 
        
           |  |  | 6 |  *                      and Richard Greenwood rich@greenwoodma$p->com
 | 
        
           |  |  | 7 |  * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
 | 
        
           |  |  | 8 |  */
 | 
        
           |  |  | 9 | /* similar to equi.js FIXME proj4 uses eqc */
 | 
        
           |  |  | 10 | class Proj4phpProjEqc {
 | 
        
           |  |  | 11 |   | 
        
           |  |  | 12 |     public function init() {
 | 
        
           |  |  | 13 |   | 
        
           |  |  | 14 |         if( !$this->x0 )
 | 
        
           |  |  | 15 |             $this->x0 = 0;
 | 
        
           |  |  | 16 |         if( !$this->y0 )
 | 
        
           |  |  | 17 |             $this->y0 = 0;
 | 
        
           |  |  | 18 |         if( !$this->lat0 )
 | 
        
           |  |  | 19 |             $this->lat0 = 0;
 | 
        
           |  |  | 20 |         if( !$this->long0 )
 | 
        
           |  |  | 21 |             $this->long0 = 0;
 | 
        
           |  |  | 22 |         if( !$this->lat_ts )
 | 
        
           |  |  | 23 |             $this->lat_ts = 0;
 | 
        
           |  |  | 24 |         if( !$this->title )
 | 
        
           |  |  | 25 |             $this->title = "Equidistant Cylindrical (Plate Carre)";
 | 
        
           |  |  | 26 |   | 
        
           |  |  | 27 |         $this->rc = cos( $this->lat_ts );
 | 
        
           |  |  | 28 |     }
 | 
        
           |  |  | 29 |   | 
        
           |  |  | 30 |     // forward equations--mapping lat,long to x,y
 | 
        
           |  |  | 31 |     // -----------------------------------------------------------------
 | 
        
           |  |  | 32 |     public function forward( $p ) {
 | 
        
           |  |  | 33 |   | 
        
           |  |  | 34 |         $lon = $p->x;
 | 
        
           |  |  | 35 |         $lat = $p->y;
 | 
        
           |  |  | 36 |   | 
        
           |  |  | 37 |         $dlon = Proj4php::$common->adjust_lon( $lon - $this->long0 );
 | 
        
           |  |  | 38 |         $dlat = Proj4php::$common . adjust_lat( $lat - $this->lat0 );
 | 
        
           |  |  | 39 |         $p->x = $this->x0 + ($this->a * $dlon * $this->rc);
 | 
        
           |  |  | 40 |         $p->y = $this->y0 + ($this->a * $dlat );
 | 
        
           |  |  | 41 |         return $p;
 | 
        
           |  |  | 42 |     }
 | 
        
           |  |  | 43 |   | 
        
           |  |  | 44 |     // inverse equations--mapping x,y to lat/long
 | 
        
           |  |  | 45 |     // -----------------------------------------------------------------
 | 
        
           |  |  | 46 |     public function inverse( $p ) {
 | 
        
           |  |  | 47 |   | 
        
           |  |  | 48 |         $x = $p->x;
 | 
        
           |  |  | 49 |         $y = $p->y;
 | 
        
           |  |  | 50 |   | 
        
           |  |  | 51 |         $p->x = Proj4php::$common->adjust_lon( $this->long0 + (($x - $this->x0) / ($this->a * $this->rc)) );
 | 
        
           |  |  | 52 |         $p->y = Proj4php::$common->adjust_lat( $this->lat0 + (($y - $this->y0) / ($this->a )) );
 | 
        
           |  |  | 53 |         return $p;
 | 
        
           |  |  | 54 |     }
 | 
        
           |  |  | 55 |   | 
        
           |  |  | 56 | }
 | 
        
           |  |  | 57 |   | 
        
           |  |  | 58 | Proj4php::$proj['eqc'] = new Proj4phpProjEqc();
 |