source:
trunk/workshop-routing-foss4g/web/proj4js/lib/projCode/sinu.js
@
79
Revision 76, 2.4 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Line | |
---|---|
1 | /******************************************************************************* |
2 | NAME SINUSOIDAL |
3 | |
4 | PURPOSE: Transforms input longitude and latitude to Easting and |
5 | Northing for the Sinusoidal 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 | D. Steinwand, EROS May, 1991 |
12 | |
13 | This function was adapted from the Sinusoidal projection code (FORTRAN) in the |
14 | General Cartographic Transformation Package software which is available from |
15 | the U.S. Geological Survey National Mapping Division. |
16 | |
17 | ALGORITHM REFERENCES |
18 | |
19 | 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological |
20 | Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United |
21 | State Government Printing Office, Washington D.C., 1987. |
22 | |
23 | 2. "Software Documentation for GCTP General Cartographic Transformation |
24 | Package", U.S. Geological Survey National Mapping Division, May 1982. |
25 | *******************************************************************************/ |
26 | |
27 | Proj4js.Proj.sinu = { |
28 | |
29 | /* Initialize the Sinusoidal projection |
30 | ------------------------------------*/ |
31 | init: function() { |
32 | /* Place parameters in static storage for common use |
33 | -------------------------------------------------*/ |
34 | this.R = 6370997.0; //Radius of earth |
35 | }, |
36 | |
37 | /* Sinusoidal forward equations--mapping lat,long to x,y |
38 | -----------------------------------------------------*/ |
39 | forward: function(p) { |
40 | var x,y,delta_lon; |
41 | var lon=p.x; |
42 | var lat=p.y; |
43 | /* Forward equations |
44 | -----------------*/ |
45 | delta_lon = Proj4js.common.adjust_lon(lon - this.long0); |
46 | x = this.R * delta_lon * Math.cos(lat) + this.x0; |
47 | y = this.R * lat + this.y0; |
48 | |
49 | p.x=x; |
50 | p.y=y; |
51 | return p; |
52 | }, |
53 | |
54 | inverse: function(p) { |
55 | var lat,temp,lon; |
56 | |
57 | /* Inverse equations |
58 | -----------------*/ |
59 | p.x -= this.x0; |
60 | p.y -= this.y0; |
61 | lat = p.y / this.R; |
62 | if (Math.abs(lat) > Proj4js.common.HALF_PI) { |
63 | Proj4js.reportError("sinu:Inv:DataError"); |
64 | } |
65 | temp = Math.abs(lat) - Proj4js.common.HALF_PI; |
66 | if (Math.abs(temp) > Proj4js.common.EPSLN) { |
67 | temp = this.long0+ p.x / (this.R *Math.cos(lat)); |
68 | lon = Proj4js.common.adjust_lon(temp); |
69 | } else { |
70 | lon = this.long0; |
71 | } |
72 | |
73 | p.x=lon; |
74 | p.y=lat; |
75 | return p; |
76 | } |
77 | }; |
78 | |
79 |
Note: See TracBrowser
for help on using the repository browser.