+++ /dev/null
-/*******************************************************************************\r
-NAME EQUIDISTANT CONIC \r
-\r
-PURPOSE: Transforms input longitude and latitude to Easting and Northing\r
- for the Equidistant Conic projection. The longitude and\r
- latitude must be in radians. The Easting and Northing values\r
- will be returned in meters.\r
-\r
-PROGRAMMER DATE\r
----------- ----\r
-T. Mittan Mar, 1993\r
-\r
-ALGORITHM REFERENCES\r
-\r
-1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological\r
- Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United\r
- State Government Printing Office, Washington D.C., 1987.\r
-\r
-2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",\r
- U.S. Geological Survey Professional Paper 1453 , United State Government\r
- Printing Office, Washington D.C., 1989.\r
-*******************************************************************************/\r
-\r
-/* Variables common to all subroutines in this code file\r
- -----------------------------------------------------*/\r
-\r
-Proj4js.Proj.eqdc = {\r
-\r
-/* Initialize the Equidistant Conic projection\r
- ------------------------------------------*/\r
- init: function() {\r
-\r
- /* Place parameters in static storage for common use\r
- -------------------------------------------------*/\r
-\r
- if(!this.mode) this.mode=0;//chosen default mode\r
- this.temp = this.b / this.a;\r
- this.es = 1.0 - Math.pow(this.temp,2);\r
- this.e = Math.sqrt(this.es);\r
- this.e0 = Proj4js.common.e0fn(this.es);\r
- this.e1 = Proj4js.common.e1fn(this.es);\r
- this.e2 = Proj4js.common.e2fn(this.es);\r
- this.e3 = Proj4js.common.e3fn(this.es);\r
-\r
- this.sinphi=Math.sin(this.lat1);\r
- this.cosphi=Math.cos(this.lat1);\r
-\r
- this.ms1 = Proj4js.common.msfnz(this.e,this.sinphi,this.cosphi);\r
- this.ml1 = Proj4js.common.mlfn(this.e0, this.e1, this.e2,this.e3, this.lat1);\r
-\r
- /* format B\r
- ---------*/\r
- if (this.mode != 0) {\r
- if (Math.abs(this.lat1 + this.lat2) < Proj4js.common.EPSLN) {\r
- Proj4js.reportError("eqdc:Init:EqualLatitudes");\r
- //return(81);\r
- }\r
- this.sinphi=Math.sin(this.lat2);\r
- this.cosphi=Math.cos(this.lat2); \r
-\r
- this.ms2 = Proj4js.common.msfnz(this.e,this.sinphi,this.cosphi);\r
- this.ml2 = Proj4js.common.mlfn(this.e0, this.e1, this.e2, this.e3, this.lat2);\r
- if (Math.abs(this.lat1 - this.lat2) >= Proj4js.common.EPSLN) {\r
- this.ns = (this.ms1 - this.ms2) / (this.ml2 - this.ml1);\r
- } else {\r
- this.ns = this.sinphi;\r
- }\r
- } else {\r
- this.ns = this.sinphi;\r
- }\r
- this.g = this.ml1 + this.ms1/this.ns;\r
- this.ml0 = Proj4js.common.mlfn(this.e0, this.e1,this. e2, this.e3, this.lat0);\r
- this.rh = this.a * (this.g - this.ml0);\r
- },\r
-\r
-\r
-/* Equidistant Conic forward equations--mapping lat,long to x,y\r
- -----------------------------------------------------------*/\r
- forward: function(p) {\r
- var lon=p.x;\r
- var lat=p.y;\r
-\r
- /* Forward equations\r
- -----------------*/\r
- var ml = Proj4js.common.mlfn(this.e0, this.e1, this.e2, this.e3, lat);\r
- var rh1 = this.a * (this.g - ml);\r
- var theta = this.ns * Proj4js.common.adjust_lon(lon - this.long0);\r
-\r
- var x = this.x0 + rh1 * Math.sin(theta);\r
- var y = this.y0 + this.rh - rh1 * Math.cos(theta);\r
- p.x=x;\r
- p.y=y;\r
- return p;\r
- },\r
-\r
-/* Inverse equations\r
- -----------------*/\r
- inverse: function(p) {\r
- p.x -= this.x0;\r
- p.y = this.rh - p.y + this.y0;\r
- var con, rh1;\r
- if (this.ns >= 0) {\r
- var rh1 = Math.sqrt(p.x *p.x + p.y * p.y); \r
- var con = 1.0;\r
- } else {\r
- rh1 = -Math.sqrt(p.x *p. x +p. y * p.y); \r
- con = -1.0;\r
- }\r
- var theta = 0.0;\r
- if (rh1 != 0.0) theta = Math.atan2(con *p.x, con *p.y);\r
- var ml = this.g - rh1 /this.a;\r
- var lat = this.phi3z(this.ml,this.e0,this.e1,this.e2,this.e3);\r
- var lon = Proj4js.common.adjust_lon(this.long0 + theta / this.ns);\r
-\r
- p.x=lon;\r
- p.y=lat; \r
- return p;\r
- },\r
- \r
-/* Function to compute latitude, phi3, for the inverse of the Equidistant\r
- Conic projection.\r
------------------------------------------------------------------*/\r
- phi3z: function(ml,e0,e1,e2,e3) {\r
- var phi;\r
- var dphi;\r
-\r
- phi = ml;\r
- for (var i = 0; i < 15; i++) {\r
- dphi = (ml + e1 * Math.sin(2.0 * phi) - e2 * Math.sin(4.0 * phi) + e3 * Math.sin(6.0 * phi))/ e0 - phi;\r
- phi += dphi;\r
- if (Math.abs(dphi) <= .0000000001) {\r
- return phi;\r
- }\r
- }\r
- Proj4js.reportError("PHI3Z-CONV:Latitude failed to converge after 15 iterations");\r
- return null;\r
- }\r
-\r
- \r
-};
\ No newline at end of file