{"size": 2506, "ext": "js", "max_stars_repo_path": "src/projections/TransformedLambertAzimuthalTransverse.js", "max_stars_repo_name": "nagaranudit/map", "max_stars_repo_stars_event_min_datetime": "2018-11-14T08:31:28.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-25T03:00:45.000Z", "max_issues_repo_path": "src/projections/TransformedLambertAzimuthalTransverse.js", "max_issues_repo_name": "nagaranudit/map", "max_issues_repo_issues_event_min_datetime": "2020-02-05T05:29:12.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-05T05:29:18.000Z", "max_forks_repo_path": "src/projections/TransformedLambertAzimuthalTransverse.js", "max_forks_repo_name": "nagaranudit/map", "max_forks_repo_forks_event_min_datetime": "2019-03-16T02:40:55.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-25T11:44:24.000Z"}
{"max_stars_count": 8, "max_issues_count": 3, "max_forks_count": 10, "avg_line_length": 27.5384615385, "max_line_length": 83, "alphanum_fraction": 0.5363128492}
/*globals GraticuleOutline*/
function TransformedLambertAzimuthalTransverse() {"use strict";
    var lat0 = 0,
	m, n, CA, CB,
	 
    // scale factor along central meridian
    k0 = 1;

    this.toString = function() {
        return 'Transformed Lambert Azimuthal Transverse';
    };

    this.isEqualArea = function() {
        return true;
    };

    this.initialize = function(conf, w) {
        lat0 = 0; // conf.lat0;

		var lam1, phi1, p,  k, d, pCyl;
		
		lam1 = w * Math.PI;
		phi1 = w * Math.PI / 2;

		// convert standard parallel to aspect ratio p
		pCyl = Math.PI * Math.cos(lat0) * Math.cos(lat0);
		p = pCyl + (1.5 - pCyl) * w;
    
        lam1 = Math.max(lam1, 0.0000001);
        phi1 = Math.max(phi1, 0.0000001);

        m = Math.sin(phi1);
        n = lam1 / Math.PI;
        k = Math.sqrt(p * Math.sin(phi1 / 2) / Math.sin(lam1 / 2));
        d = Math.sqrt(m * n);
        CA = k / d;
        CB = 1 / (k * d);
    };

    this.forward = function(lon, lat, xy) {
        var sin_O, cos_O, d, cosLon, cosLat, sinLat;

        // transverse rotation
        lon += Math.PI / 2;   
        cosLon = Math.cos(lon);
        cosLat = Math.cos(lat);
        // Synder 1987 Map Projections - A working manual, eq. 5-10b with alpha = 0
        lon = Math.atan2(cosLat * Math.sin(lon), Math.sin(lat));
        // Synder 1987 Map Projections - A working manual, eq. 5-9 with alpha = 0
        sinLat = -cosLat * cosLon;
        
        // transformed Lambert azimuthal
        lon *= n;
        sin_O = m * sinLat;
        cos_O = Math.sqrt(1 - sin_O * sin_O);
        d = Math.sqrt(2 / (1 + cos_O * Math.cos(lon)));
        // invert x and y and flip y coordinate
        xy[1] = -CA * d * cos_O * Math.sin(lon);
        xy[0] = CB * d * sin_O;
    };
    
    this.inverse = function(x, y, lonlat) {
    	// FIXME wrong
        var t, D, r;
        t = x * k0;
        r = Math.sqrt(1 - t * t);
        D = y / k0 + lat0;
        lonlat[1] = Math.asin(r * Math.sin(D));
        lonlat[0] = Math.atan2(t, (r * Math.cos(D)));
    };

    this.getOutline = function() {
        return GraticuleOutline.genericOutline(this);
    };

    this.getShaderUniforms = function() {
		var uniforms = [];
		uniforms.projectionID = this.getID();
		uniforms.wagnerM = m;
		uniforms.wagnerN = n;
		uniforms.wagnerCA = CA;
		uniforms.wagnerCB = CB;
		uniforms.falseNorthing = -lat0;
		return uniforms;
    };
   
    this.getID = function() {
        // minus sign for transverse
        return -777;
    };
}