Skip to content

Commit

Permalink
re #61: fixing various global declarations
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/metacrs/proj4js@2098 4e78687f-474d-0410-85f9-8d5e500ac6b2
  • Loading branch information
madair committed Sep 17, 2011
1 parent fd9103b commit 3de0415
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 41 deletions.
2 changes: 1 addition & 1 deletion trunk/lib/proj4js.js
Expand Up @@ -220,7 +220,7 @@ Proj4js = {
if (point[t]!==undefined) { point.z= -v; }
break;
default :
alert("ERROR: unknow axis ("+crs.axis[i]+") - check definition of "+src.projName);
alert("ERROR: unknow axis ("+crs.axis[i]+") - check definition of "+crs.projName);
return null;
}
}
Expand Down
8 changes: 4 additions & 4 deletions trunk/lib/projCode/aea.js
Expand Up @@ -106,13 +106,13 @@ Proj4js.Proj.aea = {
lat = this.phi1z(this.e3,qs);
} else {
if (qs >= 0) {
lat = .5 * PI;
lat = .5 * Proj4js.common.PI;
} else {
lat = -.5 * PI;
lat = -.5 * Proj4js.common.PI;
}
}
} else {
lat = this.phi1z(e3,qs);
lat = this.phi1z(this.e3,qs);
}

