[76] | 1 | /******************************************************************************* |
---|
| 2 | NAME ORTHOGRAPHIC |
---|
| 3 | |
---|
| 4 | PURPOSE: Transforms input longitude and latitude to Easting and |
---|
| 5 | Northing for the Orthographic 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 | |
---|
| 24 | Proj4js.Proj.ortho = { |
---|
| 25 | |
---|
| 26 | /* Initialize the Orthographic projection |
---|
| 27 | -------------------------------------*/ |
---|
| 28 | init: function(def) { |
---|
| 29 | //double temp; /* temporary variable */ |
---|
| 30 | |
---|
| 31 | /* Place parameters in static storage for common use |
---|
| 32 | -------------------------------------------------*/; |
---|
| 33 | this.sin_p14=Math.sin(this.lat0); |
---|
| 34 | this.cos_p14=Math.cos(this.lat0); |
---|
| 35 | }, |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | /* Orthographic forward equations--mapping lat,long to x,y |
---|
| 39 | ---------------------------------------------------*/ |
---|
| 40 | forward: function(p) { |
---|
| 41 | var sinphi, cosphi; /* sin and cos value */ |
---|
| 42 | var dlon; /* delta longitude value */ |
---|
| 43 | var coslon; /* cos of longitude */ |
---|
| 44 | var ksp; /* scale factor */ |
---|
| 45 | var g; |
---|
| 46 | var lon=p.x; |
---|
| 47 | var lat=p.y; |
---|
| 48 | /* Forward equations |
---|
| 49 | -----------------*/ |
---|
| 50 | dlon = Proj4js.common.adjust_lon(lon - this.long0); |
---|
| 51 | |
---|
| 52 | sinphi=Math.sin(lat); |
---|
| 53 | cosphi=Math.cos(lat); |
---|
| 54 | |
---|
| 55 | coslon = Math.cos(dlon); |
---|
| 56 | g = this.sin_p14 * sinphi + this.cos_p14 * cosphi * coslon; |
---|
| 57 | ksp = 1.0; |
---|
| 58 | if ((g > 0) || (Math.abs(g) <= Proj4js.common.EPSLN)) { |
---|
| 59 | var x = this.a * ksp * cosphi * Math.sin(dlon); |
---|
| 60 | var y = this.y0 + this.a * ksp * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon); |
---|
| 61 | } else { |
---|
| 62 | Proj4js.reportError("orthoFwdPointError"); |
---|
| 63 | } |
---|
| 64 | p.x=x; |
---|
| 65 | p.y=y; |
---|
| 66 | return p; |
---|
| 67 | }, |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | inverse: function(p) { |
---|
| 71 | var rh; /* height above ellipsoid */ |
---|
| 72 | var z; /* angle */ |
---|
| 73 | var sinz,cosz; /* sin of z and cos of z */ |
---|
| 74 | var temp; |
---|
| 75 | var con; |
---|
| 76 | var lon , lat; |
---|
| 77 | /* Inverse equations |
---|
| 78 | -----------------*/ |
---|
| 79 | p.x -= this.x0; |
---|
| 80 | p.y -= this.y0; |
---|
| 81 | rh = Math.sqrt(p.x * p.x + p.y * p.y); |
---|
| 82 | if (rh > this.a + .0000001) { |
---|
| 83 | Proj4js.reportError("orthoInvDataError"); |
---|
| 84 | } |
---|
| 85 | z = Proj4js.common.asinz(rh / this.a); |
---|
| 86 | |
---|
| 87 | sinz=Math.sin(z); |
---|
| 88 | cosz=Math.cos(z); |
---|
| 89 | |
---|
| 90 | lon = this.long0; |
---|
| 91 | if (Math.abs(rh) <= Proj4js.common.EPSLN) { |
---|
| 92 | lat = this.lat0; |
---|
| 93 | } |
---|
| 94 | lat = Proj4js.common.asinz(cosz * this.sin_p14 + (p.y * sinz * this.cos_p14)/rh); |
---|
| 95 | con = Math.abs(this.lat0) - Proj4js.common.HALF_PI; |
---|
| 96 | if (Math.abs(con) <= Proj4js.common.EPSLN) { |
---|
| 97 | if (this.lat0 >= 0) { |
---|
| 98 | lon = Proj4js.common.adjust_lon(this.long0 + Math.atan2(p.x, -p.y)); |
---|
| 99 | } else { |
---|
| 100 | lon = Proj4js.common.adjust_lon(this.long0 -Math.atan2(-p.x, p.y)); |
---|
| 101 | } |
---|
| 102 | } |
---|
| 103 | con = cosz - this.sin_p14 * Math.sin(lat); |
---|
| 104 | p.x=lon; |
---|
| 105 | p.y=lat; |
---|
| 106 | return p; |
---|
| 107 | } |
---|
| 108 | }; |
---|
| 109 | |
---|
| 110 | |
---|