mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-24 00:35:20 +03:00
Initial build
This commit is contained in:
parent
924c974473
commit
397e840e5a
2 changed files with 100 additions and 70 deletions
|
@ -144,7 +144,12 @@ 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 = "NA";
|
||||
const response = await fetch('https://api.opentopodata.org/v1/aster30m?locations='+self.getLatMap()+','+self.getLonMap());
|
||||
const myJson = await response.json();
|
||||
elevation = myJson.results[0].elevation;
|
||||
if (elevation == null) {
|
||||
elevation = "N/A";
|
||||
}
|
||||
}
|
||||
return elevation;
|
||||
}
|
||||
|
|
|
@ -414,15 +414,27 @@ 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;
|
||||
}
|
||||
|
||||
if (globalSettings.mapProviderType == 'bing') {
|
||||
if (point2measure.length >1) {
|
||||
const response = await fetch('http://dev.virtualearth.net/REST/v1/Elevation/Polyline?points='+point2measure+'&heights=ellipsoid&samples='+String(samples+1)+'&key='+globalSettings.mapApiKey);
|
||||
|
@ -436,7 +448,20 @@ let WaypointCollection = function () {
|
|||
}
|
||||
}
|
||||
else {
|
||||
elevation = "NA";
|
||||
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();
|
||||
var 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