[76] | 1 | /* Loop through the test points and create a Proj object for each |
---|
| 2 | */ |
---|
| 3 | var src, dest; |
---|
| 4 | function runTests() { |
---|
| 5 | |
---|
| 6 | //src = new Proj4js.Proj(Proj4js.defs["WKT0"],cb2); |
---|
| 7 | /* |
---|
| 8 | src = new Proj4js.Proj("EPSG:900913",cb1); |
---|
| 9 | var testPt = new Proj4js.Point([1113194.9079327357, 6800125.454397307]); |
---|
| 10 | var testRes = Proj4js.transform(src, dest, testPt); |
---|
| 11 | alert(testRes.toString()); |
---|
| 12 | */ |
---|
| 13 | |
---|
| 14 | for (var i=0; i < Proj4js.testPoints.length; ++i) { |
---|
| 15 | var test = Proj4js.testPoints[i]; |
---|
| 16 | var proj = new Proj4js.Proj(test.code, Proj4js.bind(showResults, this, test)); |
---|
| 17 | } |
---|
| 18 | } |
---|
| 19 | function cb1() { |
---|
| 20 | dest = new Proj4js.Proj("EPSG:2303X",cb2); |
---|
| 21 | } |
---|
| 22 | function cb2(arg1) { |
---|
| 23 | //alert('all set'); |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | /* a callback function to run the test for this test point since we are using |
---|
| 27 | the dynamic load capabilities in the test page |
---|
| 28 | */ |
---|
| 29 | function showResults(test, proj) { |
---|
| 30 | //var test = proj.testPoint; |
---|
| 31 | var xyEPSLN = 1.0e-2; |
---|
| 32 | var llEPSLN = 1.0e-6; |
---|
| 33 | var row = document.createElement('tr'); |
---|
| 34 | var td = document.createElement('td'); |
---|
| 35 | td.innerHTML = test.code; |
---|
| 36 | row.appendChild(td); |
---|
| 37 | var td = document.createElement('td'); |
---|
| 38 | td.innerHTML = proj.projName; |
---|
| 39 | row.appendChild(td); |
---|
| 40 | |
---|
| 41 | //transform from lon/lat to projected x/y and cmopare |
---|
| 42 | var xyResult = Proj4js.transform(Proj4js.WGS84, proj, new Proj4js.Point(test.ll)); |
---|
| 43 | if (xyResult) { |
---|
| 44 | var deltaX = Math.abs(xyResult.x - test.xy[0]); |
---|
| 45 | var deltaY = Math.abs(xyResult.y - test.xy[1]); |
---|
| 46 | td = document.createElement('td'); |
---|
| 47 | td.innerHTML = "in:"+test.ll[0]+","+test.ll[1]; |
---|
| 48 | row.appendChild(td); |
---|
| 49 | td = document.createElement('td'); |
---|
| 50 | td.innerHTML = "out:"+xyResult.x+","+xyResult.y; |
---|
| 51 | row.appendChild(td); |
---|
| 52 | td = document.createElement('td'); |
---|
| 53 | td.innerHTML = "dx:"+deltaX+ " dy:"+deltaY; |
---|
| 54 | if ( deltaX>xyEPSLN || deltaY>xyEPSLN ) td.style.backgroundColor='red'; |
---|
| 55 | row.appendChild(td); |
---|
| 56 | } else { |
---|
| 57 | td = document.createElement('td'); |
---|
| 58 | td.innerHTML = "proj undefined"; |
---|
| 59 | row.appendChild(td); |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | //transform from map x/y to lon/lat and compare |
---|
| 63 | var llResult = Proj4js.transform(proj, Proj4js.WGS84, new Proj4js.Point(test.xy)); |
---|
| 64 | if (llResult) { |
---|
| 65 | var deltaX = Math.abs(llResult.x - test.ll[0]); |
---|
| 66 | var deltaY = Math.abs(llResult.y - test.ll[1]); |
---|
| 67 | td = document.createElement('td'); |
---|
| 68 | td.innerHTML = "in:"+test.xy[0]+","+test.xy[1]; |
---|
| 69 | row.appendChild(td); |
---|
| 70 | td = document.createElement('td'); |
---|
| 71 | td.innerHTML = "out:"+llResult.x+","+llResult.y; |
---|
| 72 | row.appendChild(td); |
---|
| 73 | td = document.createElement('td'); |
---|
| 74 | td.innerHTML = "dx:"+deltaX+ " dy:"+deltaY; |
---|
| 75 | if ( deltaX>llEPSLN || deltaY>llEPSLN ) td.style.backgroundColor='red'; |
---|
| 76 | row.appendChild(td); |
---|
| 77 | } else { |
---|
| 78 | td = document.createElement('td'); |
---|
| 79 | td.innerHTML = "proj undefined"; |
---|
| 80 | row.appendChild(td); |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | var testTable = document.getElementById('testResult'); |
---|
| 84 | testTable.tBodies[0].appendChild(row); |
---|
| 85 | }; |
---|
| 86 | |
---|