Loading test/index.old.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 href="base.css" type="text/css" rel="stylesheet"/> <title>Proj4js Test Page</title> <script src="../dist/proj4.js"></script> <script src="../src/util/MGRS.js"></script> <script src="testdata.js"></script> <script src="runtests.js"></script> </head> <body onload="runTests()"> <div id="header"> <h1>Proj4js test page</h1> </div> <div id="navbar"> <a href="http://trac.osgeo.org/proj4js">Proj4js Wiki/Trac</a> | <a href="http://wiki.osgeo.org/wiki/MetaCRS">OSGeo MetaCRS</a> | <a href="http://spatialreference.org/">spatialreference.org</a> | <a href="http://communitymapbuilder.org/">MapBuilder</a> | <a href="http://openlayers.org/">OpenLayers</a> | </div> <h2>Core tests</h2> <table id="testResult" border="1"> <tr> <th>projection</th> <th>class</th> <th colspan="3">forward (m)</th> <th colspan="3">inverse (dd)</th> </tr> </table> <h2>Utility tests</h2> <script type="text/javascript" src="mgrs.js"></script> </body> </html> test/mgrs.jsdeleted 100644 → 0 +0 −28 Original line number Diff line number Diff line (function() { assert(typeof Proj4js.util.MGRS, "object", "MGRS available in the Proj4js.util namespace"); assert(typeof Proj4js.Point.fromMGRS, "function", "fromMGRS method added to Proj4js.Point prototype"); assert(typeof Proj4js.Point.prototype.toMGRS, "function", "toMGRS method added to Proj4js.Point prototype"); // Conversions cross-tested with http://geographiclib.sourceforge.net/cgi-bin/GeoConvert var mgrs, point; mgrs = "33UXP04"; point = Proj4js.Point.fromMGRS(mgrs); assert(point.x.toPrecision(7), "16.41450", "Longitude of point from MGRS correct."); assert(point.y.toPrecision(7), "48.24949", "Latitude of point from MGRS correct."); assert(point.toMGRS(), "33UXP0500444998", "MGRS reference with highest accuracy correct."); assert(point.toMGRS(1), mgrs, "MGRS reference with 1-digit accuracy correct."); mgrs = "24XWT783908"; // near UTM zone border, so there are two ways to reference this point = Proj4js.Point.fromMGRS(mgrs); assert(point.x.toPrecision(7), "-32.66433", "Longitude of point from MGRS correct."); assert(point.y.toPrecision(7), "83.62778", "Latitude of point from MGRS correct."); assert(point.toMGRS(3), "25XEN041865", "MGRS reference with 3-digit accuracy correct."); function assert(got, expected, msg) { if (got == expected) { document.write('<div>' + msg + '</div>'); } else { document.write('<div style="background-color:red">' + msg + ' - got ' + got + ', but expected ' + expected + '</div>'); } } })(); test/min.html 0 → 100644 +30 −0 Original line number Diff line number Diff line <html> <head> <meta charset="utf-8"> <title>Mocha Tests</title> <link rel="stylesheet" href="lib/mocha.css" /> </head> <body> <div id="mocha"></div> <script src="../dist/proj4.min.js"></script> <script src="lib/mocha.js"></script> <script src="lib/chai.js"></script> <script> mocha.setup({ ui: "bdd", globals: ["console"], timeout: 300000 }); var assert = chai.assert; </script> <script src="testdata.js"></script> <script src="test.js"></script> <script> if (window.mochaPhantomJS) { mochaPhantomJS.run(); } else { mocha.run(); } </script> </body> </html> No newline at end of file test/runtests.jsdeleted 100755 → 0 +0 −98 Original line number Diff line number Diff line /* Loop through the test points and create a Proj object for each */ var src, dest; function runTests() { //src = new Proj4js.Proj(Proj4js.defs["WKT0"],cb2); /* src = new Proj4js.Proj("EPSG:900913",cb1); var testPt = new Proj4js.Point([1113194.9079327357, 6800125.454397307]); var testRes = Proj4js.transform(src, dest, testPt); alert(testRes.toString()); */ /* //testing the conversion bewteen CSs which use the towgs84 params (ticket #64) //TODO convert this to asserts src = new Proj4js.Proj("EPSG:21781"); dest = new Proj4js.Proj("EPSG:900913"); var testPt = new Proj4js.Point([699212,227132]); var testRes = Proj4js.transform(src, dest, testPt); alert(testRes.toString()); //result should be 973791.60867,5972764.60117 */ for (var i=0; i < Proj4js.testPoints.length; ++i) { var test = Proj4js.testPoints[i]; var proj = new Proj4js.Proj(test.code, Proj4js.bind(showResults, this, test)); } } function cb1() { dest = new Proj4js.Proj("EPSG:2303X",cb2); } function cb2(arg1) { //alert('all set'); } /* a callback function to run the test for this test point since we are using the dynamic load capabilities in the test page */ function showResults(test, proj) { //var test = proj.testPoint; var xyEPSLN = 1.0e-2; var llEPSLN = 1.0e-6; var row = document.createElement('tr'); var td = document.createElement('td'); td.innerHTML = test.code; row.appendChild(td); var td = document.createElement('td'); td.innerHTML = proj.projName; row.appendChild(td); //transform from lon/lat to projected x/y and cmopare var xyResult = Proj4js.transform(Proj4js.WGS84, proj, new Proj4js.Point(test.ll)); if (xyResult) { var deltaX = Math.abs(xyResult.x - test.xy[0]); var deltaY = Math.abs(xyResult.y - test.xy[1]); td = document.createElement('td'); td.innerHTML = "in:"+test.ll[0]+","+test.ll[1]; row.appendChild(td); td = document.createElement('td'); td.innerHTML = "out:"+xyResult.x+","+xyResult.y; row.appendChild(td); td = document.createElement('td'); td.innerHTML = "dx:"+deltaX+ " dy:"+deltaY; if ( deltaX>xyEPSLN || deltaY>xyEPSLN ) td.style.backgroundColor='red'; row.appendChild(td); } else { td = document.createElement('td'); td.innerHTML = "proj undefined"; row.appendChild(td); } //transform from map x/y to lon/lat and compare var llResult = Proj4js.transform(proj, Proj4js.WGS84, new Proj4js.Point(test.xy)); if (llResult) { var deltaX = Math.abs(llResult.x - test.ll[0]); var deltaY = Math.abs(llResult.y - test.ll[1]); td = document.createElement('td'); td.innerHTML = "in:"+test.xy[0]+","+test.xy[1]; row.appendChild(td); td = document.createElement('td'); td.innerHTML = "out:"+llResult.x+","+llResult.y; row.appendChild(td); td = document.createElement('td'); td.innerHTML = "dx:"+deltaX+ " dy:"+deltaY; if ( deltaX>llEPSLN || deltaY>llEPSLN ) td.style.backgroundColor='red'; row.appendChild(td); } else { td = document.createElement('td'); td.innerHTML = "proj undefined"; row.appendChild(td); } var testTable = document.getElementById('testResult'); testTable.tBodies[0].appendChild(row); }; test/test.js +61 −5 Original line number Diff line number Diff line Loading @@ -2,23 +2,79 @@ var xyEPSLN = 1.0e-2; var llEPSLN = 1.0e-6; describe('Proj4js', function () { describe('core',function(){ testPoints.forEach(function(testPoint){ it('should work with forwards ' + testPoint.code, function () { var proj = new Proj4js.Proj(testPoint.code); var xy = Proj4js.transform(Proj4js.WGS84, proj, new Proj4js.Point(testPoint.ll)); console.log(xy.x, testPoint.xy[0]); console.log(xy.y, testPoint.xy[1]); assert.closeTo(xy.x, testPoint.xy[0],xyEPSLN, 'x is close'); assert.closeTo(xy.y, testPoint.xy[1],xyEPSLN, 'y is close'); }); it('should work with backwards ' + testPoint.code, function () { var proj = new Proj4js.Proj(testPoint.code); var ll = Proj4js.transform(proj,Proj4js.WGS84, new Proj4js.Point(testPoint.xy)); console.log(ll.x, testPoint.ll[0]); console.log(ll.y, testPoint.ll[1]); assert.closeTo(ll.x, testPoint.ll[0],llEPSLN, 'lng is close'); assert.closeTo(ll.y, testPoint.ll[1],llEPSLN, 'lat is close'); }); }); }); describe('errors',function(){ it('should throw an error for an unknown ref',function(){ assert.throws(function(){ new Proj4js.Proj('EPSG:23030'); },'unknown projection','should work'); }); }) describe('utility',function(){ it('should have MGRS available in the Proj4js.util namespace',function(){ assert.typeOf(Proj4js.util.MGRS, "object", "MGRS available in the Proj4js.util namespace"); }); it('should have fromMGRS method added to Proj4js.Point prototype',function(){ assert.typeOf(Proj4js.Point.fromMGRS, "function", "fromMGRS method added to Proj4js.Point prototype"); }); it('should have toMGRS method added to Proj4js.Point prototype',function(){ assert.typeOf(Proj4js.Point.prototype.toMGRS, "function", "toMGRS method added to Proj4js.Point prototype"); }); describe('First MGRS set',function(){ var mgrs = "33UXP04"; var point = Proj4js.Point.fromMGRS(mgrs); it('Longitude of point from MGRS correct.',function(){ assert.equal(point.x.toPrecision(7), "16.41450", "Longitude of point from MGRS correct."); }); it('Latitude of point from MGRS correct.',function(){ assert.equal(point.y.toPrecision(7), "48.24949", "Latitude of point from MGRS correct."); }); it('MGRS reference with highest accuracy correct.',function(){ assert.equal(point.toMGRS(), "33UXP0500444998", "MGRS reference with highest accuracy correct."); }); it('MGRS reference with 1-digit accuracy correct.',function(){ assert.equal(point.toMGRS(1), mgrs, "MGRS reference with 1-digit accuracy correct."); }); }); describe('Second MGRS set',function(){ var mgrs = "24XWT783908"; // near UTM zone border, so there are two ways to reference this var point = Proj4js.Point.fromMGRS(mgrs); it("Longitude of point from MGRS correct.",function(){ assert.equal(point.x.toPrecision(7), "-32.66433", "Longitude of point from MGRS correct."); }); it("Latitude of point from MGRS correct.",function(){ assert.equal(point.y.toPrecision(7), "83.62778", "Latitude of point from MGRS correct."); }); it("MGRS reference with 3-digit accuracy correct.",function(){ assert.equal(point.toMGRS(3), "25XEN041865", "MGRS reference with 3-digit accuracy correct."); }); }) }); describe('wkt',function(){ aWKT.forEach(function(wkt){ it('should work with '+wkt.name,function(){ var testProj = new Proj4js.Proj(wkt.wkt); assert.equal(testProj.srsCode,wkt.name,'correct name'); assert.equal(testProj.units,wkt.units,'correct units'); assert.equal(testProj.projName,wkt.proj,'correct type') }); }); }); }); No newline at end of file Loading
test/index.old.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 href="base.css" type="text/css" rel="stylesheet"/> <title>Proj4js Test Page</title> <script src="../dist/proj4.js"></script> <script src="../src/util/MGRS.js"></script> <script src="testdata.js"></script> <script src="runtests.js"></script> </head> <body onload="runTests()"> <div id="header"> <h1>Proj4js test page</h1> </div> <div id="navbar"> <a href="http://trac.osgeo.org/proj4js">Proj4js Wiki/Trac</a> | <a href="http://wiki.osgeo.org/wiki/MetaCRS">OSGeo MetaCRS</a> | <a href="http://spatialreference.org/">spatialreference.org</a> | <a href="http://communitymapbuilder.org/">MapBuilder</a> | <a href="http://openlayers.org/">OpenLayers</a> | </div> <h2>Core tests</h2> <table id="testResult" border="1"> <tr> <th>projection</th> <th>class</th> <th colspan="3">forward (m)</th> <th colspan="3">inverse (dd)</th> </tr> </table> <h2>Utility tests</h2> <script type="text/javascript" src="mgrs.js"></script> </body> </html>
test/mgrs.jsdeleted 100644 → 0 +0 −28 Original line number Diff line number Diff line (function() { assert(typeof Proj4js.util.MGRS, "object", "MGRS available in the Proj4js.util namespace"); assert(typeof Proj4js.Point.fromMGRS, "function", "fromMGRS method added to Proj4js.Point prototype"); assert(typeof Proj4js.Point.prototype.toMGRS, "function", "toMGRS method added to Proj4js.Point prototype"); // Conversions cross-tested with http://geographiclib.sourceforge.net/cgi-bin/GeoConvert var mgrs, point; mgrs = "33UXP04"; point = Proj4js.Point.fromMGRS(mgrs); assert(point.x.toPrecision(7), "16.41450", "Longitude of point from MGRS correct."); assert(point.y.toPrecision(7), "48.24949", "Latitude of point from MGRS correct."); assert(point.toMGRS(), "33UXP0500444998", "MGRS reference with highest accuracy correct."); assert(point.toMGRS(1), mgrs, "MGRS reference with 1-digit accuracy correct."); mgrs = "24XWT783908"; // near UTM zone border, so there are two ways to reference this point = Proj4js.Point.fromMGRS(mgrs); assert(point.x.toPrecision(7), "-32.66433", "Longitude of point from MGRS correct."); assert(point.y.toPrecision(7), "83.62778", "Latitude of point from MGRS correct."); assert(point.toMGRS(3), "25XEN041865", "MGRS reference with 3-digit accuracy correct."); function assert(got, expected, msg) { if (got == expected) { document.write('<div>' + msg + '</div>'); } else { document.write('<div style="background-color:red">' + msg + ' - got ' + got + ', but expected ' + expected + '</div>'); } } })();
test/min.html 0 → 100644 +30 −0 Original line number Diff line number Diff line <html> <head> <meta charset="utf-8"> <title>Mocha Tests</title> <link rel="stylesheet" href="lib/mocha.css" /> </head> <body> <div id="mocha"></div> <script src="../dist/proj4.min.js"></script> <script src="lib/mocha.js"></script> <script src="lib/chai.js"></script> <script> mocha.setup({ ui: "bdd", globals: ["console"], timeout: 300000 }); var assert = chai.assert; </script> <script src="testdata.js"></script> <script src="test.js"></script> <script> if (window.mochaPhantomJS) { mochaPhantomJS.run(); } else { mocha.run(); } </script> </body> </html> No newline at end of file
test/runtests.jsdeleted 100755 → 0 +0 −98 Original line number Diff line number Diff line /* Loop through the test points and create a Proj object for each */ var src, dest; function runTests() { //src = new Proj4js.Proj(Proj4js.defs["WKT0"],cb2); /* src = new Proj4js.Proj("EPSG:900913",cb1); var testPt = new Proj4js.Point([1113194.9079327357, 6800125.454397307]); var testRes = Proj4js.transform(src, dest, testPt); alert(testRes.toString()); */ /* //testing the conversion bewteen CSs which use the towgs84 params (ticket #64) //TODO convert this to asserts src = new Proj4js.Proj("EPSG:21781"); dest = new Proj4js.Proj("EPSG:900913"); var testPt = new Proj4js.Point([699212,227132]); var testRes = Proj4js.transform(src, dest, testPt); alert(testRes.toString()); //result should be 973791.60867,5972764.60117 */ for (var i=0; i < Proj4js.testPoints.length; ++i) { var test = Proj4js.testPoints[i]; var proj = new Proj4js.Proj(test.code, Proj4js.bind(showResults, this, test)); } } function cb1() { dest = new Proj4js.Proj("EPSG:2303X",cb2); } function cb2(arg1) { //alert('all set'); } /* a callback function to run the test for this test point since we are using the dynamic load capabilities in the test page */ function showResults(test, proj) { //var test = proj.testPoint; var xyEPSLN = 1.0e-2; var llEPSLN = 1.0e-6; var row = document.createElement('tr'); var td = document.createElement('td'); td.innerHTML = test.code; row.appendChild(td); var td = document.createElement('td'); td.innerHTML = proj.projName; row.appendChild(td); //transform from lon/lat to projected x/y and cmopare var xyResult = Proj4js.transform(Proj4js.WGS84, proj, new Proj4js.Point(test.ll)); if (xyResult) { var deltaX = Math.abs(xyResult.x - test.xy[0]); var deltaY = Math.abs(xyResult.y - test.xy[1]); td = document.createElement('td'); td.innerHTML = "in:"+test.ll[0]+","+test.ll[1]; row.appendChild(td); td = document.createElement('td'); td.innerHTML = "out:"+xyResult.x+","+xyResult.y; row.appendChild(td); td = document.createElement('td'); td.innerHTML = "dx:"+deltaX+ " dy:"+deltaY; if ( deltaX>xyEPSLN || deltaY>xyEPSLN ) td.style.backgroundColor='red'; row.appendChild(td); } else { td = document.createElement('td'); td.innerHTML = "proj undefined"; row.appendChild(td); } //transform from map x/y to lon/lat and compare var llResult = Proj4js.transform(proj, Proj4js.WGS84, new Proj4js.Point(test.xy)); if (llResult) { var deltaX = Math.abs(llResult.x - test.ll[0]); var deltaY = Math.abs(llResult.y - test.ll[1]); td = document.createElement('td'); td.innerHTML = "in:"+test.xy[0]+","+test.xy[1]; row.appendChild(td); td = document.createElement('td'); td.innerHTML = "out:"+llResult.x+","+llResult.y; row.appendChild(td); td = document.createElement('td'); td.innerHTML = "dx:"+deltaX+ " dy:"+deltaY; if ( deltaX>llEPSLN || deltaY>llEPSLN ) td.style.backgroundColor='red'; row.appendChild(td); } else { td = document.createElement('td'); td.innerHTML = "proj undefined"; row.appendChild(td); } var testTable = document.getElementById('testResult'); testTable.tBodies[0].appendChild(row); };
test/test.js +61 −5 Original line number Diff line number Diff line Loading @@ -2,23 +2,79 @@ var xyEPSLN = 1.0e-2; var llEPSLN = 1.0e-6; describe('Proj4js', function () { describe('core',function(){ testPoints.forEach(function(testPoint){ it('should work with forwards ' + testPoint.code, function () { var proj = new Proj4js.Proj(testPoint.code); var xy = Proj4js.transform(Proj4js.WGS84, proj, new Proj4js.Point(testPoint.ll)); console.log(xy.x, testPoint.xy[0]); console.log(xy.y, testPoint.xy[1]); assert.closeTo(xy.x, testPoint.xy[0],xyEPSLN, 'x is close'); assert.closeTo(xy.y, testPoint.xy[1],xyEPSLN, 'y is close'); }); it('should work with backwards ' + testPoint.code, function () { var proj = new Proj4js.Proj(testPoint.code); var ll = Proj4js.transform(proj,Proj4js.WGS84, new Proj4js.Point(testPoint.xy)); console.log(ll.x, testPoint.ll[0]); console.log(ll.y, testPoint.ll[1]); assert.closeTo(ll.x, testPoint.ll[0],llEPSLN, 'lng is close'); assert.closeTo(ll.y, testPoint.ll[1],llEPSLN, 'lat is close'); }); }); }); describe('errors',function(){ it('should throw an error for an unknown ref',function(){ assert.throws(function(){ new Proj4js.Proj('EPSG:23030'); },'unknown projection','should work'); }); }) describe('utility',function(){ it('should have MGRS available in the Proj4js.util namespace',function(){ assert.typeOf(Proj4js.util.MGRS, "object", "MGRS available in the Proj4js.util namespace"); }); it('should have fromMGRS method added to Proj4js.Point prototype',function(){ assert.typeOf(Proj4js.Point.fromMGRS, "function", "fromMGRS method added to Proj4js.Point prototype"); }); it('should have toMGRS method added to Proj4js.Point prototype',function(){ assert.typeOf(Proj4js.Point.prototype.toMGRS, "function", "toMGRS method added to Proj4js.Point prototype"); }); describe('First MGRS set',function(){ var mgrs = "33UXP04"; var point = Proj4js.Point.fromMGRS(mgrs); it('Longitude of point from MGRS correct.',function(){ assert.equal(point.x.toPrecision(7), "16.41450", "Longitude of point from MGRS correct."); }); it('Latitude of point from MGRS correct.',function(){ assert.equal(point.y.toPrecision(7), "48.24949", "Latitude of point from MGRS correct."); }); it('MGRS reference with highest accuracy correct.',function(){ assert.equal(point.toMGRS(), "33UXP0500444998", "MGRS reference with highest accuracy correct."); }); it('MGRS reference with 1-digit accuracy correct.',function(){ assert.equal(point.toMGRS(1), mgrs, "MGRS reference with 1-digit accuracy correct."); }); }); describe('Second MGRS set',function(){ var mgrs = "24XWT783908"; // near UTM zone border, so there are two ways to reference this var point = Proj4js.Point.fromMGRS(mgrs); it("Longitude of point from MGRS correct.",function(){ assert.equal(point.x.toPrecision(7), "-32.66433", "Longitude of point from MGRS correct."); }); it("Latitude of point from MGRS correct.",function(){ assert.equal(point.y.toPrecision(7), "83.62778", "Latitude of point from MGRS correct."); }); it("MGRS reference with 3-digit accuracy correct.",function(){ assert.equal(point.toMGRS(3), "25XEN041865", "MGRS reference with 3-digit accuracy correct."); }); }) }); describe('wkt',function(){ aWKT.forEach(function(wkt){ it('should work with '+wkt.name,function(){ var testProj = new Proj4js.Proj(wkt.wkt); assert.equal(testProj.srsCode,wkt.name,'correct name'); assert.equal(testProj.units,wkt.units,'correct units'); assert.equal(testProj.projName,wkt.proj,'correct type') }); }); }); }); No newline at end of file