index.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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>CUSTOM FIRMWARE BUILDER</p>
  44. <p>Multiple generated files can be combined on the SD card.</p>
  45. <p>Compatible with Ardupilot Plane 4.0.6+ and Copter 4.0.4+</p>
  46. <p>To download entire continents of terrain data, see <a href=https://terrain.ardupilot.org/data/continents/>here<a>.</p>
  47. <h2>Terrain Options</h2>
  48. <form action="/generate" method="post">
  49. <label for="lat">Centre Latitude:</label><br>
  50. <input type="text" id="lat" name="lat" value="-35.363261" oninput="plotCircleCoords(true);"><br>
  51. <label for="long">Centre Longitude:</label><br>
  52. <input type="text" id="long" name="long" value="149.165230" oninput="plotCircleCoords(true);"><br>
  53. <label id="radius-label" for="radius">Radius (km):</label><br>
  54. <input type="range" id="radius" name="radius" value="100" min="1" max="400"
  55. oninput="plotCircleCoords(false);"><br>
  56. <br>
  57. <input type="submit" value="Generate" method="post">
  58. </form>
  59. </div>
  60. <div class="wrapper">
  61. <div id="mapid" style="position: absolute;height: 100%;"></div>
  62. </div>
  63. </body>
  64. <br />
  65. <script>
  66. var circle;
  67. var mymap = L.map('mapid').setView([51.505, -0.09], 5);
  68. L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
  69. attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
  70. }).addTo(mymap);
  71. mymap.on('click', function (e) {
  72. document.getElementById("lat").value = Math.max(-60, Math.min(60, e.latlng.lat))
  73. var longitude = e.latlng.lng
  74. // leaflet allows infinite longitudes, this wraps it to [-180, 180]
  75. while (longitude > 180) {
  76. longitude -= 360
  77. }
  78. while (longitude < -180) {
  79. longitude += 360
  80. }
  81. document.getElementById("long").value = longitude
  82. plotCircleCoords(true)
  83. });
  84. function plotCircleCoords(center) {
  85. if (circle !== undefined) {
  86. circle.removeFrom(mymap)
  87. }
  88. var lat = document.getElementById("lat").value
  89. var lon = document.getElementById("long").value
  90. var distance = document.getElementById("radius").value;
  91. document.getElementById("radius-label").innerText = "Radius (" + distance + " km):"
  92. circle = circle = L.circle([lat, lon], {
  93. color: 'red',
  94. fillColor: '#f03',
  95. fillOpacity: 0.5,
  96. radius: distance * 1000
  97. }).addTo(mymap);
  98. if (center) {
  99. mymap.setView([lat, lon])
  100. }
  101. }
  102. plotCircleCoords(true)
  103. </script>
  104. <footer>Created by Stephen Dade, <a href=https://github.com/stephendade/terraingen>Source Code<a>.</footer>