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/merc.js @ 76

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

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/*******************************************************************************
2NAME                            MERCATOR
3
4PURPOSE:        Transforms input longitude and latitude to Easting and
5                Northing for the Mercator projection.  The
6                longitude and latitude must be in radians.  The Easting
7                and Northing values will be returned in meters.
8
9PROGRAMMER              DATE
10----------              ----
11D. Steinwand, EROS      Nov, 1991
12T. Mittan               Mar, 1993
13
14ALGORITHM REFERENCES
15
161.  Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
17    Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
18    State Government Printing Office, Washington D.C., 1987.
19
202.  Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
21    U.S. Geological Survey Professional Paper 1453 , United State Government
22    Printing Office, Washington D.C., 1989.
23*******************************************************************************/
24
25//static double r_major = a;               /* major axis                                */
26//static double r_minor = b;               /* minor axis                                */
27//static double lon_center = long0;        /* Center longitude (projection center) */
28//static double lat_origin =  lat0;        /* center latitude                   */
29//static double e,es;                      /* eccentricity constants            */
30//static double m1;                            /* small value m                 */
31//static double false_northing = y0;   /* y offset in meters                    */
32//static double false_easting = x0;        /* x offset in meters                        */
33//scale_fact = k0
34
35Proj4js.Proj.merc = {
36  init : function() {
37        //?this.temp = this.r_minor / this.r_major;
38        //this.temp = this.b / this.a;
39        //this.es = 1.0 - Math.sqrt(this.temp);
40        //this.e = Math.sqrt( this.es );
41        //?this.m1 = Math.cos(this.lat_origin) / (Math.sqrt( 1.0 - this.es * Math.sin(this.lat_origin) * Math.sin(this.lat_origin)));
42        //this.m1 = Math.cos(0.0) / (Math.sqrt( 1.0 - this.es * Math.sin(0.0) * Math.sin(0.0)));
43    if (this.lat_ts) {
44      if (this.sphere) {
45        this.k0 = Math.cos(this.lat_ts);
46      } else {
47        this.k0 = Proj4js.common.msfnz(this.es, Math.sin(this.lat_ts), Math.cos(this.lat_ts));
48      }
49    }
50  },
51
52/* Mercator forward equations--mapping lat,long to x,y
53  --------------------------------------------------*/
54
55  forward : function(p) {       
56    //alert("ll2m coords : "+coords);
57    var lon = p.x;
58    var lat = p.y;
59    // convert to radians
60    if ( lat*Proj4js.common.R2D > 90.0 && 
61          lat*Proj4js.common.R2D < -90.0 && 
62          lon*Proj4js.common.R2D > 180.0 && 
63          lon*Proj4js.common.R2D < -180.0) {
64      Proj4js.reportError("merc:forward: llInputOutOfRange: "+ lon +" : " + lat);
65      return null;
66    }
67
68    var x,y;
69    if(Math.abs( Math.abs(lat) - Proj4js.common.HALF_PI)  <= Proj4js.common.EPSLN) {
70      Proj4js.reportError("merc:forward: ll2mAtPoles");
71      return null;
72    } else {
73      if (this.sphere) {
74        x = this.x0 + this.a * this.k0 * Proj4js.common.adjust_lon(lon - this.long0);
75        y = this.y0 + this.a * this.k0 * Math.log(Math.tan(Proj4js.common.FORTPI + 0.5*lat));
76      } else {
77        var sinphi = Math.sin(lat);
78        var ts = Proj4js.common.tsfnz(this.e,lat,sinphi);
79        x = this.x0 + this.a * this.k0 * Proj4js.common.adjust_lon(lon - this.long0);
80        y = this.y0 - this.a * this.k0 * Math.log(ts);
81      }
82      p.x = x; 
83      p.y = y;
84      return p;
85    }
86  },
87
88
89  /* Mercator inverse equations--mapping x,y to lat/long
90  --------------------------------------------------*/
91  inverse : function(p) {       
92
93    var x = p.x - this.x0;
94    var y = p.y - this.y0;
95    var lon,lat;
96
97    if (this.sphere) {
98      lat = Proj4js.common.HALF_PI - 2.0 * Math.atan(Math.exp(-y / this.a * this.k0));
99    } else {
100      var ts = Math.exp(-y / (this.a * this.k0));
101      lat = Proj4js.common.phi2z(this.e,ts);
102      if(lat == -9999) {
103        Proj4js.reportError("merc:inverse: lat = -9999");
104        return null;
105      }
106    }
107    lon = Proj4js.common.adjust_lon(this.long0+ x / (this.a * this.k0));
108
109    p.x = lon;
110    p.y = lat;
111    return p;
112  }
113};
114
115
Note: See TracBrowser for help on using the repository browser.