1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-17 13:25:22 +03:00

Add status check

This commit is contained in:
breadoven 2021-10-02 10:55:17 +01:00
parent e94317eb5b
commit 6877aea6ae
2 changed files with 13 additions and 10 deletions

View file

@ -137,7 +137,7 @@ let Waypoint = function (number, action, lat, lon, alt=0, p1=0, p2=0, p3=0, endM
}; };
self.getElevation = async function (globalSettings) { self.getElevation = async function (globalSettings) {
let elevation; let elevation = "N/A";
if (globalSettings.mapProviderType == 'bing') { if (globalSettings.mapProviderType == 'bing') {
let elevationEarthModel = $('#elevationEarthModel').prop("checked") ? "sealevel" : "ellipsoid"; let elevationEarthModel = $('#elevationEarthModel').prop("checked") ? "sealevel" : "ellipsoid";
@ -148,9 +148,8 @@ let Waypoint = function (number, action, lat, lon, alt=0, p1=0, p2=0, p3=0, endM
else { else {
const response = await fetch('https://api.opentopodata.org/v1/aster30m?locations='+self.getLatMap()+','+self.getLonMap()); const response = await fetch('https://api.opentopodata.org/v1/aster30m?locations='+self.getLatMap()+','+self.getLonMap());
const myJson = await response.json(); const myJson = await response.json();
elevation = myJson.results[0].elevation; if (myJson.status == "OK" && myJson.results[0].elevation != null) {
if (elevation == null) { elevation = myJson.results[0].elevation;
elevation = "N/A";
} }
} }
return elevation; return elevation;

View file

@ -435,6 +435,7 @@ let WaypointCollection = function () {
samples = sampleMaxNum; samples = sampleMaxNum;
} }
let elevation = "N/A";
if (globalSettings.mapProviderType == 'bing') { if (globalSettings.mapProviderType == 'bing') {
let elevationEarthModel = $('#elevationEarthModel').prop("checked") ? "sealevel" : "ellipsoid"; let elevationEarthModel = $('#elevationEarthModel').prop("checked") ? "sealevel" : "ellipsoid";
@ -456,12 +457,15 @@ let WaypointCollection = function () {
}); });
const response = await fetch('https://api.opentopodata.org/v1/aster30m?locations='+coordList+'&samples='+String(samples+1)); const response = await fetch('https://api.opentopodata.org/v1/aster30m?locations='+coordList+'&samples='+String(samples+1));
const myJson = await response.json(); const myJson = await response.json();
var elevation = [];
for (var i = 0; i < myJson.results.length; i++){ if (myJson.status == "OK") {
if (myJson.results[i].elevation == null) { elevation = [];
elevation[i] = 0; for (var i = 0; i < myJson.results.length; i++){
} else { if (myJson.results[i].elevation == null) {
elevation[i] = myJson.results[i].elevation; elevation[i] = 0;
} else {
elevation[i] = myJson.results[i].elevation;
}
} }
} }
} }