mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-23 16:25:19 +03:00
Add WP
This commit is contained in:
parent
23a6a01143
commit
4df66d0fc5
10 changed files with 473 additions and 197 deletions
|
@ -1,12 +1,8 @@
|
|||
/*global $*/
|
||||
'use strict';
|
||||
|
||||
const ApproachDirection = Object.freeze({
|
||||
LEFT: 0,
|
||||
RIGHT: 1,
|
||||
})
|
||||
|
||||
let Safehome = function (enabled, lat, lon, approachAltAsl = 0, landAltAsl = 0, approachDirection = 0, landHeading1 = 0, landHeading2 = 0, isSeaLevelRef = 0, elevation = 0, number = 0) {
|
||||
let Safehome = function (number, enabled, lat, lon) {
|
||||
|
||||
var self = {};
|
||||
|
||||
|
@ -53,63 +49,7 @@ let Safehome = function (enabled, lat, lon, approachAltAsl = 0, landAltAsl = 0,
|
|||
self.setEnabled = function (data) {
|
||||
enabled = data;
|
||||
};
|
||||
|
||||
self.getApproachAltAsl = function () {
|
||||
return approachAltAsl;
|
||||
}
|
||||
|
||||
self.setApproachAltAsl = function (data) {
|
||||
approachAltAsl = data;
|
||||
}
|
||||
|
||||
self.getLandAltAsl = function () {
|
||||
return landAltAsl;
|
||||
}
|
||||
|
||||
self.setLandAltAsl = function (data) {
|
||||
landAltAsl = data;
|
||||
}
|
||||
|
||||
self.getApproachDirection = function () {
|
||||
return approachDirection;
|
||||
}
|
||||
|
||||
self.setApproachDirection = function (data) {
|
||||
approachDirection = data;
|
||||
}
|
||||
|
||||
self.getLandHeading1 = function () {
|
||||
return landHeading1;
|
||||
}
|
||||
|
||||
self.setLandHeading1 = function (data) {
|
||||
landHeading1 = data;
|
||||
}
|
||||
|
||||
self.getLandHeading2 = function () {
|
||||
return landHeading2;
|
||||
}
|
||||
|
||||
self.setLandHeading2 = function (data) {
|
||||
landHeading2 = data;
|
||||
}
|
||||
|
||||
self.getIsSeaLevelRef = function () {
|
||||
return isSeaLevelRef;
|
||||
}
|
||||
|
||||
self.setIsSeaLevelRef = function (data) {
|
||||
isSeaLevelRef = data;
|
||||
}
|
||||
|
||||
self.getElevation = function() {
|
||||
return elevation;
|
||||
}
|
||||
|
||||
self.setElevation = function (data) {
|
||||
elevation = data;
|
||||
}
|
||||
|
||||
self.cleanup = function () {
|
||||
number = 0;
|
||||
enabled = 0;
|
||||
|
@ -117,24 +57,5 @@ let Safehome = function (enabled, lat, lon, approachAltAsl = 0, landAltAsl = 0,
|
|||
lat = 0;
|
||||
};
|
||||
|
||||
self.getElevationFromServer = async function (globalSettings) {
|
||||
let elevation = "N/A";
|
||||
if (globalSettings.mapProviderType == 'bing') {
|
||||
let elevationEarthModel = $('#elevationEarthModel').prop("checked") ? "sealevel" : "ellipsoid";
|
||||
|
||||
const response = await fetch('http://dev.virtualearth.net/REST/v1/Elevation/List?points='+self.getLatMap()+','+self.getLonMap()+'&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='+self.getLatMap()+','+self.getLonMap());
|
||||
const myJson = await response.json();
|
||||
if (myJson.status == "OK" && myJson.results[0].elevation != null) {
|
||||
elevation = myJson.results[0].elevation;
|
||||
}
|
||||
}
|
||||
return elevation;
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue