Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-routing-foss4g/web/proj4js/lib/projCode/eqdc.js @ 76

Revision 76, 4.6 KB checked in by djay, 12 years ago (diff)

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/*******************************************************************************
2NAME                            EQUIDISTANT CONIC
3
4PURPOSE:        Transforms input longitude and latitude to Easting and Northing
5                for the Equidistant Conic projection.  The longitude and
6                latitude must be in radians.  The Easting and Northing values
7                will be returned in meters.
8
9PROGRAMMER              DATE
10----------              ----
11T. Mittan               Mar, 1993
12
13ALGORITHM REFERENCES
14
151.  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
192.  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/* Variables common to all subroutines in this code file
25  -----------------------------------------------------*/
26
27Proj4js.Proj.eqdc = {
28
29/* Initialize the Equidistant Conic projection
30  ------------------------------------------*/
31  init: function() {
32
33    /* Place parameters in static storage for common use
34      -------------------------------------------------*/
35
36    if(!this.mode) this.mode=0;//chosen default mode
37    this.temp = this.b / this.a;
38    this.es = 1.0 - Math.pow(this.temp,2);
39    this.e = Math.sqrt(this.es);
40    this.e0 = Proj4js.common.e0fn(this.es);
41    this.e1 = Proj4js.common.e1fn(this.es);
42    this.e2 = Proj4js.common.e2fn(this.es);
43    this.e3 = Proj4js.common.e3fn(this.es);
44
45    this.sinphi=Math.sin(this.lat1);
46    this.cosphi=Math.cos(this.lat1);
47
48    this.ms1 = Proj4js.common.msfnz(this.e,this.sinphi,this.cosphi);
49    this.ml1 = Proj4js.common.mlfn(this.e0, this.e1, this.e2,this.e3, this.lat1);
50
51    /* format B
52    ---------*/
53    if (this.mode != 0) {
54      if (Math.abs(this.lat1 + this.lat2) < Proj4js.common.EPSLN) {
55            Proj4js.reportError("eqdc:Init:EqualLatitudes");
56            //return(81);
57       }
58       this.sinphi=Math.sin(this.lat2);
59       this.cosphi=Math.cos(this.lat2);   
60
61       this.ms2 = Proj4js.common.msfnz(this.e,this.sinphi,this.cosphi);
62       this.ml2 = Proj4js.common.mlfn(this.e0, this.e1, this.e2, this.e3, this.lat2);
63       if (Math.abs(this.lat1 - this.lat2) >= Proj4js.common.EPSLN) {
64         this.ns = (this.ms1 - this.ms2) / (this.ml2 - this.ml1);
65       } else {
66          this.ns = this.sinphi;
67       }
68    } else {
69      this.ns = this.sinphi;
70    }
71    this.g = this.ml1 + this.ms1/this.ns;
72    this.ml0 = Proj4js.common.mlfn(this.e0, this.e1,this. e2, this.e3, this.lat0);
73    this.rh = this.a * (this.g - this.ml0);
74  },
75
76
77/* Equidistant Conic forward equations--mapping lat,long to x,y
78  -----------------------------------------------------------*/
79  forward: function(p) {
80    var lon=p.x;
81    var lat=p.y;
82
83    /* Forward equations
84      -----------------*/
85    var ml = Proj4js.common.mlfn(this.e0, this.e1, this.e2, this.e3, lat);
86    var rh1 = this.a * (this.g - ml);
87    var theta = this.ns * Proj4js.common.adjust_lon(lon - this.long0);
88
89    var x = this.x0  + rh1 * Math.sin(theta);
90    var y = this.y0 + this.rh - rh1 * Math.cos(theta);
91    p.x=x;
92    p.y=y;
93    return p;
94  },
95
96/* Inverse equations
97  -----------------*/
98  inverse: function(p) {
99    p.x -= this.x0;
100    p.y  = this.rh - p.y + this.y0;
101    var con, rh1;
102    if (this.ns >= 0) {
103       var rh1 = Math.sqrt(p.x *p.x + p.y * p.y); 
104       var con = 1.0;
105    } else {
106       rh1 = -Math.sqrt(p.x *p. x +p. y * p.y); 
107       con = -1.0;
108    }
109    var theta = 0.0;
110    if (rh1 != 0.0) theta = Math.atan2(con *p.x, con *p.y);
111    var ml = this.g - rh1 /this.a;
112    var lat = this.phi3z(ml,this.e0,this.e1,this.e2,this.e3);
113    var lon = Proj4js.common.adjust_lon(this.long0 + theta / this.ns);
114
115     p.x=lon;
116     p.y=lat; 
117     return p;
118    },
119   
120/* Function to compute latitude, phi3, for the inverse of the Equidistant
121   Conic projection.
122-----------------------------------------------------------------*/
123  phi3z: function(ml,e0,e1,e2,e3) {
124    var phi;
125    var dphi;
126
127    phi = ml;
128    for (var i = 0; i < 15; i++) {
129      dphi = (ml + e1 * Math.sin(2.0 * phi) - e2 * Math.sin(4.0 * phi) + e3 * Math.sin(6.0 * phi))/ e0 - phi;
130      phi += dphi;
131      if (Math.abs(dphi) <= .0000000001) {
132        return phi;
133      }
134    }
135    Proj4js.reportError("PHI3Z-CONV:Latitude failed to converge after 15 iterations");
136    return null;
137  }
138
139   
140};
Note: See TracBrowser for help on using the repository browser.