Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 1001 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1001 delphine 1
<?php
2
/*******************************************************************************
3
  NAME                    LAMBERT CYLINDRICAL EQUAL AREA
4
 
5
  PURPOSE:	Transforms input longitude and latitude to Easting and
6
  Northing for the Lambert Cylindrical Equal Area projection.
7
  This class of projection includes the Behrmann and
8
  Gall-Peters Projections.  The
9
  longitude and latitude must be in radians.  The Easting
10
  and Northing values will be returned in meters.
11
 
12
  PROGRAMMER              DATE
13
  ----------              ----
14
  R. Marsden              August 2009
15
  Winwaed Software Tech LLC, http://www.winwaed.com
16
 
17
  This function was adapted from the Miller Cylindrical Projection in the Proj4php
18
  library.
19
 
20
  Note: This implementation assumes a Spherical Earth. The (commented) code
21
  has been included for the ellipsoidal forward transform, but derivation of
22
  the ellispoidal inverse transform is beyond me. Note that most of the
23
  Proj4php implementations do NOT currently support ellipsoidal figures.
24
  Therefore this is not seen as a problem - especially this lack of support
25
  is explicitly stated here.
26
 
27
  ALGORITHM REFERENCES
28
 
29
  1.  "Cartographic Projection Procedures for the UNIX Environment -
30
  A User's Manual" by Gerald I. Evenden, USGS Open File Report 90-284
31
  and Release 4 Interim Reports (2003)
32
 
33
  2.  Snyder, John P., "Flattening the Earth - Two Thousand Years of Map
34
  Projections", Univ. Chicago Press, 1993
35
 ****************************************************************************** */
36
 
37
/**
38
 * Author : Julien Moquet
39
 *
40
 * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
41
 *                      and Richard Greenwood rich@greenwoodma$p->com
42
 * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
43
 */
44
class Proj4phpProjCea {
45
    /* Initialize the Cylindrical Equal Area projection
46
      ------------------------------------------- */
47
 
48
    public function init() {
49
        //no-op
50
    }
51
 
52
    /* Cylindrical Equal Area forward equations--mapping lat,long to x,y
53
      ------------------------------------------------------------ */
54
    public function forward( $p ) {
55
 
56
        $lon = $p->x;
57
        $lat = $p->y;
58
 
59
        /* Forward equations
60
          ----------------- */
61
        $dlon = Proj4php::$common->adjust_lon( $lon - $this->long0 );
62
        $x = $this->x0 + $this->a * $dlon * cos( $this->lat_ts );
63
        $y = $this->y0 + $this->a * sin( $lat ) / cos( $this->lat_ts );
64
        /* Elliptical Forward Transform
65
          Not implemented due to a lack of a matchign inverse function
66
          {
67
          $Sin_Lat = sin(lat);
68
          $Rn = $this->a * (sqrt(1.0e0 - $this->es * Sin_Lat * Sin_Lat ));
69
          x = $this->x0 + $this->a * dlon * cos($this->lat_ts);
70
          y = $this->y0 + Rn * sin(lat) / cos($this->lat_ts);
71
          }
72
         */
73
 
74
        $p->x = $x;
75
        $p->y = $y;
76
 
77
        return $p;
78
    }
79
 
80
    /**
81
     * Cylindrical Equal Area inverse equations--mapping x,y to lat/long
82
     *
83
     * @param type $p
84
     * @return type
85
     */
86
    public function inverse( $p ) {
87
        $p->x -= $this->x0;
88
        $p->y -= $this->y0;
89
 
90
        $p->x = Proj4php::$common->adjust_lon( $this->long0 + ($p->x / $this->a) / cos( $this->lat_ts ) );
91
        $p->y = asin( ($p->y / $this->a) * cos( $this->lat_ts ) );
92
 
93
        return $p;
94
    }
95
}
96
 
97
Proj4php::$proj['cea'] = new Proj4phpProjCea();