mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-26 01:35:23 +03:00
MP version 1.0
This commit is contained in:
parent
b0933b4c71
commit
162beea970
4 changed files with 145 additions and 49 deletions
|
@ -331,6 +331,57 @@ let WaypointCollection = function () {
|
|||
});
|
||||
return poiList;
|
||||
}
|
||||
|
||||
self.getDistance = function() {
|
||||
let point2measure = []
|
||||
let lengthLine = []
|
||||
let nStart = 0;
|
||||
let nLoop = 0;
|
||||
let n = 0 ;
|
||||
let startCount = true;
|
||||
while (startCount && (nLoop!=-1)) {
|
||||
if (nStart > data[data.length -1].getNumber()) {
|
||||
startCount = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if ([MWNP.WPTYPE.WAYPOINT,MWNP.WPTYPE.POSHOLD_TIME,MWNP.WPTYPE.LAND].includes(self.getWaypoint(nStart).getAction())) {
|
||||
point2measure.push(ol.proj.fromLonLat([self.getWaypoint(nStart).getLonMap(), self.getWaypoint(nStart).getLatMap()]));
|
||||
nStart++;
|
||||
}
|
||||
else if (self.getWaypoint(nStart).getAction() == MWNP.WPTYPE.JUMP) {
|
||||
if ((n>=nLoop && nLoop != 0) || self.getWaypoint(nStart).getP2() == 0) {
|
||||
nStart++;
|
||||
n = 0;
|
||||
}
|
||||
else {
|
||||
nLoop = self.getWaypoint(nStart).getP2();
|
||||
nStart = self.getWaypoint(nStart).getP1();
|
||||
n++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
nStart++;
|
||||
}
|
||||
}
|
||||
if (nLoop == -1) {
|
||||
return [-1];
|
||||
}
|
||||
else {
|
||||
|
||||
const cumulativeSum = (sum => value => sum += value)(0);
|
||||
|
||||
let oldCoord = [];
|
||||
point2measure.forEach(function (coord) {
|
||||
if (oldCoord != 'undefined' && oldCoord != []) {
|
||||
lengthLine.push(ol.Sphere.getLength(new ol.geom.LineString([oldCoord, coord])));
|
||||
}
|
||||
oldCoord = coord;
|
||||
});
|
||||
console.log("lengthLine ", lengthLine);
|
||||
return lengthLine.map(cumulativeSum);
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue