Subversion Repositories eFlore/Projets.eflore-projets

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
class Proj4phpProjGstmerc {
10
 
11
    public function init() {
12
 
13
        // array of:  a, b, lon0, lat0, k0, x0, y0
14
        $temp = $this->b / $this->a;
15
        $this->e = sqrt( 1.0 - $temp * $temp );
16
        $this->lc = $this->long0;
17
        $this->rs = sqrt( 1.0 + $this->e * $this->e * pow( cos( $this->lat0 ), 4.0 ) / (1.0 - $this->e * $this->e) );
18
        $sinz = sin( $this->lat0 );
19
        $pc = asin( $sinz / $this->rs );
20
        $sinzpc = sin( $pc );
21
        $this->cp = Proj4php::$common->latiso( 0.0, $pc, $sinzpc ) - $this->rs * Proj4php::$common->latiso( $this->e, $this->lat0, $sinz );
22
        $this->n2 = $this->k0 * $this->a * sqrt( 1.0 - $this->e * $this->e ) / (1.0 - $this->e * $this->e * $sinz * $sinz);
23
        $this->xs = $this->x0;
24
        $this->ys = $this->y0 - $this->n2 * $pc;
25
 
26
        if( !$this->title )
27
            $this->title = "Gauss Schreiber transverse mercator";
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
        $L = $this->rs * ($lon - $this->lc);
38
        $Ls = $this->cp + ($this->rs * Proj4php::$common->latiso( $this->e, $lat, sin( $lat ) ));
39
        $lat1 = asin( sin( $L ) / Proj4php::$common . cosh( $Ls ) );
40
        $Ls1 = Proj4php::$common . latiso( 0.0, $lat1, sin( $lat1 ) );
41
        $p->x = $this->xs + ($this->n2 * $Ls1);
42
        $p->y = $this->ys + ($this->n2 * atan( Proj4php::$common->sinh( $Ls ) / cos( $L ) ));
43
        return $p;
44
    }
45
 
46
    // inverse equations--mapping x,y to lat/long
47
    // -----------------------------------------------------------------
48
    public function inverse( $p ) {
49
 
50
        $x = $p->x;
51
        $y = $p->y;
52
 
53
        $L = atan( Proj4php::$common . sinh( ($x - $this->xs) / $this->n2 ) / cos( ($y - $this->ys) / $this->n2 ) );
54
        $lat1 = asin( sin( ($y - $this->ys) / $this->n2 ) / Proj4php::$common . cosh( ($x - $this->xs) / $this->n2 ) );
55
        $LC = Proj4php::$common . latiso( 0.0, $lat1, sin( $lat1 ) );
56
        $p->x = $this->lc + $L / $this->rs;
57
        $p->y = Proj4php::$common . invlatiso( $this->e, ($LC - $this->cp) / $this->rs );
58
        return $p;
59
    }
60
 
61
}
62
 
63
Proj4php::$proj['gstmerc'] = new Proj4phpProjGestmerc();