mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-24 00:35:20 +03:00
Merge branch 'master' into change-profiles-with-programmin
This commit is contained in:
commit
03e569dd7c
11 changed files with 204 additions and 213 deletions
|
@ -77,6 +77,10 @@ helper.defaultsDialog = (function () {
|
|||
key: "setpoint_kalman_q",
|
||||
value: 200
|
||||
},
|
||||
{
|
||||
key: "smith_predictor_delay", // Enable Smith Predictor
|
||||
value: 1.5
|
||||
},
|
||||
/*
|
||||
Mechanics
|
||||
*/
|
||||
|
|
|
@ -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) {
|
||||
let elevation;
|
||||
let elevation = "N/A";
|
||||
if (globalSettings.mapProviderType == 'bing') {
|
||||
let elevationEarthModel = $('#elevationEarthModel').prop("checked") ? "sealevel" : "ellipsoid";
|
||||
|
||||
|
@ -146,7 +146,11 @@ let Waypoint = function (number, action, lat, lon, alt=0, p1=0, p2=0, p3=0, endM
|
|||
elevation = myJson.resourceSets[0].resources[0].elevations[0];
|
||||
}
|
||||
else {
|
||||
elevation = "N/A";
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ let WaypointCollection = function () {
|
|||
};
|
||||
|
||||
self.isEmpty = function () {
|
||||
return data == [];
|
||||
return data.length == 0;
|
||||
};
|
||||
|
||||
self.flush = function () {
|
||||
|
@ -414,15 +414,28 @@ let WaypointCollection = function () {
|
|||
let lengthMission = self.getDistance(true);
|
||||
let totalMissionDistance = lengthMission[lengthMission.length -1].toFixed(1);
|
||||
let samples;
|
||||
let sampleMaxNum;
|
||||
let sampleDistance;
|
||||
|
||||
if (globalSettings.mapProviderType == 'bing') {
|
||||
sampleMaxNum = 1024;
|
||||
sampleDistance = 30;
|
||||
} else { // use opentopodata.org instead
|
||||
sampleMaxNum = 99;
|
||||
sampleDistance = 60;
|
||||
}
|
||||
|
||||
if (point2measure.length <= 2){
|
||||
samples = 1;
|
||||
}
|
||||
else if (Math.trunc(totalMissionDistance/30) <= 1024 && point2measure.length > 2){
|
||||
samples = Math.trunc(totalMissionDistance/30);
|
||||
else if (Math.trunc(totalMissionDistance / sampleDistance) <= sampleMaxNum && point2measure.length > 2){
|
||||
samples = Math.trunc(totalMissionDistance / sampleDistance);
|
||||
}
|
||||
else {
|
||||
samples = 1024;
|
||||
samples = sampleMaxNum;
|
||||
}
|
||||
|
||||
let elevation = "N/A";
|
||||
if (globalSettings.mapProviderType == 'bing') {
|
||||
let elevationEarthModel = $('#elevationEarthModel').prop("checked") ? "sealevel" : "ellipsoid";
|
||||
|
||||
|
@ -438,7 +451,23 @@ let WaypointCollection = function () {
|
|||
}
|
||||
}
|
||||
else {
|
||||
elevation = "N/A";
|
||||
let coordList = "";
|
||||
point2measure.forEach(function (item) {
|
||||
coordList += item + '|';
|
||||
});
|
||||
const response = await fetch('https://api.opentopodata.org/v1/aster30m?locations='+coordList+'&samples='+String(samples+1));
|
||||
const myJson = await response.json();
|
||||
|
||||
if (myJson.status == "OK") {
|
||||
elevation = [];
|
||||
for (var i = 0; i < myJson.results.length; i++){
|
||||
if (myJson.results[i].elevation == null) {
|
||||
elevation[i] = 0;
|
||||
} else {
|
||||
elevation[i] = myJson.results[i].elevation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//console.log("elevation ", elevation);
|
||||
return [lengthMission, totalMissionDistance, samples, elevation, altPoint2measure, namePoint2measure, refPoint2measure];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue