index.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <!doctype html>
  2. <head>
  3. <link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css"
  4. integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
  5. crossorigin="" />
  6. <!-- Make sure you put this AFTER Leaflet's CSS -->
  7. <script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"
  8. integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
  9. crossorigin=""></script>
  10. <style type="text/css">
  11. html,
  12. body {
  13. height: 100%;
  14. margin: 0;
  15. width: 100%
  16. }
  17. #wrapper {
  18. min-height: 100%;
  19. }
  20. #mapid {
  21. height: 100%;
  22. width: 100%;
  23. }
  24. #menu {
  25. position: absolute;
  26. z-index: 2000;
  27. width: 28%;
  28. background-color: azure;
  29. margin: 5px;
  30. margin-top: 7%;
  31. border-radius: 10px;
  32. padding: 10px;
  33. }
  34. #radius {
  35. width: 100%;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div id="menu">
  41. <title>ArduPilot Terrain Generator</title>
  42. <h1>ArduPilot Terrain Generator</h1>
  43. <p>Use this to generate terrain to put on your SD card. The generated terrain is based on the SRTM data and has
  44. 100m
  45. horizontal resolution. It covers all areas between 0 and 60 degrees North/South latitude.</p>
  46. <p>Multiple generated files can be combined on the SD card.</p>
  47. <p>Compatible with Ardupilot Plane 4.0.6+ and Copter 4.0.4+</p>
  48. <p>To download entire continents of terrain data, see <a href=https://terrain.ardupilot.org/data/continents/>here<a>.</p>
  49. <h2>Terrain Options</h2>
  50. <form action="/generate" method="post">
  51. <label for="lat">Centre Latitude:</label><br>
  52. <input type="text" id="lat" name="lat" value="-35.363261" oninput="plotCircleCoords(true);"><br>
  53. <label for="long">Centre Longitude:</label><br>
  54. <input type="text" id="long" name="long" value="149.165230" oninput="plotCircleCoords(true);"><br>
  55. <label id="radius-label" for="radius">Radius (km):</label><br>
  56. <input type="range" id="radius" name="radius" value="100" min="1" max="400"
  57. oninput="plotCircleCoords(false);"><br>
  58. <br>
  59. <input type="submit" value="Generate" method="post">
  60. </form>
  61. </div>
  62. <div class="wrapper">
  63. <div id="mapid" style="position: absolute;height: 100%;"></div>
  64. </div>
  65. </body>
  66. <br />
  67. <script>
  68. var circle;
  69. var mymap = L.map('mapid').setView([51.505, -0.09], 5);
  70. L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
  71. attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
  72. }).addTo(mymap);
  73. mymap.on('click', function (e) {
  74. document.getElementById("lat").value = Math.max(-60, Math.min(60, e.latlng.lat))
  75. var longitude = e.latlng.lng
  76. // leaflet allows infinite longitudes, this wraps it to [-180, 180]
  77. while (longitude > 180) {
  78. longitude -= 360
  79. }
  80. while (longitude < -180) {
  81. longitude += 360
  82. }
  83. document.getElementById("long").value = longitude
  84. plotCircleCoords(true)
  85. });
  86. function plotCircleCoords(center) {
  87. if (circle !== undefined) {
  88. circle.removeFrom(mymap)
  89. }
  90. var lat = document.getElementById("lat").value
  91. var lon = document.getElementById("long").value
  92. var distance = document.getElementById("radius").value;
  93. document.getElementById("radius-label").innerText = "Radius (" + distance + " km):"
  94. circle = circle = L.circle([lat, lon], {
  95. color: 'red',
  96. fillColor: '#f03',
  97. fillOpacity: 0.5,
  98. radius: distance * 1000
  99. }).addTo(mymap);
  100. if (center) {
  101. mymap.setView([lat, lon])
  102. }
  103. }
  104. plotCircleCoords(true)
  105. </script>
  106. <footer>Created by Stephen Dade, <a href=https://github.com/stephendade/terraingen>Source Code<a>.</footer>