diff --git a/js/geozone.js b/js/geozone.js index f2b8a80dd..ee6e90d04 100644 --- a/js/geozone.js +++ b/js/geozone.js @@ -55,7 +55,7 @@ let GeozoneVertex = function (number, lat, lon) { return self; } -let Geozone = function (type, shape, minAltitude, maxAltitude, radius, fenceAction, vertices, number = 0) { +let Geozone = function (type, shape, minAltitude, maxAltitude, sealevelRef, radius, fenceAction, vertices, number = 0) { var self = {}; self.setNumber = (data) => { @@ -98,6 +98,14 @@ let Geozone = function (type, shape, minAltitude, maxAltitude, radius, fenceActi return maxAltitude; } + self.setSealevelRef = (data) => { + sealevelRef = data; + } + + self.getSealevelRef = () => { + return sealevelRef; + } + self.setRadius = (data) => { radius = data; } @@ -168,6 +176,27 @@ let Geozone = function (type, shape, minAltitude, maxAltitude, radius, fenceActi vertices = []; } + self.getElevationFromServer = async function (lon, lat, globalSettings) { + let elevation = "N/A"; + if (globalSettings.mapProviderType == 'bing') { + let elevationEarthModel = $('#elevationEarthModel').prop("checked") ? "ellipsoid" : "sealevel"; + + const response = await fetch('http://dev.virtualearth.net/REST/v1/Elevation/List?points='+lat+','+lon+'&heights='+elevationEarthModel+'&key='+globalSettings.mapApiKey); + const myJson = await response.json(); + elevation = myJson.resourceSets[0].resources[0].elevations[0]; + } + else { + const response = await fetch('https://api.opentopodata.org/v1/aster30m?locations='+lat+','+lon); + const myJson = await response.json(); + if (myJson.status == "OK" && myJson.results[0].elevation != null) { + elevation = myJson.results[0].elevation; + } + } + return elevation; + } + + return self; + return self; } diff --git a/js/geozoneCollection.js b/js/geozoneCollection.js index e1ef668c0..66b5e666a 100644 --- a/js/geozoneCollection.js +++ b/js/geozoneCollection.js @@ -132,6 +132,7 @@ let GeozoneCollection = function() { buffer.push(BitHelper.specificByte(zone.getMaxAltitude(), 1)); buffer.push(BitHelper.specificByte(zone.getMaxAltitude(), 2)); buffer.push(BitHelper.specificByte(zone.getMaxAltitude(), 3)); + buffer.push(zone.getSealevelRef()); buffer.push(zone.getFenceAction()); if (zone.getShape() == GeozoneShapes.CIRCULAR) { buffer.push(2); diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 9a871958b..fa9d02ffd 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -1608,16 +1608,17 @@ var mspHelper = (function () { case MSPCodes.MSP2_INAV_GEOZONE: var geozone = new Geozone( - data.getUint8(0), data.getUint8(1), - data.getInt32(2, true), - data.getInt32(6, true), + data.getUint8(2), + data.getInt32(3, true), + data.getInt32(4, true), + data.getUint8(11), 0, - data.getInt8(10, true), + data.getInt8(12, true), null, - data.getUint8(12, true), + data.getUint8(14, true), ); - let verticesCount = data.getUint8(11, true); + let verticesCount = data.getUint8(13, true); if (verticesCount == 0) { break; } diff --git a/tabs/mission_control.html b/tabs/mission_control.html index d031c5a33..41341702b 100644 --- a/tabs/mission_control.html +++ b/tabs/mission_control.html @@ -335,12 +335,18 @@
+
+
+
+ + +