Commit 50e5e5e0 authored by Calvin Metcalf's avatar Calvin Metcalf
Browse files

sinu done

parent f12d43e6
Loading
Loading
Loading
Loading
+22 −20
Original line number Diff line number Diff line
@@ -37,11 +37,11 @@ proj4.Proj.sinu = {
      this.en = proj4.common.pj_enfn(this.es);
    }
    else {
      this.n = 1.;
      this.m = 0.;
      this.n = 1;
      this.m = 0;
      this.es = 0;
      this.C_y = Math.sqrt((this.m + 1.) / this.n);
      this.C_x = this.C_y / (this.m + 1.);
      this.C_y = Math.sqrt((this.m + 1) / this.n);
      this.C_x = this.C_y / (this.m + 1);
    }

  },
@@ -49,7 +49,7 @@ proj4.Proj.sinu = {
  /* Sinusoidal forward equations--mapping lat,long to x,y
  -----------------------------------------------------*/
  forward: function(p) {
    var x, y, delta_lon;
    var x, y;
    var lon = p.x;
    var lat = p.y;
    /* Forward equations
@@ -58,14 +58,16 @@ proj4.Proj.sinu = {

    if (this.sphere) {
      if (!this.m) {
        lat = this.n != 1. ? Math.asin(this.n * Math.sin(lat)) : lat;
        lat = this.n !== 1 ? Math.asin(this.n * Math.sin(lat)) : lat;
      }
      else {
        var k = this.n * Math.sin(lat);
        for (var i = proj4.common.MAX_ITER; i; --i) {
          var V = (this.m * lat + Math.sin(lat) - k) / (this.m + Math.cos(lat));
          lat -= V;
          if (Math.abs(V) < proj4.common.EPSLN) break;
          if (Math.abs(V) < proj4.common.EPSLN){
            break;
          }
        }
      }
      x = this.a * this.C_x * lon * (this.m + Math.cos(lat));
@@ -77,7 +79,7 @@ proj4.Proj.sinu = {
      var s = Math.sin(lat);
      var c = Math.cos(lat);
      y = this.a * proj4.common.pj_mlfn(lat, s, c, this.en);
      x = this.a * lon * c / Math.sqrt(1. - this.es * s * s);
      x = this.a * lon * c / Math.sqrt(1 - this.es * s * s);
    }

    p.x = x;
@@ -97,7 +99,7 @@ proj4.Proj.sinu = {
    if (this.sphere) {

      p.y /= this.C_y;
      lat = this.m ? Math.asin((this.m * p.y + Math.sin(p.y)) / this.n) : (this.n != 1. ? Math.asin(Math.sin(p.y) / this.n) : p.y);
      lat = this.m ? Math.asin((this.m * p.y + Math.sin(p.y)) / this.n) : (this.n !== 1 ? Math.asin(Math.sin(p.y) / this.n) : p.y);
      lon = p.x / (this.C_x * (this.m + Math.cos(p.y)));

    }
@@ -106,7 +108,7 @@ proj4.Proj.sinu = {
      var s = Math.abs(lat);
      if (s < proj4.common.HALF_PI) {
        s = Math.sin(lat);
        temp = this.long0 + p.x * Math.sqrt(1. - this.es * s * s) / (this.a * Math.cos(lat));
        temp = this.long0 + p.x * Math.sqrt(1 - this.es * s * s) / (this.a * Math.cos(lat));
        //temp = this.long0 + p.x / (this.a * Math.cos(lat));
        lon = proj4.common.adjust_lon(temp);
      }