Commit bc106798 authored by ahocevar's avatar ahocevar
Browse files

Merge pull request #12 from calvinmetcalf/jshint

Jshint
parents 3ebcde3c e130dc5c
Loading
Loading
Loading
Loading
+23 −9
Original line number Diff line number Diff line
@@ -28,7 +28,8 @@ module.exports = function(grunt) {
					base: '.'
				}
			}
		},mocha_phantomjs: {
		},
		mocha_phantomjs: {
			all: {
				options: {
					urls: [//my ide requries process.env.IP and PORT
@@ -37,8 +38,21 @@ module.exports = function(grunt) {
					]
				}
			}
		},
		jshint: {
			options:{
				curly: true,
				eqeqeq: true,
				latedef: true,
				//undef: true,
				unused: true,
				trailing:true,
				indent:4
			},
			all: [ './src/Proj4.js','./src/Proj.js','./src/defs.js','./src/common.js','./src/datum.js','./src/Point.js','./src/constants.js','./src/projCode/*.js','./src/defs/*.js','./src/util/MGRS.js']
		}
	});
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-connect');
@@ -46,5 +60,5 @@ module.exports = function(grunt) {
	grunt.registerTask('full', ['concat:full','uglify:full']);
	grunt.registerTask('noDefs', ['concat:noDefs','uglify:noDefs']);
	grunt.registerTask('test', ['connect', 'mocha_phantomjs']);
	grunt.registerTask('default', ['full','noDefs','test']);
	grunt.registerTask('default', ['full','noDefs','jshint','test']);
}
+33 −32
Original line number Diff line number Diff line
@@ -97,15 +97,15 @@ proj4.Proj = proj4.Class({
      }else{
      
      // DGR 2008-08-03 : support urn and url
      if (srsCode.indexOf('urn:') == 0) {
      if (srsCode.indexOf('urn:') === 0) {
          //urn:ORIGINATOR:def:crs:CODESPACE:VERSION:ID
          var urn = srsCode.split(':');
          if ((urn[1] == 'ogc' || urn[1] =='x-ogc') &&
              (urn[2] =='def') &&
              (urn[3] =='crs')) {
          if ((urn[1] === 'ogc' || urn[1] =='x-ogc') &&
              (urn[2] ==='def') &&
              (urn[3] ==='crs')) {
              srsCode = urn[4]+':'+urn[urn.length-1];
          }
      } else if (srsCode.indexOf('http://') == 0) {
      } else if (srsCode.indexOf('http://') === 0) {
          //url#ID
          var url = srsCode.split('#');
          if (url[0].match(/epsg.org/)) {
@@ -124,17 +124,17 @@ proj4.Proj = proj4.Class({
          }
      }
      this.srsCode = srsCode.toUpperCase();
      if (this.srsCode.indexOf("EPSG") == 0) {
      if (this.srsCode.indexOf("EPSG") === 0) {
          this.srsCode = this.srsCode;
          this.srsAuth = 'epsg';
          this.srsProjNumber = this.srsCode.substring(5);
      // DGR 2007-11-20 : authority IGNF
      } else if (this.srsCode.indexOf("IGNF") == 0) {
      } else if (this.srsCode.indexOf("IGNF") === 0) {
          this.srsCode = this.srsCode;
          this.srsAuth = 'IGNF';
          this.srsProjNumber = this.srsCode.substring(5);
      // DGR 2008-06-19 : pseudo-authority CRS for WMS
      } else if (this.srsCode.indexOf("CRS") == 0) {
      } else if (this.srsCode.indexOf("CRS") === 0) {
          this.srsCode = this.srsCode;
          this.srsAuth = 'CRS';
          this.srsProjNumber = this.srsCode.substring(4);
@@ -181,7 +181,7 @@ proj4.Proj = proj4.Class({
    var wktContent = wktMatch[2];
    var wktTemp = wktContent.split(",");
    var wktName;
    if (wktObject.toUpperCase() == "TOWGS84") {
    if (wktObject.toUpperCase() === "TOWGS84") {
      wktName = wktObject;  //no name supplied for the TOWGS84 array
    } else {
      wktName = wktTemp.shift();
@@ -197,14 +197,14 @@ proj4.Proj = proj4.Class({
    }
    */
    
    var wktArray = new Array();
    var wktArray = [];
    var bkCount = 0;
    var obj = "";
    for (var i=0; i<wktTemp.length; ++i) {
      var token = wktTemp[i];
      for (var j=0; j<token.length; ++j) {
        if (token.charAt(j) == "[") ++bkCount;
        if (token.charAt(j) == "]") --bkCount;
      for (var j2=0; j2<token.length; ++j2) {
        if (token.charAt(j2) === "[") ++bkCount;
        if (token.charAt(j2) === "]") --bkCount;
      }
      obj += token;
      if (bkCount === 0) {
@@ -215,8 +215,8 @@ proj4.Proj = proj4.Class({
      }
    }
    
    //do something based on the type of the wktObject being parsed
    //add in variations in the spelling as required
    //this is grotesque -cwm
    var name,value;
    switch (wktObject) {
      case 'LOCAL_CS':
        this.projName = 'identity';
@@ -255,8 +255,8 @@ proj4.Proj = proj4.Class({
        this.unitsPerMeter = parseFloat(wktArray.shift());
        break;
      case 'PARAMETER':
        var name = wktName.toLowerCase();
        var value = parseFloat(wktArray.shift());
        name = wktName.toLowerCase();
        value = parseFloat(wktArray.shift());
        //there may be many variations on the wktName values, add in case
        //statements as required
        switch (name) {
@@ -286,8 +286,8 @@ proj4.Proj = proj4.Class({
        break;
      //DGR 2010-11-12: AXIS
      case 'AXIS':
        var name= wktName.toLowerCase();
        var value= wktArray.shift();
        name= wktName.toLowerCase();
        value= wktArray.shift();
        switch (value) {
          case 'EAST' : value= 'e'; break;
          case 'WEST' : value= 'w'; break;
@@ -295,7 +295,7 @@ proj4.Proj = proj4.Class({
          case 'SOUTH': value= 's'; break;
          case 'UP'   : value= 'u'; break;
          case 'DOWN' : value= 'd'; break;
          case 'OTHER':
          //case 'OTHER': 
          default     : value= ' '; break;//FIXME
        }
        if (!this.axis) { this.axis= "enu"; }
@@ -305,13 +305,14 @@ proj4.Proj = proj4.Class({
          case 'z': this.axis= this.axis.substr(0,2) + value                        ; break;
          default : break;
        }
        break;
      case 'MORE_HERE':
        break;
      default:
        break;
    }
    for (var i=0; i<wktArray.length; ++i) {
      this.parseWKT(wktArray[i]);
    for (var j=0; j<wktArray.length; ++j) {
      this.parseWKT(wktArray[j]);
    }
 },

@@ -389,7 +390,7 @@ proj4.Proj = proj4.Class({
              // DGR 2010-11-12: axis
              case "axis":   paramVal = paramVal.replace(/\s/gi,"");
                             var legalAxis= "ewnsud";
                             if (paramVal.length==3 &&
                             if (paramVal.length===3 &&
                                 legalAxis.indexOf(paramVal.substr(0,1))!=-1 &&
                                 legalAxis.indexOf(paramVal.substr(1,1))!=-1 &&
                                 legalAxis.indexOf(paramVal.substr(2,1))!=-1) {
@@ -412,7 +413,7 @@ proj4.Proj = proj4.Class({
 */
  deriveConstants: function() {
      // DGR 2011-03-20 : nagrids -> nadgrids
      if (this.nadgrids && this.nadgrids.length==0) {
      if (this.nadgrids && this.nadgrids.length===0) {
          this.nadgrids= null;
      }
      if (this.nadgrids) {
@@ -422,12 +423,12 @@ proj4.Proj = proj4.Class({
          for (var i= 0; i<l; i++) {
            g= this.grids[i];
            var fg= g.split("@");
            if (fg[fg.length-1]=="") {
            if (fg[fg.length-1]==="") {
              proj4.reportError("nadgrids syntax error '"+this.nadgrids+"' : empty grid found");
              continue;
            }
            this.grids[i]= {
              mandatory: fg.length==1,//@=> optional grid (no error if not found)
              mandatory: fg.length===1,//@=> optional grid (no error if not found)
              name:fg[fg.length-1],
              grid: proj4.grids[fg[fg.length-1]]//FIXME: grids loading ...
            };
@@ -439,7 +440,7 @@ proj4.Proj = proj4.Class({
        // DGR, 2011-03-20: grids is an array of objects that hold
        // the loaded grids, its name and the mandatory informations of it.
      }
      if (this.datumCode && this.datumCode != 'none') {
      if (this.datumCode && this.datumCode !== 'none') {
        var datumDef = proj4.Datum[this.datumCode];
        if (datumDef) {
          this.datum_params = datumDef.towgs84 ? datumDef.towgs84.split(',') : null;
@@ -448,7 +449,7 @@ proj4.Proj = proj4.Class({
        }
      }
      if (!this.a) {    // do we have an ellipsoid?
          var ellipse = proj4.Ellipsoid[this.ellps] ? proj4.Ellipsoid[this.ellps] : proj4.Ellipsoid['WGS84'];
          var ellipse = proj4.Ellipsoid[this.ellps] ? proj4.Ellipsoid[this.ellps] : proj4.Ellipsoid.WGS84;
          proj4.extend(this, ellipse);
      }
      if (this.rf && !this.b) this.b = (1.0 - 1.0/this.rf) * this.a;
@@ -461,10 +462,10 @@ proj4.Proj = proj4.Class({
      this.es = (this.a2-this.b2)/this.a2;  // e ^ 2
      this.e = Math.sqrt(this.es);        // eccentricity
      if (this.R_A) {
        this.a *= 1. - this.es * (proj4.common.SIXTH + this.es * (proj4.common.RA4 + this.es * proj4.common.RA6));
        this.a *= 1 - this.es * (proj4.common.SIXTH + this.es * (proj4.common.RA4 + this.es * proj4.common.RA6));
        this.a2 = this.a * this.a;
        this.b2 = this.b * this.b;
        this.es = 0.;
        this.es = 0;
      }
      this.ep2=(this.a2-this.b2)/this.b2; // used in geocentric
      if (!this.k0) this.k0 = 1.0;    //default value
+38 −74
Original line number Diff line number Diff line
@@ -45,13 +45,13 @@ $Id: Proj.js 2956 2007-07-09 12:17:52Z steven $
/**
 * Global namespace object for proj4 library
 */
var proj4 = {
var proj4 = {};

    /**
     * Property: defaultDatum
     * The datum to use when no others a specified
     */
    defaultDatum: 'WGS84',                  //default datum
proj4.defaultDatum = 'WGS84';                  //default datum

    /** 
    * Method: transform(source, dest, point)
@@ -64,7 +64,7 @@ var proj4 = {
    * point - {Object} point to transform, may be geodetic (long, lat) or
    *     projected Cartesian (x,y), but should always have x,y properties.
    */
    transform: function(source, dest, point) {
proj4.transform = function(source, dest, point) {
        if (!source.readyToUse) {
            this.reportError("proj4 initialization for:"+source.srsCode+" not yet complete");
            return point;
@@ -76,20 +76,20 @@ var proj4 = {
        
        // Workaround for datum shifts towgs84, if either source or destination projection is not wgs84
        if (source.datum && dest.datum && (
            ((source.datum.datum_type == proj4.common.PJD_3PARAM || source.datum.datum_type == proj4.common.PJD_7PARAM) && dest.datumCode != "WGS84") ||
            ((dest.datum.datum_type == proj4.common.PJD_3PARAM || dest.datum.datum_type == proj4.common.PJD_7PARAM) && source.datumCode != "WGS84"))) {
            ((source.datum.datum_type === proj4.common.PJD_3PARAM || source.datum.datum_type === proj4.common.PJD_7PARAM) && dest.datumCode !== "WGS84") ||
            ((dest.datum.datum_type === proj4.common.PJD_3PARAM || dest.datum.datum_type === proj4.common.PJD_7PARAM) && source.datumCode !== "WGS84"))) {
            var wgs84 = proj4.WGS84;
            this.transform(source, wgs84, point);
            source = wgs84;
        }

        // DGR, 2010/11/12
        if (source.axis!="enu") {
        if (source.axis!=="enu") {
            this.adjust_axis(source,false,point);
        }

        // Transform source points to long/lat, if they aren't already.
        if (source.projName=="longlat") {
        if (source.projName==="longlat") {
            point.x *= proj4.common.D2R;  // convert degrees to radians
            point.y *= proj4.common.D2R;
        } else {
@@ -113,7 +113,7 @@ var proj4 = {
            point.x -= dest.from_greenwich;
        }

        if (dest.projName=="longlat") {
        if (dest.projName==="longlat") {
            // convert radians to decimal degrees
            point.x *= proj4.common.R2D;
            point.y *= proj4.common.R2D;
@@ -126,19 +126,19 @@ var proj4 = {
        }

        // DGR, 2010/11/12
        if (dest.axis!="enu") {
        if (dest.axis!=="enu") {
            this.adjust_axis(dest,true,point);
        }

        return point;
    }, // transform()
    }; // transform()

    /** datum_transform()
      source coordinate system definition,
      destination coordinate system definition,
      point to transform in geodetic coordinates (long, lat, height)
    */
    datum_transform : function( source, dest, point ) {
proj4.datum_transform = function( source, dest, point ) {

      // Short cut if the datums are identical.
      if( source.compare_datums( dest ) ) {
@@ -148,8 +148,7 @@ var proj4 = {
      }

      // Explicitly skip datum transform by setting 'datum=none' as parameter for either source or dest
      if( source.datum_type == proj4.common.PJD_NODATUM
          || dest.datum_type == proj4.common.PJD_NODATUM) {
      if( source.datum_type === proj4.common.PJD_NODATUM || dest.datum_type === proj4.common.PJD_NODATUM) {
          return point;
      }

@@ -162,9 +161,9 @@ var proj4 = {

      var fallback= source.datum_type;
      // If this datum requires grid shifts, then apply it to geodetic coordinates.
      if( fallback == proj4.common.PJD_GRIDSHIFT )
      if( fallback === proj4.common.PJD_GRIDSHIFT )
      {
          if (this.apply_gridshift( source, 0, point )==0) {
          if (this.apply_gridshift( source, 0, point )===0) {
            source.a = proj4.common.SRS_WGS84_SEMIMAJOR;
            source.es = proj4.common.SRS_WGS84_ESQUARED;
          } else {
@@ -179,7 +178,7 @@ var proj4 = {
              for (var i= 0, l= source.datum_params.length; i<l; i++) {
                wp*= source.datum_params[i];
              }
              if (wp==0.0) {
              if (wp===0.0) {
                source.a = src_a;
                source.es = source.es;
                return point;
@@ -191,18 +190,12 @@ var proj4 = {
          }
      }

      if( dest.datum_type == proj4.common.PJD_GRIDSHIFT )
      {
      if( dest.datum_type === proj4.common.PJD_GRIDSHIFT ){
          dest.a = proj4.common.SRS_WGS84_SEMIMAJOR;
          dest.es = proj4.common.SRS_WGS84_ESQUARED;
      }
      // Do we need to go through geocentric coordinates?
      if (source.es != dest.es || source.a != dest.a
          || fallback == proj4.common.PJD_3PARAM
          || fallback == proj4.common.PJD_7PARAM
          || dest.datum_type == proj4.common.PJD_3PARAM
          || dest.datum_type == proj4.common.PJD_7PARAM)
      {
      if (source.es !== dest.es || source.a !== dest.a || fallback === proj4.common.PJD_3PARAM || fallback === proj4.common.PJD_7PARAM || dest.datum_type === proj4.common.PJD_3PARAM || dest.datum_type === proj4.common.PJD_7PARAM) {
      //DGR: 2012-07-29 : add nadgrids support (end)

        // Convert to geocentric coordinates.
@@ -210,12 +203,12 @@ var proj4 = {
        // CHECK_RETURN;

        // Convert between datums
        if( source.datum_type == proj4.common.PJD_3PARAM || source.datum_type == proj4.common.PJD_7PARAM ) {
        if( source.datum_type === proj4.common.PJD_3PARAM || source.datum_type === proj4.common.PJD_7PARAM ) {
          source.geocentric_to_wgs84(point);
          // CHECK_RETURN;
        }

        if( dest.datum_type == proj4.common.PJD_3PARAM || dest.datum_type == proj4.common.PJD_7PARAM ) {
        if( dest.datum_type === proj4.common.PJD_3PARAM || dest.datum_type === proj4.common.PJD_7PARAM ) {
          dest.geocentric_from_wgs84(point);
          // CHECK_RETURN;
        }
@@ -226,8 +219,7 @@ var proj4 = {
      }

      // Apply grid shift to destination if required
      if( dest.datum_type == proj4.common.PJD_GRIDSHIFT )
      {
      if( dest.datum_type === proj4.common.PJD_GRIDSHIFT ) {
          this.apply_gridshift( dest, 1, point);
          // CHECK_RETURN;
      }
@@ -238,14 +230,14 @@ var proj4 = {
      dest.es = dst_es;

      return point;
    }, // cs_datum_transform
    }; // cs_datum_transform

    /**
     * This is the real workhorse, given a gridlist
     * DGR: 2012-07-29 addition based on proj4 trunk
     */
    apply_gridshift : function(srs,inverse,point) {
        if (srs.grids==null || srs.grids.length==0) {
proj4.apply_gridshift = function(srs,inverse,point) {
        if (srs.grids===null || srs.grids.length===0) {
            return -38;
        }
        var input= {"x":point.x, "y":point.y};
@@ -256,7 +248,7 @@ var proj4 = {
            var gi= srs.grids[i];
            onlyMandatoryGrids= gi.mandatory;
            var ct= gi.grid;
            if (ct==null) {
            if (ct===null) {
                if (gi.mandatory) {
                    this.reportError("unable to find '"+gi.name+"' grid.");
                    return -48;
@@ -265,9 +257,7 @@ var proj4 = {
            } 
            /* skip tables that don't match our point at all.  */
            var epsilon= (Math.abs(ct.del[1])+Math.abs(ct.del[0]))/10000.0;
            if( ct.ll[1]-epsilon>input.y || ct.ll[0]-epsilon>input.x ||
                ct.ll[1]+(ct.lim[1]-1)*ct.del[1]+epsilon<input.y ||
                ct.ll[0]+(ct.lim[0]-1)*ct.del[0]+epsilon<input.x ) {
            if( ct.ll[1]-epsilon>input.y || ct.ll[0]-epsilon>input.x || ct.ll[1]+(ct.lim[1]-1)*ct.del[1]+epsilon<input.y || ct.ll[0]+(ct.lim[0]-1)*ct.del[0]+epsilon<input.x ) {
                continue;
            }
            /* If we have child nodes, check to see if any of them apply. */
@@ -276,7 +266,7 @@ var proj4 = {
            /* load the grid shift info if we don't have it. */
            /* TODO : proj4.grids pre-loaded (as they can be huge ...) */
            /* skip numerical computing error when "null" grid (identity grid): */
            if (gi.name=="null") {
            if (gi.name==="null") {
                output.x= input.x;
                output.y= input.y;
            } else {
@@ -298,7 +288,7 @@ var proj4 = {
        point.x= output.x;
        point.y= output.y;
        return 0;
    },
    };

    /**
     * Function: adjust_axis
@@ -309,13 +299,13 @@ var proj4 = {
     * denorm {Boolean} when false, normalize
     * point {Object} the coordinates to adjust
     */
    adjust_axis: function(crs, denorm, point) {
proj4.adjust_axis = function(crs, denorm, point) {
        var xin= point.x, yin= point.y, zin= point.z || 0.0;
        var v, t;
        for (var i= 0; i<3; i++) {
            if (denorm && i==2 && point.z===undefined) { continue; }
                 if (i==0) { v= xin; t= 'x'; }
            else if (i==1) { v= yin; t= 'y'; }
            if (denorm && i===2 && point.z===undefined) { continue; }
                 if (i===0) { v= xin; t= 'x'; }
            else if (i===1) { v= yin; t= 'y'; }
            else           { v= zin; t= 'z'; }
            switch(crs.axis[i]) {
            case 'e':
@@ -342,16 +332,16 @@ var proj4 = {
            }
        }
        return point;
    },
    };

    /**
     * Function: reportError
     * An internal method to report errors back to user. 
     * Override this in applications to report error messages or throw exceptions.
     */
    reportError: function(msg) {
proj4.reportError = function(msg) {
      //console.log(msg);
    },
    };

/**
 *
@@ -376,7 +366,7 @@ var proj4 = {
 * Returns:
 * {Object} The destination object.
 */
    extend: function(destination, source) {
proj4.extend = function(destination, source) {
      destination = destination || {};
      if(source) {
          for(var property in source) {
@@ -387,7 +377,7 @@ var proj4 = {
          }
      }
      return destination;
    },
    };

/**
 * Constructor: Class
@@ -395,7 +385,7 @@ var proj4 = {
 *     multiple inheritance. 
 *  
 */
    Class: function() {
proj4.Class = function() {
      var Class = function() {
          this.initialize.apply(this, arguments);
      };
@@ -415,30 +405,4 @@ var proj4 = {
      Class.prototype = extended;
      
      return Class;
    },

    /**
     * Function: bind
     * Bind a function to an object.  Method to easily create closures with
     *     'this' altered.
     * 
     * Parameters:
     * func - {Function} Input function.
     * object - {Object} The object to bind to the input function (as this).
     * 
     * Returns:
     * {Function} A closure with 'this' set to the passed in object.
     */
    bind: function(func, object) {
        // create a reference to all arguments past the second one
        var args = Array.prototype.slice.apply(arguments, [2]);
        return function() {
            // Push on any additional arguments from the actual function call.
            // These will come after those sent to the bind call.
            var newArgs = args.concat(
                Array.prototype.slice.apply(arguments, [0])
            );
            return func.apply(object, newArgs);
        };
    }
    };
+28 −28
Original line number Diff line number Diff line
@@ -23,11 +23,11 @@ proj4.common = {
  SRS_WGS84_ESQUARED : 0.006694379990141316, //DGR: 2012-07-29

  // ellipoid pj_set_ell.c
  SIXTH : .1666666666666666667, /* 1/6 */
  RA4   : .04722222222222222222, /* 17/360 */
  RA6   : .02215608465608465608, /* 67/3024 */
  RV4   : .06944444444444444444, /* 5/72 */
  RV6   : .04243827160493827160, /* 55/1296 */
  SIXTH : 0.1666666666666666667, /* 1/6 */
  RA4   : 0.04722222222222222222, /* 17/360 */
  RA6   : 0.02215608465608465608, /* 67/3024 */
  RV4   : 0.06944444444444444444, /* 5/72 */
  RV6   : 0.04243827160493827160, /* 55/1296 */

// Function to compute the constant small m which is the radius of
//   a parallel of latitude, phi, divided by the semimajor axis.
@@ -43,23 +43,23 @@ proj4.common = {
// -----------------------------------------------------------------
  tsfnz : function(eccent, phi, sinphi) {
    var con = eccent * sinphi;
    var com = .5 * eccent;
    var com = 0.5 * eccent;
    con = Math.pow(((1.0 - con) / (1.0 + con)), com);
    return (Math.tan(.5 * (this.HALF_PI - phi))/con);
    return (Math.tan(0.5 * (this.HALF_PI - phi))/con);
  },

// Function to compute the latitude angle, phi2, for the inverse of the
//   Lambert Conformal Conic and Polar Stereographic projections.
// ----------------------------------------------------------------
  phi2z : function(eccent, ts) {
    var eccnth = .5 * eccent;
    var eccnth = 0.5 * eccent;
    var con, dphi;
    var phi = this.HALF_PI - 2 * Math.atan(ts);
    for (var i = 0; i <= 15; i++) {
      con = eccent * Math.sin(phi);
      dphi = this.HALF_PI - 2 * Math.atan(ts *(Math.pow(((1.0 - con)/(1.0 + con)),eccnth))) - phi;
      phi += dphi;
      if (Math.abs(dphi) <= .0000000001) return phi;
      if (Math.abs(dphi) <= 0.0000000001) return phi;
    }
    alert("phi2z has NoConvergence");
    return (-9999);
@@ -72,7 +72,7 @@ proj4.common = {
    var con;
    if (eccent > 1.0e-7) {
      con = eccent * sinphi;
      return (( 1.0- eccent * eccent) * (sinphi /(1.0 - con * con) - (.5/eccent)*Math.log((1.0 - con)/(1.0 + con))));
      return (( 1.0- eccent * eccent) * (sinphi /(1.0 - con * con) - (0.5/eccent)*Math.log((1.0 - con)/(1.0 + con))));
    } else {
      return(2.0 * sinphi);
    }
@@ -101,7 +101,7 @@ proj4.common = {
      con = eccent*sin_phi;
      dphi=Math.pow(1.0-con*con,2.0)/(2.0*cos_phi)*(q/(1-eccent*eccent)-sin_phi/(1.0-con*con)+0.5/eccent*Math.log((1.0-con)/(1.0+con)));
      phi+=dphi;
      if (Math.abs(dphi) <= .0000000001) {
      if (Math.abs(dphi) <= 0.0000000001) {
        return phi;
      }
    }
@@ -133,7 +133,7 @@ proj4.common = {
    for (var i=0;i<15;i++){
      dphi=(ml-(e0*phi-e1*Math.sin(2.0*phi)+e2*Math.sin(4.0*phi)-e3*Math.sin(6.0*phi)))/(e0-2.0*e1*Math.cos(2.0*phi)+4.0*e2*Math.cos(4.0*phi)-6.0*e3*Math.cos(6.0*phi));
      phi+=dphi;
      if (Math.abs(dphi) <= .0000000001) {
      if (Math.abs(dphi) <= 0.0000000001) {
        return phi;
      }
    }
@@ -239,7 +239,7 @@ proj4.common = {
  
  //code from the PROJ.4 pj_mlfn.c file;  this may be useful for other projections
  pj_enfn: function(es) {
    var en = new Array();
    var en = [];
    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;
@@ -257,11 +257,11 @@ proj4.common = {
  },
  
  pj_inv_mlfn: function(arg, es, en) {
    var k = 1./(1.-es);
    var k = 1.0/(1.0-es);
    var phi = arg;
    for (var i = proj4.common.MAX_ITER; i ; --i) { /* rarely goes over 2 iterations */
      var s = Math.sin(phi);
      var t = 1. - es * s * s;
      var t = 1.0 - es * s * s;
      //t = this.pj_mlfn(phi, s, Math.cos(phi), en) - arg;
      //phi -= t * (t * Math.sqrt(t)) * k;
      t = (this.pj_mlfn(phi, s, Math.cos(phi), en) - arg) * (t * Math.sqrt(t)) * k;
@@ -383,16 +383,16 @@ proj4.common = {
**	Inverse determines phi to EPS (1e-11) radians, about 1e-6 seconds.
*/
  C00: 1.0,
  C02: .25,
  C04: .046875,
  C06: .01953125,
  C08: .01068115234375,
  C22: .75,
  C44: .46875,
  C46: .01302083333333333333,
  C48: .00712076822916666666,
  C66: .36458333333333333333,
  C68: .00569661458333333333,
  C88: .3076171875  
  C02: 0.25,
  C04: 0.046875,
  C06: 0.01953125,
  C08: 0.01068115234375,
  C22: 0.75,
  C44: 0.46875,
  C46: 0.01302083333333333333,
  C48: 0.00712076822916666666,
  C66: 0.36458333333333333333,
  C68: 0.00569661458333333333,
  C88: 0.3076171875  

};
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ proj4.Datum = {
};

proj4.WGS84 = new proj4.Proj('WGS84');
proj4.Datum['OSB36'] = proj4.Datum['OSGB36']; //as returned from spatialreference.org
proj4.Datum.OSB36 = proj4.Datum.OSGB36; //as returned from spatialreference.org

//lookup table to go from the projection name in WKT to the proj4 projection name
//build this out as required
Loading