Loading Gruntfile.js +5 −5 Original line number Diff line number Diff line Loading @@ -3,21 +3,21 @@ module.exports = function(grunt) { pkg: grunt.file.readJSON('package.json'), concat:{ full:{ src:[ './src/Proj4js.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'], src:[ './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'], dest:'./dist/proj4.js' }, noDefs:{ src:[ './src/Proj4js.js','./src/Proj.js','./src/defs.js','./src/common.js','./src/datum.js','./src/Point.js','./src/constants.js','./src/projCode/*.js','./src/defs/GOOGLE.js'], src:[ './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/GOOGLE.js'], dest:'./dist/proj4-noDefs.js' } }, uglify:{ full:{ src:[ './src/Proj4js.js','./src/Proj.js','./src/defs.js','./src/common.js','./src/datum.js','./src/Point.js','./src/constants.js','./src/projCode/*.js','./srcgrunt/defs/*.js','./src/util/MGRS.js'], src:[ './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'], dest:'./dist/proj4.min.js' }, noDefs:{ src:[ './src/Proj4js.js','./src/Proj.js','./src/defs.js','./src/common.js','./src/datum.js','./src/Point.js','./src/constants.js','./src/projCode/*.js','./src/defs/GOOGLE.js'], src:[ './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/GOOGLE.js'], dest:'./dist/proj4-noDefs.min.js' } }, Loading src/Point.js +7 −7 Original line number Diff line number Diff line Proj4js.Point = Proj4js.Class({ proj4.Point = proj4.Class({ /** * Constructor: Proj4js.Point * Constructor: proj4.Point * * Parameters: * - x {float} or {Array} either the first coordinates component or Loading @@ -28,13 +28,13 @@ Proj4js.Point = Proj4js.Class({ /** * APIMethod: clone * Build a copy of a Proj4js.Point object. * Build a copy of a proj4.Point object. * * Return: * {Proj4js}.Point the cloned point. * {proj4}.Point the cloned point. */ clone : function() { return new Proj4js.Point(this.x, this.y, this.z); return new proj4.Point(this.x, this.y, this.z); }, /** Loading @@ -42,7 +42,7 @@ Proj4js.Point = Proj4js.Class({ * Return a readable string version of the point * * Return: * {String} String representation of Proj4js.Point object. * {String} String representation of proj4.Point object. * (ex. <i>"x=5,y=42"</i>) */ toString : function() { Loading @@ -54,7 +54,7 @@ Proj4js.Point = Proj4js.Class({ * Return a short string version of the point. * * Return: * {String} Shortened String representation of Proj4js.Point object. * {String} Shortened String representation of proj4.Point object. * (ex. <i>"5, 42"</i>) */ toShortString : function() { Loading src/Proj.js +35 −35 Original line number Diff line number Diff line /** * Class: Proj4js.Proj * Class: proj4.Proj * * Proj objects provide transformation methods for point coordinates * between geodetic latitude/longitude and a projected coordinate system. * once they have been initialized with a projection code. * * Initialization of Proj objects is with a projection code, usually EPSG codes, * which is the key that will be used with the Proj4js.defs array. * which is the key that will be used with the proj4.defs array. * * The code passed in will be stripped of colons and converted to uppercase * to locate projection definition files. * * A projection object has properties for units and title strings. */ Proj4js.Proj = Proj4js.Class({ proj4.Proj = proj4.Class({ /** * Property: readyToUse Loading Loading @@ -70,7 +70,7 @@ Proj4js.Proj = Proj4js.Class({ /** * Constructor: initialize * Constructor for Proj4js.Proj objects * Constructor for proj4.Proj objects * * Parameters: * srsCode - a code for map projection definition parameters. These are usually Loading Loading @@ -154,10 +154,10 @@ Proj4js.Proj = Proj4js.Class({ * */ initTransforms: function() { if(!(this.projName in Proj4js.Proj)){ if(!(this.projName in proj4.Proj)){ throw("unknown projection"); } Proj4js.extend(this, Proj4js.Proj[this.projName]); proj4.extend(this, proj4.Proj[this.projName]); this.init(); this.readyToUse = true; if( this.queue ) { Loading Loading @@ -234,7 +234,7 @@ Proj4js.Proj = Proj4js.Class({ case 'GEOCCS': break; case 'PROJECTION': this.projName = Proj4js.wktProjections[wktName]; this.projName = proj4.wktProjections[wktName]; break; case 'DATUM': this.datumName = wktName; Loading Loading @@ -270,10 +270,10 @@ Proj4js.Proj = Proj4js.Class({ this.k0 = value; break; case 'central_meridian': this.long0 = value*Proj4js.common.D2R; this.long0 = value*proj4.common.D2R; break; case 'latitude_of_origin': this.lat0 = value*Proj4js.common.D2R; this.lat0 = value*proj4.common.D2R; break; case 'more_here': break; Loading Loading @@ -327,7 +327,7 @@ Proj4js.Proj = Proj4js.Class({ 'x_0|y_0|k_0|k|r_a|zone|south|'+ 'towgs84|to_meter|from_greenwich|pm|axis|czech|'+ 'wktext|no_rot|no_off|no_defs)'); this.defData = Proj4js.defs[this.srsCode]; this.defData = proj4.defs[this.srsCode]; var paramName, paramVal; if (!this.defData) { return; Loading Loading @@ -357,17 +357,17 @@ Proj4js.Proj = Proj4js.Class({ case "b": this.b = parseFloat(paramVal); break; // semi-minor radius // DGR 2007-11-20 case "rf": this.rf = parseFloat(paramVal); break; // inverse flattening rf= a/(a-b) case "lat_0": this.lat0 = paramVal*Proj4js.common.D2R; break; // phi0, central latitude case "lat_1": this.lat1 = paramVal*Proj4js.common.D2R; break; //standard parallel 1 case "lat_2": this.lat2 = paramVal*Proj4js.common.D2R; break; //standard parallel 2 case "lat_ts": this.lat_ts = paramVal*Proj4js.common.D2R; break; // used in merc and eqc case "lon_0": this.long0 = paramVal*Proj4js.common.D2R; break; // lam0, central longitude case "lon_1": this.long1 = paramVal*Proj4js.common.D2R; break; case "lon_2": this.long2 = paramVal*Proj4js.common.D2R; break; case "lat_0": this.lat0 = paramVal*proj4.common.D2R; break; // phi0, central latitude case "lat_1": this.lat1 = paramVal*proj4.common.D2R; break; //standard parallel 1 case "lat_2": this.lat2 = paramVal*proj4.common.D2R; break; //standard parallel 2 case "lat_ts": this.lat_ts = paramVal*proj4.common.D2R; break; // used in merc and eqc case "lon_0": this.long0 = paramVal*proj4.common.D2R; break; // lam0, central longitude case "lon_1": this.long1 = paramVal*proj4.common.D2R; break; case "lon_2": this.long2 = paramVal*proj4.common.D2R; break; case "no_rot": this.no_rot = true; break; case "no_off": this.no_off = true; break; case "alpha": this.alpha = parseFloat(paramVal)*Proj4js.common.D2R; break; //for somerc projection case "lonc": this.longc = paramVal*Proj4js.common.D2R; break; //for somerc projection case "alpha": this.alpha = parseFloat(paramVal)*proj4.common.D2R; break; //for somerc projection case "lonc": this.longc = paramVal*proj4.common.D2R; break; //for somerc projection case "x_0": this.x0 = parseFloat(paramVal); break; // false easting case "y_0": this.y0 = parseFloat(paramVal); break; // false northing case "k_0": this.k0 = parseFloat(paramVal); break; // projection scale factor Loading @@ -377,14 +377,14 @@ Proj4js.Proj = Proj4js.Class({ case "south": this.utmSouth = true; break; // UTM north/south case "towgs84":this.datum_params = paramVal.split(","); break; case "to_meter": this.to_meter = parseFloat(paramVal); break; // cartesian scaling case "from_greenwich": this.from_greenwich = paramVal*Proj4js.common.D2R; break; case "from_greenwich": this.from_greenwich = paramVal*proj4.common.D2R; break; case "czech": this.czech = true; break; // DGR 2008-07-09 : if pm is not a well-known prime meridian take // the value instead of 0.0, then convert to radians case "pm": paramVal = paramVal.replace(/\s/gi,""); this.from_greenwich = Proj4js.PrimeMeridian[paramVal] ? Proj4js.PrimeMeridian[paramVal] : parseFloat(paramVal); this.from_greenwich *= Proj4js.common.D2R; this.from_greenwich = proj4.PrimeMeridian[paramVal] ? proj4.PrimeMeridian[paramVal] : parseFloat(paramVal); this.from_greenwich *= proj4.common.D2R; break; // DGR 2010-11-12: axis case "axis": paramVal = paramVal.replace(/\s/gi,""); Loading Loading @@ -423,16 +423,16 @@ Proj4js.Proj = Proj4js.Class({ g= this.grids[i]; var fg= g.split("@"); if (fg[fg.length-1]=="") { Proj4js.reportError("nadgrids syntax error '"+this.nadgrids+"' : empty grid found"); 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) name:fg[fg.length-1], grid: Proj4js.grids[fg[fg.length-1]]//FIXME: grids loading ... grid: proj4.grids[fg[fg.length-1]]//FIXME: grids loading ... }; if (this.grids[i].mandatory && !this.grids[i].grid) { Proj4js.reportError("Missing '"+this.grids[i].name+"'"); proj4.reportError("Missing '"+this.grids[i].name+"'"); } } } Loading @@ -440,7 +440,7 @@ Proj4js.Proj = Proj4js.Class({ // the loaded grids, its name and the mandatory informations of it. } if (this.datumCode && this.datumCode != 'none') { var datumDef = Proj4js.Datum[this.datumCode]; var datumDef = proj4.Datum[this.datumCode]; if (datumDef) { this.datum_params = datumDef.towgs84 ? datumDef.towgs84.split(',') : null; this.ellps = datumDef.ellipse; Loading @@ -448,11 +448,11 @@ Proj4js.Proj = Proj4js.Class({ } } if (!this.a) { // do we have an ellipsoid? var ellipse = Proj4js.Ellipsoid[this.ellps] ? Proj4js.Ellipsoid[this.ellps] : Proj4js.Ellipsoid['WGS84']; Proj4js.extend(this, ellipse); 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; if (this.rf === 0 || Math.abs(this.a - this.b)<Proj4js.common.EPSLN) { if (this.rf === 0 || Math.abs(this.a - this.b)<proj4.common.EPSLN) { this.sphere = true; this.b= this.a; } Loading @@ -461,7 +461,7 @@ Proj4js.Proj = Proj4js.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 * (Proj4js.common.SIXTH + this.es * (Proj4js.common.RA4 + this.es * Proj4js.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.; Loading @@ -471,11 +471,11 @@ Proj4js.Proj = Proj4js.Class({ //DGR 2010-11-12: axis if (!this.axis) { this.axis= "enu"; } this.datum = new Proj4js.datum(this); this.datum = new proj4.datum(this); } }); Proj4js.Proj.longlat = { proj4.Proj.longlat = { init: function() { //no-op for longlat }, Loading @@ -488,10 +488,10 @@ Proj4js.Proj.longlat = { return pt; } }; Proj4js.Proj.identity = Proj4js.Proj.longlat; proj4.Proj.identity = proj4.Proj.longlat; /** Proj4js.defs is a collection of coordinate system definition objects in the proj4.defs is a collection of coordinate system definition objects in the PROJ.4 command line format. Generally a def is added by means of a separate .js file for example: Loading src/Proj4js.js→src/Proj4.js +44 −44 Original line number Diff line number Diff line Loading @@ -7,9 +7,9 @@ $Id: Proj.js 2956 2007-07-09 12:17:52Z steven $ */ /** * Namespace: Proj4js * Namespace: proj4 * * Proj4js is a JavaScript library to transform point coordinates from one * proj4 is a JavaScript library to transform point coordinates from one * coordinate system to another, including datum transformations. * * This library is a port of both the Proj.4 and GCTCP C libraries to JavaScript. Loading @@ -17,15 +17,15 @@ $Id: Proj.js 2956 2007-07-09 12:17:52Z steven $ * in different projections to be combined in browser-based web mapping * applications. * * Proj4js must have access to coordinate system initialization strings (which * proj4 must have access to coordinate system initialization strings (which * are the same as for PROJ.4 command line). Thes can be included in your * application using a <script> tag or Proj4js can load CS initialization * application using a <script> tag or proj4 can load CS initialization * strings from a local directory or a web service such as spatialreference.org. * * Similarly, Proj4js must have access to projection transform code. These can * Similarly, proj4 must have access to projection transform code. These can * be included individually using a <script> tag in your page, built into a * custom build of Proj4js or loaded dynamically at run-time. Using the * -combined and -compressed versions of Proj4js includes all projection class * custom build of proj4 or loaded dynamically at run-time. Using the * -combined and -compressed versions of proj4 includes all projection class * code by default. * * Note that dynamic loading of defs and code happens ascynchrously, check the Loading @@ -37,15 +37,15 @@ $Id: Proj.js 2956 2007-07-09 12:17:52Z steven $ * All coordinates are handled as points which have a .x and a .y property * which will be modified in place. * * Override Proj4js.reportError for output of alerts and warnings. * Override proj4.reportError for output of alerts and warnings. * * See http://trac.osgeo.org/proj4js/wiki/UserGuide for full details. */ /** * Global namespace object for Proj4js library * Global namespace object for proj4 library */ var Proj4js = { var proj4 = { /** * Property: defaultDatum Loading @@ -59,26 +59,26 @@ var Proj4js = { * really the only public method you should need to use. * * Parameters: * source - {Proj4js.Proj} source map projection for the transformation * dest - {Proj4js.Proj} destination map projection for the transformation * source - {proj4.Proj} source map projection for the transformation * dest - {proj4.Proj} destination map projection for the transformation * 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) { if (!source.readyToUse) { this.reportError("Proj4js initialization for:"+source.srsCode+" not yet complete"); this.reportError("proj4 initialization for:"+source.srsCode+" not yet complete"); return point; } if (!dest.readyToUse) { this.reportError("Proj4js initialization for:"+dest.srsCode+" not yet complete"); this.reportError("proj4 initialization for:"+dest.srsCode+" not yet complete"); return point; } // Workaround for datum shifts towgs84, if either source or destination projection is not wgs84 if (source.datum && dest.datum && ( ((source.datum.datum_type == Proj4js.common.PJD_3PARAM || source.datum.datum_type == Proj4js.common.PJD_7PARAM) && dest.datumCode != "WGS84") || ((dest.datum.datum_type == Proj4js.common.PJD_3PARAM || dest.datum.datum_type == Proj4js.common.PJD_7PARAM) && source.datumCode != "WGS84"))) { var wgs84 = Proj4js.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; } Loading @@ -90,8 +90,8 @@ var Proj4js = { // Transform source points to long/lat, if they aren't already. if (source.projName=="longlat") { point.x *= Proj4js.common.D2R; // convert degrees to radians point.y *= Proj4js.common.D2R; point.x *= proj4.common.D2R; // convert degrees to radians point.y *= proj4.common.D2R; } else { if (source.to_meter) { point.x *= source.to_meter; Loading @@ -115,8 +115,8 @@ var Proj4js = { if (dest.projName=="longlat") { // convert radians to decimal degrees point.x *= Proj4js.common.R2D; point.y *= Proj4js.common.R2D; point.x *= proj4.common.R2D; point.y *= proj4.common.R2D; } else { // else project dest.forward(point); if (dest.to_meter) { Loading Loading @@ -148,8 +148,8 @@ var Proj4js = { } // Explicitly skip datum transform by setting 'datum=none' as parameter for either source or dest if( source.datum_type == Proj4js.common.PJD_NODATUM || dest.datum_type == Proj4js.common.PJD_NODATUM) { if( source.datum_type == proj4.common.PJD_NODATUM || dest.datum_type == proj4.common.PJD_NODATUM) { return point; } Loading @@ -162,11 +162,11 @@ var Proj4js = { var fallback= source.datum_type; // If this datum requires grid shifts, then apply it to geodetic coordinates. if( fallback == Proj4js.common.PJD_GRIDSHIFT ) if( fallback == proj4.common.PJD_GRIDSHIFT ) { if (this.apply_gridshift( source, 0, point )==0) { source.a = Proj4js.common.SRS_WGS84_SEMIMAJOR; source.es = Proj4js.common.SRS_WGS84_ESQUARED; source.a = proj4.common.SRS_WGS84_SEMIMAJOR; source.es = proj4.common.SRS_WGS84_ESQUARED; } else { // try 3 or 7 params transformation or nothing ? Loading @@ -185,23 +185,23 @@ var Proj4js = { return point; } fallback= source.datum_params.length>3? Proj4js.common.PJD_7PARAM : Proj4js.common.PJD_3PARAM; proj4.common.PJD_7PARAM : proj4.common.PJD_3PARAM; // CHECK_RETURN; } } if( dest.datum_type == Proj4js.common.PJD_GRIDSHIFT ) if( dest.datum_type == proj4.common.PJD_GRIDSHIFT ) { dest.a = Proj4js.common.SRS_WGS84_SEMIMAJOR; dest.es = Proj4js.common.SRS_WGS84_ESQUARED; 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 == Proj4js.common.PJD_3PARAM || fallback == Proj4js.common.PJD_7PARAM || dest.datum_type == Proj4js.common.PJD_3PARAM || dest.datum_type == Proj4js.common.PJD_7PARAM) || 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) Loading @@ -210,12 +210,12 @@ var Proj4js = { // CHECK_RETURN; // Convert between datums if( source.datum_type == Proj4js.common.PJD_3PARAM || source.datum_type == Proj4js.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 == Proj4js.common.PJD_3PARAM || dest.datum_type == Proj4js.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; } Loading @@ -226,7 +226,7 @@ var Proj4js = { } // Apply grid shift to destination if required if( dest.datum_type == Proj4js.common.PJD_GRIDSHIFT ) if( dest.datum_type == proj4.common.PJD_GRIDSHIFT ) { this.apply_gridshift( dest, 1, point); // CHECK_RETURN; Loading Loading @@ -274,13 +274,13 @@ var Proj4js = { /* TODO : only plain grid has been implemented ... */ /* we found a more refined child node to use */ /* load the grid shift info if we don't have it. */ /* TODO : Proj4js.grids pre-loaded (as they can be huge ...) */ /* TODO : proj4.grids pre-loaded (as they can be huge ...) */ /* skip numerical computing error when "null" grid (identity grid): */ if (gi.name=="null") { output.x= input.x; output.y= input.y; } else { output= Proj4js.common.nad_cvt(input, inverse, ct); output= proj4.common.nad_cvt(input, inverse, ct); } if (!isNaN(output.x)) { break; Loading @@ -289,7 +289,7 @@ var Proj4js = { if (isNaN(output.x)) { if (!onlyMandatoryGrids) { this.reportError("failed to find a grid shift table for location '"+ input.x*Proj4js.common.R2D+" "+input.y*Proj4js.common.R2D+ input.x*proj4.common.R2D+" "+input.y*proj4.common.R2D+ " tried: '"+srs.nadgrids+"'"); return -48; } Loading @@ -305,7 +305,7 @@ var Proj4js = { * Normalize or de-normalized the x/y/z axes. The normal form is "enu" * (easting, northing, up). * Parameters: * crs {Proj4js.Proj} the coordinate reference system * crs {proj4.Proj} the coordinate reference system * denorm {Boolean} when false, normalize * point {Object} the coordinates to adjust */ Loading Loading @@ -359,7 +359,7 @@ var Proj4js = { * The following properties and methods are intended for internal use only. * * This is a minimal implementation of JavaScript inheritance methods so that * Proj4js can be used as a stand-alone library. * proj4 can be used as a stand-alone library. * These are copies of the equivalent OpenLayers methods at v2.7 */ Loading Loading @@ -410,7 +410,7 @@ var Proj4js = { // in this case we're extending with the prototype parent = arguments[i]; } Proj4js.extend(extended, parent); proj4.extend(extended, parent); } Class.prototype = extended; Loading src/common.js +11 −11 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
Gruntfile.js +5 −5 Original line number Diff line number Diff line Loading @@ -3,21 +3,21 @@ module.exports = function(grunt) { pkg: grunt.file.readJSON('package.json'), concat:{ full:{ src:[ './src/Proj4js.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'], src:[ './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'], dest:'./dist/proj4.js' }, noDefs:{ src:[ './src/Proj4js.js','./src/Proj.js','./src/defs.js','./src/common.js','./src/datum.js','./src/Point.js','./src/constants.js','./src/projCode/*.js','./src/defs/GOOGLE.js'], src:[ './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/GOOGLE.js'], dest:'./dist/proj4-noDefs.js' } }, uglify:{ full:{ src:[ './src/Proj4js.js','./src/Proj.js','./src/defs.js','./src/common.js','./src/datum.js','./src/Point.js','./src/constants.js','./src/projCode/*.js','./srcgrunt/defs/*.js','./src/util/MGRS.js'], src:[ './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'], dest:'./dist/proj4.min.js' }, noDefs:{ src:[ './src/Proj4js.js','./src/Proj.js','./src/defs.js','./src/common.js','./src/datum.js','./src/Point.js','./src/constants.js','./src/projCode/*.js','./src/defs/GOOGLE.js'], src:[ './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/GOOGLE.js'], dest:'./dist/proj4-noDefs.min.js' } }, Loading
src/Point.js +7 −7 Original line number Diff line number Diff line Proj4js.Point = Proj4js.Class({ proj4.Point = proj4.Class({ /** * Constructor: Proj4js.Point * Constructor: proj4.Point * * Parameters: * - x {float} or {Array} either the first coordinates component or Loading @@ -28,13 +28,13 @@ Proj4js.Point = Proj4js.Class({ /** * APIMethod: clone * Build a copy of a Proj4js.Point object. * Build a copy of a proj4.Point object. * * Return: * {Proj4js}.Point the cloned point. * {proj4}.Point the cloned point. */ clone : function() { return new Proj4js.Point(this.x, this.y, this.z); return new proj4.Point(this.x, this.y, this.z); }, /** Loading @@ -42,7 +42,7 @@ Proj4js.Point = Proj4js.Class({ * Return a readable string version of the point * * Return: * {String} String representation of Proj4js.Point object. * {String} String representation of proj4.Point object. * (ex. <i>"x=5,y=42"</i>) */ toString : function() { Loading @@ -54,7 +54,7 @@ Proj4js.Point = Proj4js.Class({ * Return a short string version of the point. * * Return: * {String} Shortened String representation of Proj4js.Point object. * {String} Shortened String representation of proj4.Point object. * (ex. <i>"5, 42"</i>) */ toShortString : function() { Loading
src/Proj.js +35 −35 Original line number Diff line number Diff line /** * Class: Proj4js.Proj * Class: proj4.Proj * * Proj objects provide transformation methods for point coordinates * between geodetic latitude/longitude and a projected coordinate system. * once they have been initialized with a projection code. * * Initialization of Proj objects is with a projection code, usually EPSG codes, * which is the key that will be used with the Proj4js.defs array. * which is the key that will be used with the proj4.defs array. * * The code passed in will be stripped of colons and converted to uppercase * to locate projection definition files. * * A projection object has properties for units and title strings. */ Proj4js.Proj = Proj4js.Class({ proj4.Proj = proj4.Class({ /** * Property: readyToUse Loading Loading @@ -70,7 +70,7 @@ Proj4js.Proj = Proj4js.Class({ /** * Constructor: initialize * Constructor for Proj4js.Proj objects * Constructor for proj4.Proj objects * * Parameters: * srsCode - a code for map projection definition parameters. These are usually Loading Loading @@ -154,10 +154,10 @@ Proj4js.Proj = Proj4js.Class({ * */ initTransforms: function() { if(!(this.projName in Proj4js.Proj)){ if(!(this.projName in proj4.Proj)){ throw("unknown projection"); } Proj4js.extend(this, Proj4js.Proj[this.projName]); proj4.extend(this, proj4.Proj[this.projName]); this.init(); this.readyToUse = true; if( this.queue ) { Loading Loading @@ -234,7 +234,7 @@ Proj4js.Proj = Proj4js.Class({ case 'GEOCCS': break; case 'PROJECTION': this.projName = Proj4js.wktProjections[wktName]; this.projName = proj4.wktProjections[wktName]; break; case 'DATUM': this.datumName = wktName; Loading Loading @@ -270,10 +270,10 @@ Proj4js.Proj = Proj4js.Class({ this.k0 = value; break; case 'central_meridian': this.long0 = value*Proj4js.common.D2R; this.long0 = value*proj4.common.D2R; break; case 'latitude_of_origin': this.lat0 = value*Proj4js.common.D2R; this.lat0 = value*proj4.common.D2R; break; case 'more_here': break; Loading Loading @@ -327,7 +327,7 @@ Proj4js.Proj = Proj4js.Class({ 'x_0|y_0|k_0|k|r_a|zone|south|'+ 'towgs84|to_meter|from_greenwich|pm|axis|czech|'+ 'wktext|no_rot|no_off|no_defs)'); this.defData = Proj4js.defs[this.srsCode]; this.defData = proj4.defs[this.srsCode]; var paramName, paramVal; if (!this.defData) { return; Loading Loading @@ -357,17 +357,17 @@ Proj4js.Proj = Proj4js.Class({ case "b": this.b = parseFloat(paramVal); break; // semi-minor radius // DGR 2007-11-20 case "rf": this.rf = parseFloat(paramVal); break; // inverse flattening rf= a/(a-b) case "lat_0": this.lat0 = paramVal*Proj4js.common.D2R; break; // phi0, central latitude case "lat_1": this.lat1 = paramVal*Proj4js.common.D2R; break; //standard parallel 1 case "lat_2": this.lat2 = paramVal*Proj4js.common.D2R; break; //standard parallel 2 case "lat_ts": this.lat_ts = paramVal*Proj4js.common.D2R; break; // used in merc and eqc case "lon_0": this.long0 = paramVal*Proj4js.common.D2R; break; // lam0, central longitude case "lon_1": this.long1 = paramVal*Proj4js.common.D2R; break; case "lon_2": this.long2 = paramVal*Proj4js.common.D2R; break; case "lat_0": this.lat0 = paramVal*proj4.common.D2R; break; // phi0, central latitude case "lat_1": this.lat1 = paramVal*proj4.common.D2R; break; //standard parallel 1 case "lat_2": this.lat2 = paramVal*proj4.common.D2R; break; //standard parallel 2 case "lat_ts": this.lat_ts = paramVal*proj4.common.D2R; break; // used in merc and eqc case "lon_0": this.long0 = paramVal*proj4.common.D2R; break; // lam0, central longitude case "lon_1": this.long1 = paramVal*proj4.common.D2R; break; case "lon_2": this.long2 = paramVal*proj4.common.D2R; break; case "no_rot": this.no_rot = true; break; case "no_off": this.no_off = true; break; case "alpha": this.alpha = parseFloat(paramVal)*Proj4js.common.D2R; break; //for somerc projection case "lonc": this.longc = paramVal*Proj4js.common.D2R; break; //for somerc projection case "alpha": this.alpha = parseFloat(paramVal)*proj4.common.D2R; break; //for somerc projection case "lonc": this.longc = paramVal*proj4.common.D2R; break; //for somerc projection case "x_0": this.x0 = parseFloat(paramVal); break; // false easting case "y_0": this.y0 = parseFloat(paramVal); break; // false northing case "k_0": this.k0 = parseFloat(paramVal); break; // projection scale factor Loading @@ -377,14 +377,14 @@ Proj4js.Proj = Proj4js.Class({ case "south": this.utmSouth = true; break; // UTM north/south case "towgs84":this.datum_params = paramVal.split(","); break; case "to_meter": this.to_meter = parseFloat(paramVal); break; // cartesian scaling case "from_greenwich": this.from_greenwich = paramVal*Proj4js.common.D2R; break; case "from_greenwich": this.from_greenwich = paramVal*proj4.common.D2R; break; case "czech": this.czech = true; break; // DGR 2008-07-09 : if pm is not a well-known prime meridian take // the value instead of 0.0, then convert to radians case "pm": paramVal = paramVal.replace(/\s/gi,""); this.from_greenwich = Proj4js.PrimeMeridian[paramVal] ? Proj4js.PrimeMeridian[paramVal] : parseFloat(paramVal); this.from_greenwich *= Proj4js.common.D2R; this.from_greenwich = proj4.PrimeMeridian[paramVal] ? proj4.PrimeMeridian[paramVal] : parseFloat(paramVal); this.from_greenwich *= proj4.common.D2R; break; // DGR 2010-11-12: axis case "axis": paramVal = paramVal.replace(/\s/gi,""); Loading Loading @@ -423,16 +423,16 @@ Proj4js.Proj = Proj4js.Class({ g= this.grids[i]; var fg= g.split("@"); if (fg[fg.length-1]=="") { Proj4js.reportError("nadgrids syntax error '"+this.nadgrids+"' : empty grid found"); 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) name:fg[fg.length-1], grid: Proj4js.grids[fg[fg.length-1]]//FIXME: grids loading ... grid: proj4.grids[fg[fg.length-1]]//FIXME: grids loading ... }; if (this.grids[i].mandatory && !this.grids[i].grid) { Proj4js.reportError("Missing '"+this.grids[i].name+"'"); proj4.reportError("Missing '"+this.grids[i].name+"'"); } } } Loading @@ -440,7 +440,7 @@ Proj4js.Proj = Proj4js.Class({ // the loaded grids, its name and the mandatory informations of it. } if (this.datumCode && this.datumCode != 'none') { var datumDef = Proj4js.Datum[this.datumCode]; var datumDef = proj4.Datum[this.datumCode]; if (datumDef) { this.datum_params = datumDef.towgs84 ? datumDef.towgs84.split(',') : null; this.ellps = datumDef.ellipse; Loading @@ -448,11 +448,11 @@ Proj4js.Proj = Proj4js.Class({ } } if (!this.a) { // do we have an ellipsoid? var ellipse = Proj4js.Ellipsoid[this.ellps] ? Proj4js.Ellipsoid[this.ellps] : Proj4js.Ellipsoid['WGS84']; Proj4js.extend(this, ellipse); 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; if (this.rf === 0 || Math.abs(this.a - this.b)<Proj4js.common.EPSLN) { if (this.rf === 0 || Math.abs(this.a - this.b)<proj4.common.EPSLN) { this.sphere = true; this.b= this.a; } Loading @@ -461,7 +461,7 @@ Proj4js.Proj = Proj4js.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 * (Proj4js.common.SIXTH + this.es * (Proj4js.common.RA4 + this.es * Proj4js.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.; Loading @@ -471,11 +471,11 @@ Proj4js.Proj = Proj4js.Class({ //DGR 2010-11-12: axis if (!this.axis) { this.axis= "enu"; } this.datum = new Proj4js.datum(this); this.datum = new proj4.datum(this); } }); Proj4js.Proj.longlat = { proj4.Proj.longlat = { init: function() { //no-op for longlat }, Loading @@ -488,10 +488,10 @@ Proj4js.Proj.longlat = { return pt; } }; Proj4js.Proj.identity = Proj4js.Proj.longlat; proj4.Proj.identity = proj4.Proj.longlat; /** Proj4js.defs is a collection of coordinate system definition objects in the proj4.defs is a collection of coordinate system definition objects in the PROJ.4 command line format. Generally a def is added by means of a separate .js file for example: Loading
src/Proj4js.js→src/Proj4.js +44 −44 Original line number Diff line number Diff line Loading @@ -7,9 +7,9 @@ $Id: Proj.js 2956 2007-07-09 12:17:52Z steven $ */ /** * Namespace: Proj4js * Namespace: proj4 * * Proj4js is a JavaScript library to transform point coordinates from one * proj4 is a JavaScript library to transform point coordinates from one * coordinate system to another, including datum transformations. * * This library is a port of both the Proj.4 and GCTCP C libraries to JavaScript. Loading @@ -17,15 +17,15 @@ $Id: Proj.js 2956 2007-07-09 12:17:52Z steven $ * in different projections to be combined in browser-based web mapping * applications. * * Proj4js must have access to coordinate system initialization strings (which * proj4 must have access to coordinate system initialization strings (which * are the same as for PROJ.4 command line). Thes can be included in your * application using a <script> tag or Proj4js can load CS initialization * application using a <script> tag or proj4 can load CS initialization * strings from a local directory or a web service such as spatialreference.org. * * Similarly, Proj4js must have access to projection transform code. These can * Similarly, proj4 must have access to projection transform code. These can * be included individually using a <script> tag in your page, built into a * custom build of Proj4js or loaded dynamically at run-time. Using the * -combined and -compressed versions of Proj4js includes all projection class * custom build of proj4 or loaded dynamically at run-time. Using the * -combined and -compressed versions of proj4 includes all projection class * code by default. * * Note that dynamic loading of defs and code happens ascynchrously, check the Loading @@ -37,15 +37,15 @@ $Id: Proj.js 2956 2007-07-09 12:17:52Z steven $ * All coordinates are handled as points which have a .x and a .y property * which will be modified in place. * * Override Proj4js.reportError for output of alerts and warnings. * Override proj4.reportError for output of alerts and warnings. * * See http://trac.osgeo.org/proj4js/wiki/UserGuide for full details. */ /** * Global namespace object for Proj4js library * Global namespace object for proj4 library */ var Proj4js = { var proj4 = { /** * Property: defaultDatum Loading @@ -59,26 +59,26 @@ var Proj4js = { * really the only public method you should need to use. * * Parameters: * source - {Proj4js.Proj} source map projection for the transformation * dest - {Proj4js.Proj} destination map projection for the transformation * source - {proj4.Proj} source map projection for the transformation * dest - {proj4.Proj} destination map projection for the transformation * 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) { if (!source.readyToUse) { this.reportError("Proj4js initialization for:"+source.srsCode+" not yet complete"); this.reportError("proj4 initialization for:"+source.srsCode+" not yet complete"); return point; } if (!dest.readyToUse) { this.reportError("Proj4js initialization for:"+dest.srsCode+" not yet complete"); this.reportError("proj4 initialization for:"+dest.srsCode+" not yet complete"); return point; } // Workaround for datum shifts towgs84, if either source or destination projection is not wgs84 if (source.datum && dest.datum && ( ((source.datum.datum_type == Proj4js.common.PJD_3PARAM || source.datum.datum_type == Proj4js.common.PJD_7PARAM) && dest.datumCode != "WGS84") || ((dest.datum.datum_type == Proj4js.common.PJD_3PARAM || dest.datum.datum_type == Proj4js.common.PJD_7PARAM) && source.datumCode != "WGS84"))) { var wgs84 = Proj4js.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; } Loading @@ -90,8 +90,8 @@ var Proj4js = { // Transform source points to long/lat, if they aren't already. if (source.projName=="longlat") { point.x *= Proj4js.common.D2R; // convert degrees to radians point.y *= Proj4js.common.D2R; point.x *= proj4.common.D2R; // convert degrees to radians point.y *= proj4.common.D2R; } else { if (source.to_meter) { point.x *= source.to_meter; Loading @@ -115,8 +115,8 @@ var Proj4js = { if (dest.projName=="longlat") { // convert radians to decimal degrees point.x *= Proj4js.common.R2D; point.y *= Proj4js.common.R2D; point.x *= proj4.common.R2D; point.y *= proj4.common.R2D; } else { // else project dest.forward(point); if (dest.to_meter) { Loading Loading @@ -148,8 +148,8 @@ var Proj4js = { } // Explicitly skip datum transform by setting 'datum=none' as parameter for either source or dest if( source.datum_type == Proj4js.common.PJD_NODATUM || dest.datum_type == Proj4js.common.PJD_NODATUM) { if( source.datum_type == proj4.common.PJD_NODATUM || dest.datum_type == proj4.common.PJD_NODATUM) { return point; } Loading @@ -162,11 +162,11 @@ var Proj4js = { var fallback= source.datum_type; // If this datum requires grid shifts, then apply it to geodetic coordinates. if( fallback == Proj4js.common.PJD_GRIDSHIFT ) if( fallback == proj4.common.PJD_GRIDSHIFT ) { if (this.apply_gridshift( source, 0, point )==0) { source.a = Proj4js.common.SRS_WGS84_SEMIMAJOR; source.es = Proj4js.common.SRS_WGS84_ESQUARED; source.a = proj4.common.SRS_WGS84_SEMIMAJOR; source.es = proj4.common.SRS_WGS84_ESQUARED; } else { // try 3 or 7 params transformation or nothing ? Loading @@ -185,23 +185,23 @@ var Proj4js = { return point; } fallback= source.datum_params.length>3? Proj4js.common.PJD_7PARAM : Proj4js.common.PJD_3PARAM; proj4.common.PJD_7PARAM : proj4.common.PJD_3PARAM; // CHECK_RETURN; } } if( dest.datum_type == Proj4js.common.PJD_GRIDSHIFT ) if( dest.datum_type == proj4.common.PJD_GRIDSHIFT ) { dest.a = Proj4js.common.SRS_WGS84_SEMIMAJOR; dest.es = Proj4js.common.SRS_WGS84_ESQUARED; 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 == Proj4js.common.PJD_3PARAM || fallback == Proj4js.common.PJD_7PARAM || dest.datum_type == Proj4js.common.PJD_3PARAM || dest.datum_type == Proj4js.common.PJD_7PARAM) || 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) Loading @@ -210,12 +210,12 @@ var Proj4js = { // CHECK_RETURN; // Convert between datums if( source.datum_type == Proj4js.common.PJD_3PARAM || source.datum_type == Proj4js.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 == Proj4js.common.PJD_3PARAM || dest.datum_type == Proj4js.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; } Loading @@ -226,7 +226,7 @@ var Proj4js = { } // Apply grid shift to destination if required if( dest.datum_type == Proj4js.common.PJD_GRIDSHIFT ) if( dest.datum_type == proj4.common.PJD_GRIDSHIFT ) { this.apply_gridshift( dest, 1, point); // CHECK_RETURN; Loading Loading @@ -274,13 +274,13 @@ var Proj4js = { /* TODO : only plain grid has been implemented ... */ /* we found a more refined child node to use */ /* load the grid shift info if we don't have it. */ /* TODO : Proj4js.grids pre-loaded (as they can be huge ...) */ /* TODO : proj4.grids pre-loaded (as they can be huge ...) */ /* skip numerical computing error when "null" grid (identity grid): */ if (gi.name=="null") { output.x= input.x; output.y= input.y; } else { output= Proj4js.common.nad_cvt(input, inverse, ct); output= proj4.common.nad_cvt(input, inverse, ct); } if (!isNaN(output.x)) { break; Loading @@ -289,7 +289,7 @@ var Proj4js = { if (isNaN(output.x)) { if (!onlyMandatoryGrids) { this.reportError("failed to find a grid shift table for location '"+ input.x*Proj4js.common.R2D+" "+input.y*Proj4js.common.R2D+ input.x*proj4.common.R2D+" "+input.y*proj4.common.R2D+ " tried: '"+srs.nadgrids+"'"); return -48; } Loading @@ -305,7 +305,7 @@ var Proj4js = { * Normalize or de-normalized the x/y/z axes. The normal form is "enu" * (easting, northing, up). * Parameters: * crs {Proj4js.Proj} the coordinate reference system * crs {proj4.Proj} the coordinate reference system * denorm {Boolean} when false, normalize * point {Object} the coordinates to adjust */ Loading Loading @@ -359,7 +359,7 @@ var Proj4js = { * The following properties and methods are intended for internal use only. * * This is a minimal implementation of JavaScript inheritance methods so that * Proj4js can be used as a stand-alone library. * proj4 can be used as a stand-alone library. * These are copies of the equivalent OpenLayers methods at v2.7 */ Loading Loading @@ -410,7 +410,7 @@ var Proj4js = { // in this case we're extending with the prototype parent = arguments[i]; } Proj4js.extend(extended, parent); proj4.extend(extended, parent); } Class.prototype = extended; Loading