mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-24 16:55:22 +03:00
MP version 1.7
This commit is contained in:
parent
63b548e3e0
commit
2fb3cacf9a
6 changed files with 270 additions and 31 deletions
|
@ -334,6 +334,9 @@ let WaypointCollection = function () {
|
|||
|
||||
self.getPoint2Measure = function(reverse=false) {
|
||||
let point2measure = [];
|
||||
let altPoint2measure = [];
|
||||
let namePoint2measure = [];
|
||||
let refPoint2measure = [];
|
||||
let jumpDict = {};
|
||||
let nStart = 0;
|
||||
let nLoop = 0;
|
||||
|
@ -352,6 +355,9 @@ let WaypointCollection = function () {
|
|||
else {
|
||||
point2measure.push(ol.proj.fromLonLat([self.getWaypoint(nStart).getLonMap(), self.getWaypoint(nStart).getLatMap()]));
|
||||
}
|
||||
altPoint2measure.push(self.getWaypoint(nStart).getAlt());
|
||||
namePoint2measure.push(self.getWaypoint(nStart).getLayerNumber()+1);
|
||||
refPoint2measure.push(self.getWaypoint(nStart).getP3());
|
||||
nStart++;
|
||||
}
|
||||
else if (self.getWaypoint(nStart).getAction() == MWNP.WPTYPE.JUMP) {
|
||||
|
@ -379,12 +385,12 @@ let WaypointCollection = function () {
|
|||
}
|
||||
}
|
||||
|
||||
return [nLoop, point2measure];
|
||||
return [nLoop, point2measure, altPoint2measure, namePoint2measure, refPoint2measure];
|
||||
}
|
||||
|
||||
self.getDistance = function(display) {
|
||||
let lengthLine = [];
|
||||
const [nLoop, point2measure] = self.getPoint2Measure();
|
||||
const [nLoop, point2measure, altPoint2measure, namePoint2measure, refPoint2measure] = self.getPoint2Measure();
|
||||
if (nLoop == -1 && display) {
|
||||
return [-1];
|
||||
}
|
||||
|
@ -405,16 +411,10 @@ let WaypointCollection = function () {
|
|||
}
|
||||
|
||||
self.getElevation = async function(globalSettings) {
|
||||
const [nLoop, point2measure] = self.getPoint2Measure(true);
|
||||
const [nLoop, point2measure, altPoint2measure, namePoint2measure, refPoint2measure] = self.getPoint2Measure(true);
|
||||
let lengthMission = self.getDistance(true);
|
||||
let totalMissionDistance = lengthMission[lengthMission.length -1].toFixed(1);
|
||||
//let point2measureMap = point2measure.map(function(x) { return x.map(function(y) {return y / 10000000})});
|
||||
console.log(totalMissionDistance/30);
|
||||
let samples = (Math.trunc(totalMissionDistance/30) <= 1024 ? Math.trunc(totalMissionDistance/30) : 1024);
|
||||
|
||||
console.log(samples);
|
||||
console.log(point2measure.toString());
|
||||
console.log('http://dev.virtualearth.net/REST/v1/Elevation/Polyline?points='+point2measure+'&heights=ellipsoid&samples='+String(samples)+'&key='+globalSettings.mapApiKey);
|
||||
if (globalSettings.mapProviderType == 'bing') {
|
||||
const response = await fetch('http://dev.virtualearth.net/REST/v1/Elevation/Polyline?points='+point2measure+'&heights=ellipsoid&samples='+String(samples)+'&key='+globalSettings.mapApiKey);
|
||||
const myJson = await response.json();
|
||||
|
@ -423,9 +423,7 @@ let WaypointCollection = function () {
|
|||
else {
|
||||
elevation = "NA";
|
||||
}
|
||||
console.log("getElevation");
|
||||
console.log(elevation);
|
||||
return elevation;
|
||||
return [lengthMission, totalMissionDistance, samples, elevation, altPoint2measure, namePoint2measure, refPoint2measure];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue