index.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3. <head>
  4. <title>Proj4js</title>
  5. <style type="text/css">
  6. @import url(test/base.css);
  7. #descSource, #descDest {
  8. font-style: italic;
  9. color: #999;
  10. }
  11. #xySource, #xyDest {
  12. width: 100%;
  13. }
  14. </style>
  15. <script src="lib/proj4js.js"></script>
  16. <script src="lib/defs/EPSG27200.js"></script>
  17. <script src="lib/defs/EPSG4272.js"></script>
  18. <script src="lib/defs/EPSG54009.js"></script>
  19. <script src="lib/defs/EPSG42304.js"></script>
  20. <script src="lib/defs/EPSG25833.js"></script>
  21. <script src="lib/defs/EPSG27563.js"></script>
  22. <script src="lib/defs/EPSG4139.js"></script>
  23. <script src="lib/defs/EPSG4302.js"></script>
  24. <script src="lib/defs/EPSG31285.js"></script>
  25. <script src="lib/defs/EPSG900913.js"></script>
  26. <script type="text/javascript">
  27. var projHash = {};
  28. function initProj4js() {
  29. var crsSource = document.getElementById('crsSource');
  30. var crsDest = document.getElementById('crsDest');
  31. var optIndex = 0;
  32. for (var def in Proj4js.defs) {
  33. projHash[def] = new Proj4js.Proj(def); //create a Proj for each definition
  34. var label = def+" - "+ (projHash[def].title ? projHash[def].title : '');
  35. var opt = new Option(label, def);
  36. crsSource.options[optIndex]= opt;
  37. var opt = new Option(label, def);
  38. crsDest.options[optIndex]= opt;
  39. ++optIndex;
  40. } // for
  41. updateCrs('Source');
  42. updateCrs('Dest');
  43. }
  44. function updateCrs(id) {
  45. var crs = document.getElementById('crs'+id);
  46. if (crs.value) {
  47. var proj = projHash[crs.value];
  48. var str = 'projection: ' + proj.projName + ' - datum: ' + proj.datumName;
  49. var desc = document.getElementById('desc'+id);
  50. desc.innerHTML = str;
  51. var units = document.getElementById('units'+id);
  52. units.innerHTML = proj.units;
  53. }
  54. }
  55. function transform() {
  56. var crsSource = document.getElementById('crsSource');
  57. var projSource = null;
  58. if (crsSource.value) {
  59. projSource = projHash[crsSource.value];
  60. } else {
  61. alert("Select a source coordinate system");
  62. return;
  63. }
  64. var crsDest = document.getElementById('crsDest');
  65. var projDest = null;
  66. if (crsDest.value) {
  67. projDest = projHash[crsDest.value];
  68. } else {
  69. alert("Select a destination coordinate system");
  70. return;
  71. }
  72. var pointInput = document.getElementById('xySource');
  73. if (pointInput.value) {
  74. var pointSource = new Proj4js.Point(pointInput.value);
  75. var pointDest = Proj4js.transform(projSource, projDest, pointSource);
  76. document.getElementById('xyDest').value = pointDest.toShortString();
  77. } else {
  78. alert("Enter source coordinates");
  79. return;
  80. }
  81. }
  82. </script>
  83. </head>
  84. <body onload="initProj4js()">
  85. <div id="header">
  86. <h1>Proj4js Home Page</h1>
  87. </div>
  88. <div id="navbar">
  89. <a href="http://trac.osgeo.org/proj4js">Proj4js Wiki/Trac</a> |
  90. <a href="http://wiki.osgeo.org/wiki/MetaCRS">OSGeo MetaCRS</a> |
  91. <a href="http://spatialreference.org/">spatialreference.org</a> |
  92. <a href="http://communitymapbuilder.org/">MapBuilder</a> |
  93. <a href="http://openlayers.org/">OpenLayers</a> |
  94. </div>
  95. <h1>Welcome to Proj4js</h1>
  96. <p>
  97. This is a JavaScript library that provides methods for coordinate
  98. transformations between map projections and longitude/latitude,
  99. including datum transformations, in a web client.
  100. </p>
  101. <p>
  102. To use the Proj4js, you first create a source and destination Proj4js.Proj
  103. objects, passing in a projection code (e.g. EPSG:4326).
  104. You can then use the Proj4js.transform() method, passing in map XY as a point
  105. object and the source and destination projection objects,
  106. and it returns the point coordinate in the destination projection.
  107. </p>
  108. <form>
  109. <table>
  110. <tbody>
  111. <tr>
  112. <th colspan="3">source</th>
  113. <th></th>
  114. <th colspan="3">dest</th>
  115. </tr>
  116. <tr>
  117. <td>CRS:</td>
  118. <td colspan="2">
  119. <select name="crsSource" id="crsSource" onchange="updateCrs('Source')">
  120. <option value selected="selected">Select a CRS</option>
  121. </select>
  122. </td>
  123. <td></td>
  124. <td>CRS:</td>
  125. <td colspan="2">
  126. <select name="crsDest" id="crsDest" onchange="updateCrs('Dest')">
  127. <option value selected="selected">Select a CRS</option>
  128. </select>
  129. </td>
  130. </tr>
  131. <tr>
  132. <td></td>
  133. <td colspan="2" id="descSource">Projection - datum</td>
  134. <td></td>
  135. <td></td>
  136. <td colspan="2" id="descDest">Projection - datum</td>
  137. </tr>
  138. <tr>
  139. <td>x,y</td>
  140. <td><input name="xySource" id="xySource" type="text"/></td>
  141. <td id="unitsSource">units</td>
  142. <td><input type="button" value="--> transform -->" onclick="transform();"/></td>
  143. <td>x,y</td>
  144. <td><input name="xyDest" id="xyDest" type="text"></td>
  145. <td id="unitsDest">units</td>
  146. </tr>
  147. <tr>
  148. <td colspan="7" align="center"><input type="reset" value="reset"/></td>
  149. </tr>
  150. </tbody>
  151. </table>
  152. </form>
  153. <p>
  154. For more information on Proj4js and to report bugs, please visit the
  155. <a href="http://trac.osgeo.org/proj4js">Proj4js Trac and Wiki</a> at OSGeo.
  156. </p>
  157. </body>
  158. </html>