lon = Proj4js.common.adjust_lon(theta/this.ns0 + this.long0);
Expand All @@ -125,7 +125,7 @@ Proj4js.Proj.aea = {
Albers Conical Equal-Area projection.
-------------------------------------------*/
phi1z: function (eccent,qs) {
var con, com, dphi;
var sinphi, cosphi, con, com, dphi;
var phi = Proj4js.common.asinz(.5 * qs);
if (eccent < Proj4js.common.EPSLN) return phi;

Expand Down
15 changes: 8 additions & 7 deletions trunk/lib/projCode/cass.js
Expand Up @@ -80,14 +80,15 @@ Proj4js.Proj.cass = {
p.y -= this.y0;
var x = p.x/this.a;
var y = p.y/this.a;

var phi, lam;

if (this.sphere) {
this.dd = y + this.lat0;
phi = Math.asin(Math.sin(this.dd) * Math.cos(x));
lam = Math.atan2(Math.tan(x), Math.cos(this.dd));
} else {
/* ellipsoid */
ph1 = this.pj_inv_mlfn(this.m0 + y, this.es, this.en);
var ph1 = this.pj_inv_mlfn(this.m0 + y, this.es, this.en);
this.tn = Math.tan(ph1);
this.t = this.tn * this.tn;
this.n = Math.sin(ph1);
Expand All @@ -107,7 +108,7 @@ Proj4js.Proj.cass = {

//code from the PROJ.4 pj_mlfn.c file; this may be useful for other projections
pj_enfn: function(es) {
en = new Array();
var en = new Array();
en[0] = this.C00 - es * (this.C02 + es * (this.C04 + es * (this.C06 + es * this.C08)));
en[1] = es * (this.C22 - es * (this.C04 + es * (this.C06 + es * this.C08)));
var t = es * es;
Expand All @@ -125,10 +126,10 @@ Proj4js.Proj.cass = {
},

pj_inv_mlfn: function(arg, es, en) {
k = 1./(1.-es);
phi = arg;
for (i = Proj4js.common.MAX_ITER; i ; --i) { /* rarely goes over 2 iterations */
s = Math.sin(phi);
var k = 1./(1.-es);
var phi = arg;
for (var i = Proj4js.common.MAX_ITER; i ; --i) { /* rarely goes over 2 iterations */
var s = Math.sin(phi);
t = 1. - es * s * s;
//t = this.pj_mlfn(phi, s, Math.cos(phi), en) - arg;
//phi -= t * (t * Math.sqrt(t)) * k;
Expand Down
2 changes: 1 addition & 1 deletion trunk/lib/projCode/cea.js
Expand Up @@ -49,7 +49,7 @@ Proj4js.Proj.cea = {
var lat=p.y;
/* Forward equations
-----------------*/
dlon = Proj4js.common.adjust_lon(lon -this.long0);
var dlon = Proj4js.common.adjust_lon(lon -this.long0);
var x = this.x0 + this.a * dlon * Math.cos(this.lat_ts);
var y = this.y0 + this.a * Math.sin(lat) / Math.cos(this.lat_ts);
/* Elliptical Forward Transform
Expand Down
6 changes: 3 additions & 3 deletions trunk/lib/projCode/gauss.js
Expand Up @@ -2,8 +2,8 @@
Proj4js.Proj.gauss = {

init : function() {
sphi = Math.sin(this.lat0);
cphi = Math.cos(this.lat0);
var sphi = Math.sin(this.lat0);
var cphi = Math.cos(this.lat0);
cphi *= cphi;
this.rc = Math.sqrt(1.0 - this.es) / (1.0 - this.es * sphi * sphi);
this.C = Math.sqrt(1.0 + this.es * cphi * cphi / (1.0 - this.es));
Expand All @@ -25,7 +25,7 @@ Proj4js.Proj.gauss = {
var DEL_TOL = 1e-14;
var lon = p.x / this.C;
var lat = p.y;
num = Math.pow(Math.tan(0.5 * lat + Proj4js.common.FORTPI)/this.K, 1./this.C);
var num = Math.pow(Math.tan(0.5 * lat + Proj4js.common.FORTPI)/this.K, 1./this.C);
for (var i = Proj4js.common.MAX_ITER; i>0; --i) {
lat = 2.0 * Math.atan(num * Proj4js.common.srat(this.e * Math.sin(p.y), -0.5 * this.e)) - Proj4js.common.HALF_PI;
if (Math.abs(lat - p.y) < DEL_TOL) break;
Expand Down
1 change: 1 addition & 0 deletions trunk/lib/projCode/gnom.js
Expand Up @@ -44,6 +44,7 @@ Proj4js.Proj.gnom = {
var coslon; /* cos of longitude */
var ksp; /* scale factor */
var g;
var x, y;
var lon=p.x;
var lat=p.y;
/* Forward equations
Expand Down
3 changes: 2 additions & 1 deletion trunk/lib/projCode/laea.js
Expand Up @@ -205,7 +205,8 @@ Proj4js.Proj.laea = {
p.y -= this.y0;
var x = p.x/this.a;
var y = p.y/this.a;

var lam, phi;

if (this.sphere) {
var cosz=0.0, rh, sinz=0.0;

Expand Down
20 changes: 9 additions & 11 deletions trunk/lib/projCode/nzmg.js
Expand Up @@ -181,7 +181,7 @@ Proj4js.Proj.nzmg = {
var d_phi_n = 1; // d_phi^0

var d_psi = 0;
for (n = 1; n <= 10; n++) {
for (var n = 1; n <= 10; n++) {
d_phi_n = d_phi_n * d_phi;
d_psi = d_psi + this.A[n] * d_phi_n;
}
Expand All @@ -194,17 +194,15 @@ Proj4js.Proj.nzmg = {
var th_n_re1; var th_n_im1;

var z_re = 0; var z_im = 0;
for (n = 1; n <= 6; n++) {
for (var n = 1; n <= 6; n++) {
th_n_re1 = th_n_re*th_re - th_n_im*th_im; th_n_im1 = th_n_im*th_re + th_n_re*th_im;
th_n_re = th_n_re1; th_n_im = th_n_im1;
z_re = z_re + this.B_re[n]*th_n_re - this.B_im[n]*th_n_im; z_im = z_im + this.B_im[n]*th_n_re + this.B_re[n]*th_n_im;
}

// 4. Calculate easting and northing
x = (z_im * this.a) + this.x0;
y = (z_re * this.a) + this.y0;

p.x = x; p.y = y;
p.x = (z_im * this.a) + this.x0;
p.y = (z_re * this.a) + this.y0;

return p;
},
Expand All @@ -229,7 +227,7 @@ Proj4js.Proj.nzmg = {
var z_n_re1; var z_n_im1;

var th_re = 0; var th_im = 0;
for (n = 1; n <= 6; n++) {
for (var n = 1; n <= 6; n++) {
z_n_re1 = z_n_re*z_re - z_n_im*z_im; z_n_im1 = z_n_im*z_re + z_n_re*z_im;
z_n_re = z_n_re1; z_n_im = z_n_im1;
th_re = th_re + this.C_re[n]*z_n_re - this.C_im[n]*z_n_im; th_im = th_im + this.C_im[n]*z_n_re + this.C_re[n]*z_n_im;
Expand All @@ -239,20 +237,20 @@ Proj4js.Proj.nzmg = {
// 0 iterations gives km accuracy
// 1 iteration gives m accuracy -- good enough for most mapping applications
// 2 iterations bives mm accuracy
for (i = 0; i < this.iterations; i++) {
for (var i = 0; i < this.iterations; i++) {
var th_n_re = th_re; var th_n_im = th_im;
var th_n_re1; var th_n_im1;

var num_re = z_re; var num_im = z_im;
for (n = 2; n <= 6; n++) {
for (var n = 2; n <= 6; n++) {
th_n_re1 = th_n_re*th_re - th_n_im*th_im; th_n_im1 = th_n_im*th_re + th_n_re*th_im;
th_n_re = th_n_re1; th_n_im = th_n_im1;
num_re = num_re + (n-1)*(this.B_re[n]*th_n_re - this.B_im[n]*th_n_im); num_im = num_im + (n-1)*(this.B_im[n]*th_n_re + this.B_re[n]*th_n_im);
}

th_n_re = 1; th_n_im = 0;
var den_re = this.B_re[1]; var den_im = this.B_im[1];
for (n = 2; n <= 6; n++) {
for (var n = 2; n <= 6; n++) {
th_n_re1 = th_n_re*th_re - th_n_im*th_im; th_n_im1 = th_n_im*th_re + th_n_re*th_im;
th_n_re = th_n_re1; th_n_im = th_n_im1;
den_re = den_re + n * (this.B_re[n]*th_n_re - this.B_im[n]*th_n_im); den_im = den_im + n * (this.B_im[n]*th_n_re + this.B_re[n]*th_n_im);
Expand All @@ -268,7 +266,7 @@ Proj4js.Proj.nzmg = {
var d_psi_n = 1; // d_psi^0

var d_phi = 0;
for (n = 1; n <= 9; n++) {
for (var n = 1; n <= 9; n++) {
d_psi_n = d_psi_n * d_psi;
d_phi = d_phi + this.D[n] * d_psi_n;
}
Expand Down
6 changes: 3 additions & 3 deletions trunk/lib/projCode/omerc.js
Expand Up @@ -122,7 +122,7 @@ Proj4js.Proj.omerc = {
} else {
this.con = Math.abs(this.lat1);
}
if ((this.con <= Proj4js.common.EPSLN) || (Math.abs(this.con - HALF_PI) <= Proj4js.common.EPSLN)) {
if ((this.con <= Proj4js.common.EPSLN) || (Math.abs(this.con - Proj4js.common.HALF_PI) <= Proj4js.common.EPSLN)) {
Proj4js.reportError("omercInitDataError");
//return(202);
} else {
Expand Down Expand Up @@ -215,8 +215,8 @@ Proj4js.Proj.omerc = {
var con, n, ml; /* cone constant, small m */
var vs,us,q,s,ts1;
var vl,ul,bs;
var dlon;
var flag;
var lon, lat;
var flag;

/* Inverse equations
-----------------*/
Expand Down
4 changes: 2 additions & 2 deletions trunk/lib/projCode/poly.js
Expand Up @@ -2,7 +2,7 @@
Polyconic projection.
------------------------------------------------------------*/
function phi4z (eccent,e0,e1,e2,e3,a,b,c,phi) {
var sinphi, sin2ph, tanph, ml, mlp, con1, con2, con3, dphi, i;
var sinphi, sin2ph, tanphi, ml, mlp, con1, con2, con3, dphi, i;

phi = a;
for (i = 1; i <= 15; i++) {
Expand Down Expand Up @@ -72,7 +72,7 @@ Proj4js.Proj.poly = {
----------------------------------*/
init: function() {
var temp; /* temporary variable */
if (this.lat0=0) this.lat0=90;//this.lat0 ca
if (this.lat0 == 0) this.lat0 = 90;//this.lat0 ca

/* Place parameters in static storage for common use
-------------------------------------------------*/
Expand Down
11 changes: 6 additions & 5 deletions trunk/lib/projCode/stere.js
Expand Up @@ -118,19 +118,20 @@ Proj4js.Proj.stere = {
coslam = Math.cos(lon);
sinlam = Math.sin(lon);
sinphi = Math.sin(lat);
var sinX, cosX;
if (this.mode == this.OBLIQ || this.mode == this.EQUIT) {
X = 2. * Math.atan(this.ssfn_(lat, sinphi, this.e));
sinX = Math.sin(X - Proj4js.common.HALF_PI);
cosX = Math.cos(X);
var Xt = 2. * Math.atan(this.ssfn_(lat, sinphi, this.e));
sinX = Math.sin(Xt - Proj4js.common.HALF_PI);
cosX = Math.cos(Xt);
}
switch (this.mode) {
case this.OBLIQ:
A = this.akm1 / (this.cosX1 * (1. + this.sinX1 * sinX + this.cosX1 * cosX * coslam));
var A = this.akm1 / (this.cosX1 * (1. + this.sinX1 * sinX + this.cosX1 * cosX * coslam));
y = A * (this.cosX1 * sinX - this.sinX1 * cosX * coslam);
x = A * cosX;
break;
case this.EQUIT:
A = 2. * this.akm1 / (1. + cosX * coslam);
var A = 2. * this.akm1 / (1. + cosX * coslam);
y = A * sinX;
x = A * cosX;
break;
Expand Down
5 changes: 3 additions & 2 deletions trunk/lib/projCode/sterea.js
Expand Up @@ -15,6 +15,7 @@ Proj4js.Proj.sterea = {
},

forward : function(p) {
var sinc, cosc, cosl, k;
p.x = Proj4js.common.adjust_lon(p.x-this.long0); /* adjust del longitude */
Proj4js.Proj['gauss'].forward.apply(this, [p]);
sinc = Math.sin(p.y);
Expand All @@ -29,14 +30,14 @@ Proj4js.Proj.sterea = {
},

inverse : function(p) {
var lon,lat;
var sinc, cosc, lon, lat, rho;
p.x = (p.x - this.x0) / this.a; /* descale and de-offset */
p.y = (p.y - this.y0) / this.a;

p.x /= this.k0;
p.y /= this.k0;
if ( (rho = Math.sqrt(p.x*p.x + p.y*p.y)) ) {
c = 2.0 * Math.atan2(rho, this.R2);
var c = 2.0 * Math.atan2(rho, this.R2);
sinc = Math.sin(c);
cosc = Math.cos(c);
lat = Math.asin(cosc * this.sinc0 + p.y * sinc * this.cosc0 / rho);
Expand Down
2 changes: 1 addition & 1 deletion trunk/lib/projCode/vandg.js
Expand Up @@ -87,7 +87,7 @@ Proj4js.Proj.vandg = {
/* Van Der Grinten inverse equations--mapping x,y to lat/long
---------------------------------------------------------*/
inverse: function(p) {
var dlon;
var lon, lat;
var xx,yy,xys,c1,c2,c3;
var al,asq;
var a1;
Expand Down

0 comments on commit 3de0415

Please sign in to comment.