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