[76] | 1 | /******************************************************************************* |
---|
| 2 | NAME LAMBERT CONFORMAL CONIC |
---|
| 3 | |
---|
| 4 | PURPOSE: Transforms input longitude and latitude to Easting and |
---|
| 5 | Northing for the Lambert Conformal Conic projection. The |
---|
| 6 | longitude and latitude must be in radians. The Easting |
---|
| 7 | and Northing values will be returned in meters. |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | ALGORITHM REFERENCES |
---|
| 11 | |
---|
| 12 | 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological |
---|
| 13 | Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United |
---|
| 14 | State Government Printing Office, Washington D.C., 1987. |
---|
| 15 | |
---|
| 16 | 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections", |
---|
| 17 | U.S. Geological Survey Professional Paper 1453 , United State Government |
---|
| 18 | *******************************************************************************/ |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | //<2104> +proj=lcc +lat_1=10.16666666666667 +lat_0=10.16666666666667 +lon_0=-71.60561777777777 +k_0=1 +x0=-17044 +x0=-23139.97 +ellps=intl +units=m +no_defs no_defs |
---|
| 22 | |
---|
| 23 | // Initialize the Lambert Conformal conic projection |
---|
| 24 | // ----------------------------------------------------------------- |
---|
| 25 | |
---|
| 26 | //Proj4js.Proj.lcc = Class.create(); |
---|
| 27 | Proj4js.Proj.lcc = { |
---|
| 28 | init : function() { |
---|
| 29 | |
---|
| 30 | // array of: r_maj,r_min,lat1,lat2,c_lon,c_lat,false_east,false_north |
---|
| 31 | //double c_lat; /* center latitude */ |
---|
| 32 | //double c_lon; /* center longitude */ |
---|
| 33 | //double lat1; /* first standard parallel */ |
---|
| 34 | //double lat2; /* second standard parallel */ |
---|
| 35 | //double r_maj; /* major axis */ |
---|
| 36 | //double r_min; /* minor axis */ |
---|
| 37 | //double false_east; /* x offset in meters */ |
---|
| 38 | //double false_north; /* y offset in meters */ |
---|
| 39 | |
---|
| 40 | if (!this.lat2){this.lat2=this.lat0;}//if lat2 is not defined |
---|
| 41 | if (!this.k0) this.k0 = 1.0; |
---|
| 42 | |
---|
| 43 | // Standard Parallels cannot be equal and on opposite sides of the equator |
---|
| 44 | if (Math.abs(this.lat1+this.lat2) < Proj4js.common.EPSLN) { |
---|
| 45 | Proj4js.reportError("lcc:init: Equal Latitudes"); |
---|
| 46 | return; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | var temp = this.b / this.a; |
---|
| 50 | this.e = Math.sqrt(1.0 - temp*temp); |
---|
| 51 | |
---|
| 52 | var sin1 = Math.sin(this.lat1); |
---|
| 53 | var cos1 = Math.cos(this.lat1); |
---|
| 54 | var ms1 = Proj4js.common.msfnz(this.e, sin1, cos1); |
---|
| 55 | var ts1 = Proj4js.common.tsfnz(this.e, this.lat1, sin1); |
---|
| 56 | |
---|
| 57 | var sin2 = Math.sin(this.lat2); |
---|
| 58 | var cos2 = Math.cos(this.lat2); |
---|
| 59 | var ms2 = Proj4js.common.msfnz(this.e, sin2, cos2); |
---|
| 60 | var ts2 = Proj4js.common.tsfnz(this.e, this.lat2, sin2); |
---|
| 61 | |
---|
| 62 | var ts0 = Proj4js.common.tsfnz(this.e, this.lat0, Math.sin(this.lat0)); |
---|
| 63 | |
---|
| 64 | if (Math.abs(this.lat1 - this.lat2) > Proj4js.common.EPSLN) { |
---|
| 65 | this.ns = Math.log(ms1/ms2)/Math.log(ts1/ts2); |
---|
| 66 | } else { |
---|
| 67 | this.ns = sin1; |
---|
| 68 | } |
---|
| 69 | this.f0 = ms1 / (this.ns * Math.pow(ts1, this.ns)); |
---|
| 70 | this.rh = this.a * this.f0 * Math.pow(ts0, this.ns); |
---|
| 71 | if (!this.title) this.title = "Lambert Conformal Conic"; |
---|
| 72 | }, |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | // Lambert Conformal conic forward equations--mapping lat,long to x,y |
---|
| 76 | // ----------------------------------------------------------------- |
---|
| 77 | forward : function(p) { |
---|
| 78 | |
---|
| 79 | var lon = p.x; |
---|
| 80 | var lat = p.y; |
---|
| 81 | |
---|
| 82 | // convert to radians |
---|
| 83 | if ( lat <= 90.0 && lat >= -90.0 && lon <= 180.0 && lon >= -180.0) { |
---|
| 84 | //lon = lon * Proj4js.common.D2R; |
---|
| 85 | //lat = lat * Proj4js.common.D2R; |
---|
| 86 | } else { |
---|
| 87 | Proj4js.reportError("lcc:forward: llInputOutOfRange: "+ lon +" : " + lat); |
---|
| 88 | return null; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | var con = Math.abs( Math.abs(lat) - Proj4js.common.HALF_PI); |
---|
| 92 | var ts, rh1; |
---|
| 93 | if (con > Proj4js.common.EPSLN) { |
---|
| 94 | ts = Proj4js.common.tsfnz(this.e, lat, Math.sin(lat) ); |
---|
| 95 | rh1 = this.a * this.f0 * Math.pow(ts, this.ns); |
---|
| 96 | } else { |
---|
| 97 | con = lat * this.ns; |
---|
| 98 | if (con <= 0) { |
---|
| 99 | Proj4js.reportError("lcc:forward: No Projection"); |
---|
| 100 | return null; |
---|
| 101 | } |
---|
| 102 | rh1 = 0; |
---|
| 103 | } |
---|
| 104 | var theta = this.ns * Proj4js.common.adjust_lon(lon - this.long0); |
---|
| 105 | p.x = this.k0 * (rh1 * Math.sin(theta)) + this.x0; |
---|
| 106 | p.y = this.k0 * (this.rh - rh1 * Math.cos(theta)) + this.y0; |
---|
| 107 | |
---|
| 108 | return p; |
---|
| 109 | }, |
---|
| 110 | |
---|
| 111 | // Lambert Conformal Conic inverse equations--mapping x,y to lat/long |
---|
| 112 | // ----------------------------------------------------------------- |
---|
| 113 | inverse : function(p) { |
---|
| 114 | |
---|
| 115 | var rh1, con, ts; |
---|
| 116 | var lat, lon; |
---|
| 117 | var x = (p.x - this.x0)/this.k0; |
---|
| 118 | var y = (this.rh - (p.y - this.y0)/this.k0); |
---|
| 119 | if (this.ns > 0) { |
---|
| 120 | rh1 = Math.sqrt (x * x + y * y); |
---|
| 121 | con = 1.0; |
---|
| 122 | } else { |
---|
| 123 | rh1 = -Math.sqrt (x * x + y * y); |
---|
| 124 | con = -1.0; |
---|
| 125 | } |
---|
| 126 | var theta = 0.0; |
---|
| 127 | if (rh1 != 0) { |
---|
| 128 | theta = Math.atan2((con * x),(con * y)); |
---|
| 129 | } |
---|
| 130 | if ((rh1 != 0) || (this.ns > 0.0)) { |
---|
| 131 | con = 1.0/this.ns; |
---|
| 132 | ts = Math.pow((rh1/(this.a * this.f0)), con); |
---|
| 133 | lat = Proj4js.common.phi2z(this.e, ts); |
---|
| 134 | if (lat == -9999) return null; |
---|
| 135 | } else { |
---|
| 136 | lat = -Proj4js.common.HALF_PI; |
---|
| 137 | } |
---|
| 138 | lon = Proj4js.common.adjust_lon(theta/this.ns + this.long0); |
---|
| 139 | |
---|
| 140 | p.x = lon; |
---|
| 141 | p.y = lat; |
---|
| 142 | return p; |
---|
| 143 | } |
---|
| 144 | }; |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | |
---|