Loading Gruntfile.js +1 −3 Original line number Diff line number Diff line Loading @@ -52,9 +52,7 @@ module.exports = function(grunt) { endFile: 'almond/end.frag' }, name: '../almond/almond', include: ['proj4'], insertRequire: ['proj4'], optimize:'none' include: ['proj4'] } } } Loading docs/index.htmldeleted 100755 → 0 +0 −35 Original line number Diff line number Diff line <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <link rel="stylesheet" href="img/base.css"/> <title>Proj4js Docs</title> <script src="../lib/prototype.js"></script> <script src="../lib/proj4js.js"></script> <script> var mapXY = new Proj4js.Point(0,0); var lonLat = new Proj4js.Point(0,0); var sourceProj = new Proj4js.Proj("EPSG:42304"); var newLonLat = sourceProj.mapXYToLonLat(mapXY); var newMapXY = sourceProj.lonLatToMapXY(lonLat); var destProj = new Proj4js.Proj("EPSG:2957"); var otherProjXY = sourceProj.transform(mapXY, destProj); </script> </head> <body> Proj4js Documentation Usage 1. include the Proj4js package source JavaScript 2. initialize a Proj4js.Proj object with a projection code 3. transform away Configuration defs projCode mapExamples globals Sources </body> </html> No newline at end of file src/Point.js +31 −59 Original line number Diff line number Diff line define(function(require, exports, module) { var Class = require('./class'); var mgrs = require('./mgrs'); var Point = Class({ /** * Constructor: proj4.Point * * Parameters: * - x {float} or {Array} either the first coordinates component or * the full coordinates * - y {float} the second component * - z {float} the third component, optional. */ initialize: function(x, y, z) { var Point = function(x, y, z) { if (typeof x === 'object') { this.x = x[0]; this.y = x[1]; Loading @@ -29,28 +17,12 @@ define(function(require, exports, module) { this.y = y; this.z = z || 0.0; } }, /** * APIMethod: clone * Build a copy of a proj4.Point object. * * Return: * {proj4}.Point the cloned point. */ clone: function() { this.clone = function() { return new Point(this.x, this.y, this.z); }, /** * APIMethod: toString * Return a readable string version of the point * * Return: * {String} String representation of proj4.Point object. * (ex. <i>"x=5,y=42"</i>) */ toString: function() { }; this.toString = function() { return ("x=" + this.x + ",y=" + this.y); }, }; /** * APIMethod: toShortString * Return a short string version of the point. Loading @@ -59,15 +31,21 @@ define(function(require, exports, module) { * {String} Shortened String representation of proj4.Point object. * (ex. <i>"5, 42"</i>) */ toShortString: function() { this.toShortString = function() { return (this.x + ", " + this.y); } }); }; }; Point.fromMGRS = function(mgrsStr) { var llbbox = mgrs.inverse(mgrsStr); return new Point((llbbox[2] + llbbox[0]) / 2, (llbbox[3] + llbbox[1]) / 2); }; Point.prototype.toMGRS = function(accuracy) { return mgrs.forward({ lon: this.x, lat: this.y }, accuracy); }; /** * Converts a proj4.Point instance to a MGRS reference. The point * coordinates are expected to be in WGS84 longitude and latitude. Loading @@ -77,11 +55,5 @@ define(function(require, exports, module) { * @param accuracy {int} The accuracy for the MGRS reference in digits (5 * for 1 m, 4 for 10 m, 3 for 100 m, 4 for 1000 m or 5 for 10000 m) */ Point.prototype.toMGRS = function(accuracy) { return mgrs.forward({ lon: this.x, lat: this.y }, accuracy); }; module.exports = Point; }); src/Proj.js +88 −90 Original line number Diff line number Diff line Loading @@ -14,7 +14,6 @@ define(function(require, exports, module) { * * A projection object has properties for units and title strings. */ var Class = require('./class'); var extend = require('./extend'); var common = require('./common'); var defs = require('./defs'); Loading @@ -36,57 +35,7 @@ define(function(require, exports, module) { }; projections.identity = projections.longlat; var proj = Class({ /** * Property: title * The title to describe the projection */ title: null, /** * Property: projName * The projection class for this projection, e.g. lcc (lambert conformal conic, * or merc for mercator). These are exactly equivalent to their Proj4 * counterparts. */ projName: null, /** * Property: units * The units of the projection. Values include 'm' and 'degrees' */ units: null, /** * Property: datum * The datum specified for the projection */ datum: null, /** * Property: x0 * The x coordinate origin */ x0: 0, /** * Property: y0 * The y coordinate origin */ y0: 0, /** * Property: localCS * Flag to indicate if the projection is a local one in which no transforms * are required. */ localCS: false, /** * Constructor: initialize * Constructor for proj objects * * Parameters: * srsCode - a code for map projection definition parameters. These are usually * (but not always) EPSG codes. */ initialize: function(srsCode) { var proj = function(srsCode) { this.srsCodeInput = srsCode; //check to see if this is a WKT string Loading Loading @@ -152,7 +101,56 @@ define(function(require, exports, module) { this.parseDefs(); } this.initTransforms(this.projName); }, }; proj.prototype = { /** * Property: title * The title to describe the projection */ title: null, /** * Property: projName * The projection class for this projection, e.g. lcc (lambert conformal conic, * or merc for mercator). These are exactly equivalent to their Proj4 * counterparts. */ projName: null, /** * Property: units * The units of the projection. Values include 'm' and 'degrees' */ units: null, /** * Property: datum * The datum specified for the projection */ datum: null, /** * Property: x0 * The x coordinate origin */ x0: 0, /** * Property: y0 * The y coordinate origin */ y0: 0, /** * Property: localCS * Flag to indicate if the projection is a local one in which no transforms * are required. */ localCS: false, /** * Constructor: initialize * Constructor for proj objects * * Parameters: * srsCode - a code for map projection definition parameters. These are usually * (but not always) EPSG codes. */ /** * Function: initTransforms Loading @@ -160,10 +158,10 @@ define(function(require, exports, module) { * */ initTransforms: function(projName) { if (!(projName in projections)) { if (!(projName in proj.projections)) { throw ("unknown projection " + projName); } extend(this, projections[projName]); extend(this, proj.projections[projName]); this.init(); }, Loading Loading @@ -441,8 +439,8 @@ define(function(require, exports, module) { this.datum = new datum(this); } }); }; proj.projections = projections; module.exports = proj; }); src/class.jsdeleted 100644 → 0 +0 −23 Original line number Diff line number Diff line define(function(require, exports, module) { var extend = require('./extend'); module.exports = function() { var Class = function() { this.initialize.apply(this, arguments); }; var extended = {}; var parent, i; for (i = 0; i < arguments.length; ++i) { if (typeof arguments[i] === "function") { // get the prototype of the superclass parent = arguments[i].prototype; } else { // in this case we're extending with the prototype parent = arguments[i]; } extend(extended, parent); } Class.prototype = extended; return Class; }; }); Loading
Gruntfile.js +1 −3 Original line number Diff line number Diff line Loading @@ -52,9 +52,7 @@ module.exports = function(grunt) { endFile: 'almond/end.frag' }, name: '../almond/almond', include: ['proj4'], insertRequire: ['proj4'], optimize:'none' include: ['proj4'] } } } Loading
docs/index.htmldeleted 100755 → 0 +0 −35 Original line number Diff line number Diff line <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <link rel="stylesheet" href="img/base.css"/> <title>Proj4js Docs</title> <script src="../lib/prototype.js"></script> <script src="../lib/proj4js.js"></script> <script> var mapXY = new Proj4js.Point(0,0); var lonLat = new Proj4js.Point(0,0); var sourceProj = new Proj4js.Proj("EPSG:42304"); var newLonLat = sourceProj.mapXYToLonLat(mapXY); var newMapXY = sourceProj.lonLatToMapXY(lonLat); var destProj = new Proj4js.Proj("EPSG:2957"); var otherProjXY = sourceProj.transform(mapXY, destProj); </script> </head> <body> Proj4js Documentation Usage 1. include the Proj4js package source JavaScript 2. initialize a Proj4js.Proj object with a projection code 3. transform away Configuration defs projCode mapExamples globals Sources </body> </html> No newline at end of file
src/Point.js +31 −59 Original line number Diff line number Diff line define(function(require, exports, module) { var Class = require('./class'); var mgrs = require('./mgrs'); var Point = Class({ /** * Constructor: proj4.Point * * Parameters: * - x {float} or {Array} either the first coordinates component or * the full coordinates * - y {float} the second component * - z {float} the third component, optional. */ initialize: function(x, y, z) { var Point = function(x, y, z) { if (typeof x === 'object') { this.x = x[0]; this.y = x[1]; Loading @@ -29,28 +17,12 @@ define(function(require, exports, module) { this.y = y; this.z = z || 0.0; } }, /** * APIMethod: clone * Build a copy of a proj4.Point object. * * Return: * {proj4}.Point the cloned point. */ clone: function() { this.clone = function() { return new Point(this.x, this.y, this.z); }, /** * APIMethod: toString * Return a readable string version of the point * * Return: * {String} String representation of proj4.Point object. * (ex. <i>"x=5,y=42"</i>) */ toString: function() { }; this.toString = function() { return ("x=" + this.x + ",y=" + this.y); }, }; /** * APIMethod: toShortString * Return a short string version of the point. Loading @@ -59,15 +31,21 @@ define(function(require, exports, module) { * {String} Shortened String representation of proj4.Point object. * (ex. <i>"5, 42"</i>) */ toShortString: function() { this.toShortString = function() { return (this.x + ", " + this.y); } }); }; }; Point.fromMGRS = function(mgrsStr) { var llbbox = mgrs.inverse(mgrsStr); return new Point((llbbox[2] + llbbox[0]) / 2, (llbbox[3] + llbbox[1]) / 2); }; Point.prototype.toMGRS = function(accuracy) { return mgrs.forward({ lon: this.x, lat: this.y }, accuracy); }; /** * Converts a proj4.Point instance to a MGRS reference. The point * coordinates are expected to be in WGS84 longitude and latitude. Loading @@ -77,11 +55,5 @@ define(function(require, exports, module) { * @param accuracy {int} The accuracy for the MGRS reference in digits (5 * for 1 m, 4 for 10 m, 3 for 100 m, 4 for 1000 m or 5 for 10000 m) */ Point.prototype.toMGRS = function(accuracy) { return mgrs.forward({ lon: this.x, lat: this.y }, accuracy); }; module.exports = Point; });
src/Proj.js +88 −90 Original line number Diff line number Diff line Loading @@ -14,7 +14,6 @@ define(function(require, exports, module) { * * A projection object has properties for units and title strings. */ var Class = require('./class'); var extend = require('./extend'); var common = require('./common'); var defs = require('./defs'); Loading @@ -36,57 +35,7 @@ define(function(require, exports, module) { }; projections.identity = projections.longlat; var proj = Class({ /** * Property: title * The title to describe the projection */ title: null, /** * Property: projName * The projection class for this projection, e.g. lcc (lambert conformal conic, * or merc for mercator). These are exactly equivalent to their Proj4 * counterparts. */ projName: null, /** * Property: units * The units of the projection. Values include 'm' and 'degrees' */ units: null, /** * Property: datum * The datum specified for the projection */ datum: null, /** * Property: x0 * The x coordinate origin */ x0: 0, /** * Property: y0 * The y coordinate origin */ y0: 0, /** * Property: localCS * Flag to indicate if the projection is a local one in which no transforms * are required. */ localCS: false, /** * Constructor: initialize * Constructor for proj objects * * Parameters: * srsCode - a code for map projection definition parameters. These are usually * (but not always) EPSG codes. */ initialize: function(srsCode) { var proj = function(srsCode) { this.srsCodeInput = srsCode; //check to see if this is a WKT string Loading Loading @@ -152,7 +101,56 @@ define(function(require, exports, module) { this.parseDefs(); } this.initTransforms(this.projName); }, }; proj.prototype = { /** * Property: title * The title to describe the projection */ title: null, /** * Property: projName * The projection class for this projection, e.g. lcc (lambert conformal conic, * or merc for mercator). These are exactly equivalent to their Proj4 * counterparts. */ projName: null, /** * Property: units * The units of the projection. Values include 'm' and 'degrees' */ units: null, /** * Property: datum * The datum specified for the projection */ datum: null, /** * Property: x0 * The x coordinate origin */ x0: 0, /** * Property: y0 * The y coordinate origin */ y0: 0, /** * Property: localCS * Flag to indicate if the projection is a local one in which no transforms * are required. */ localCS: false, /** * Constructor: initialize * Constructor for proj objects * * Parameters: * srsCode - a code for map projection definition parameters. These are usually * (but not always) EPSG codes. */ /** * Function: initTransforms Loading @@ -160,10 +158,10 @@ define(function(require, exports, module) { * */ initTransforms: function(projName) { if (!(projName in projections)) { if (!(projName in proj.projections)) { throw ("unknown projection " + projName); } extend(this, projections[projName]); extend(this, proj.projections[projName]); this.init(); }, Loading Loading @@ -441,8 +439,8 @@ define(function(require, exports, module) { this.datum = new datum(this); } }); }; proj.projections = projections; module.exports = proj; });
src/class.jsdeleted 100644 → 0 +0 −23 Original line number Diff line number Diff line define(function(require, exports, module) { var extend = require('./extend'); module.exports = function() { var Class = function() { this.initialize.apply(this, arguments); }; var extended = {}; var parent, i; for (i = 0; i < arguments.length; ++i) { if (typeof arguments[i] === "function") { // get the prototype of the superclass parent = arguments[i].prototype; } else { // in this case we're extending with the prototype parent = arguments[i]; } extend(extended, parent); } Class.prototype = extended; return Class; }; });