source:
trunk/workshop-routing-foss4g/web/proj4js/lib/projCode/equi.js
@
78
Revision 76, 2.1 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Line | |
---|---|
1 | /******************************************************************************* |
2 | NAME EQUIRECTANGULAR |
3 | |
4 | PURPOSE: Transforms input longitude and latitude to Easting and |
5 | Northing for the Equirectangular projection. The |
6 | longitude and latitude must be in radians. The Easting |
7 | and Northing values will be returned in meters. |
8 | |
9 | PROGRAMMER DATE |
10 | ---------- ---- |
11 | T. Mittan Mar, 1993 |
12 | |
13 | ALGORITHM REFERENCES |
14 | |
15 | 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological |
16 | Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United |
17 | State Government Printing Office, Washington D.C., 1987. |
18 | |
19 | 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections", |
20 | U.S. Geological Survey Professional Paper 1453 , United State Government |
21 | Printing Office, Washington D.C., 1989. |
22 | *******************************************************************************/ |
23 | Proj4js.Proj.equi = { |
24 | |
25 | init: function() { |
26 | if(!this.x0) this.x0=0; |
27 | if(!this.y0) this.y0=0; |
28 | if(!this.lat0) this.lat0=0; |
29 | if(!this.long0) this.long0=0; |
30 | ///this.t2; |
31 | }, |
32 | |
33 | |
34 | |
35 | /* Equirectangular forward equations--mapping lat,long to x,y |
36 | ---------------------------------------------------------*/ |
37 | forward: function(p) { |
38 | |
39 | var lon=p.x; |
40 | var lat=p.y; |
41 | |
42 | var dlon = Proj4js.common.adjust_lon(lon - this.long0); |
43 | var x = this.x0 +this. a * dlon *Math.cos(this.lat0); |
44 | var y = this.y0 + this.a * lat; |
45 | |
46 | this.t1=x; |
47 | this.t2=Math.cos(this.lat0); |
48 | p.x=x; |
49 | p.y=y; |
50 | return p; |
51 | }, //equiFwd() |
52 | |
53 | |
54 | |
55 | /* Equirectangular inverse equations--mapping x,y to lat/long |
56 | ---------------------------------------------------------*/ |
57 | inverse: function(p) { |
58 | |
59 | p.x -= this.x0; |
60 | p.y -= this.y0; |
61 | var lat = p.y /this. a; |
62 | |
63 | if ( Math.abs(lat) > Proj4js.common.HALF_PI) { |
64 | Proj4js.reportError("equi:Inv:DataError"); |
65 | } |
66 | var lon = Proj4js.common.adjust_lon(this.long0 + p.x / (this.a * Math.cos(this.lat0))); |
67 | p.x=lon; |
68 | p.y=lat; |
69 | }//equiInv() |
70 | }; |
71 | |
72 |
Note: See TracBrowser
for help on using the repository browser.