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 |
/*******************************************************************************
|
|
|
10 |
NAME EQUIRECTANGULAR
|
|
|
11 |
|
|
|
12 |
PURPOSE: Transforms input longitude and latitude to Easting and
|
|
|
13 |
Northing for the Equirectangular projection. The
|
|
|
14 |
longitude and latitude must be in radians. The Easting
|
|
|
15 |
and Northing values will be returned in meters.
|
|
|
16 |
|
|
|
17 |
PROGRAMMER DATE
|
|
|
18 |
---------- ----
|
|
|
19 |
T. Mittan Mar, 1993
|
|
|
20 |
|
|
|
21 |
ALGORITHM REFERENCES
|
|
|
22 |
|
|
|
23 |
1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
|
|
|
24 |
Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
|
|
|
25 |
State Government Printing Office, Washington D.C., 1987.
|
|
|
26 |
|
|
|
27 |
2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
|
|
|
28 |
U.S. Geological Survey Professional Paper 1453 , United State Government
|
|
|
29 |
Printing Office, Washington D.C., 1989.
|
|
|
30 |
*******************************************************************************/
|
|
|
31 |
class Proj4phpProjEqui {
|
|
|
32 |
|
|
|
33 |
public function init() {
|
|
|
34 |
if( !$this->x0 )
|
|
|
35 |
$this->x0 = 0;
|
|
|
36 |
if( !$this->y0 )
|
|
|
37 |
$this->y0 = 0;
|
|
|
38 |
if( !$this->lat0 )
|
|
|
39 |
$this->lat0 = 0;
|
|
|
40 |
if( !$this->long0 )
|
|
|
41 |
$this->long0 = 0;
|
|
|
42 |
///$this->t2;
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
/* Equirectangular forward equations--mapping lat,long to x,y
|
|
|
46 |
--------------------------------------------------------- */
|
|
|
47 |
public function forward( $p ) {
|
|
|
48 |
|
|
|
49 |
$lon = $p->x;
|
|
|
50 |
$lat = $p->y;
|
|
|
51 |
|
|
|
52 |
$dlon = Proj4php::$common->adjust_lon( $lon - $this->long0 );
|
|
|
53 |
$x = $this->x0 + $this->a * $dlon * cos( $this->lat0 );
|
|
|
54 |
$y = $this->y0 + $this->a * $lat;
|
|
|
55 |
|
|
|
56 |
$this->t1 = $x;
|
|
|
57 |
$this->t2 = cos( $this->lat0 );
|
|
|
58 |
$p->x = $x;
|
|
|
59 |
$p->y = $y;
|
|
|
60 |
return $p;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
/* Equirectangular inverse equations--mapping x,y to lat/long
|
|
|
64 |
--------------------------------------------------------- */
|
|
|
65 |
public function inverse( $p ) {
|
|
|
66 |
|
|
|
67 |
$p->x -= $this->x0;
|
|
|
68 |
$p->y -= $this->y0;
|
|
|
69 |
$lat = $p->y / $this->a;
|
|
|
70 |
|
|
|
71 |
if( abs( $lat ) > Proj4php::$common->HALF_PI ) {
|
|
|
72 |
Proj4php::reportError( "equi:Inv:DataError" );
|
|
|
73 |
}
|
|
|
74 |
$lon = Proj4php::$common->adjust_lon( $this->long0 + $p->x / ($this->a * cos( $this->lat0 )) );
|
|
|
75 |
$p->x = $lon;
|
|
|
76 |
$p->y = $lat;
|
|
|
77 |
}
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
Proj4php::$proj['equi'] = new Proj4phpProjEqui();
|