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

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

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/*******************************************************************************
2NAME                            MOLLWEIDE
3
4PURPOSE:        Transforms input longitude and latitude to Easting and
5                Northing for the MOllweide 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      May, 1991;  Updated Sept, 1992; Updated Feb, 1993
12S. Nelson, EDC          Jun, 2993;      Made corrections in precision and
13                                        number of iterations.
14
15ALGORITHM REFERENCES
16
171.  Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
18    U.S. Geological Survey Professional Paper 1453 , United State Government
19    Printing Office, Washington D.C., 1989.
20
212.  Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
22    Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
23    State Government Printing Office, Washington D.C., 1987.
24*******************************************************************************/
25
26Proj4js.Proj.moll = {
27
28  /* Initialize the Mollweide projection
29    ------------------------------------*/
30  init: function(){
31    //no-op
32  },
33
34  /* Mollweide forward equations--mapping lat,long to x,y
35    ----------------------------------------------------*/
36  forward: function(p) {
37
38    /* Forward equations
39      -----------------*/
40    var lon=p.x;
41    var lat=p.y;
42
43    var delta_lon = Proj4js.common.adjust_lon(lon - this.long0);
44    var theta = lat;
45    var con = Proj4js.common.PI * Math.sin(lat);
46
47    /* Iterate using the Newton-Raphson method to find theta
48      -----------------------------------------------------*/
49    for (var i=0;true;i++) {
50       var delta_theta = -(theta + Math.sin(theta) - con)/ (1.0 + Math.cos(theta));
51       theta += delta_theta;
52       if (Math.abs(delta_theta) < Proj4js.common.EPSLN) break;
53       if (i >= 50) {
54          Proj4js.reportError("moll:Fwd:IterationError");
55         //return(241);
56       }
57    }
58    theta /= 2.0;
59
60    /* If the latitude is 90 deg, force the x coordinate to be "0 + false easting"
61       this is done here because of precision problems with "cos(theta)"
62       --------------------------------------------------------------------------*/
63    if (Proj4js.common.PI/2 - Math.abs(lat) < Proj4js.common.EPSLN) delta_lon =0;
64    var x = 0.900316316158 * this.a * delta_lon * Math.cos(theta) + this.x0;
65    var y = 1.4142135623731 * this.a * Math.sin(theta) + this.y0;
66
67    p.x=x;
68    p.y=y;
69    return p;
70  },
71
72  inverse: function(p){
73    var theta;
74    var arg;
75
76    /* Inverse equations
77      -----------------*/
78    p.x-= this.x0;
79    //~ p.y -= this.y0;
80    var arg = p.y /  (1.4142135623731 * this.a);
81
82    /* Because of division by zero problems, 'arg' can not be 1.0.  Therefore
83       a number very close to one is used instead.
84       -------------------------------------------------------------------*/
85    if(Math.abs(arg) > 0.999999999999) arg=0.999999999999;
86    var theta =Math.asin(arg);
87    var lon = Proj4js.common.adjust_lon(this.long0 + (p.x / (0.900316316158 * this.a * Math.cos(theta))));
88    if(lon < (-Proj4js.common.PI)) lon= -Proj4js.common.PI;
89    if(lon > Proj4js.common.PI) lon= Proj4js.common.PI;
90    arg = (2.0 * theta + Math.sin(2.0 * theta)) / Proj4js.common.PI;
91    if(Math.abs(arg) > 1.0)arg=1.0;
92    var lat = Math.asin(arg);
93    //return(OK);
94
95    p.x=lon;
96    p.y=lat;
97    return p;
98  }
99};
100
Note: See TracBrowser for help on using the repository browser.