You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
inav-configurator/js/waypoint.js

159 lines
3.4 KiB
JavaScript

4 years ago
/*global $*/
'use strict';
let Waypoint = function (number, action, lat, lon, alt=0, p1=0, p2=0, p3=0, endMission=0, isUsed=true, isAttached=false, attachedId="") {
4 years ago
var self = {};
let layerNumber = "undefined";
let attachedNumber = "undefined";
let poiNumber = "undefined";
4 years ago
self.getNumber = function () {
return number;
};
self.setNumber = function (data) {
number = data;
};
3 years ago
self.getLayerNumber = function () {
return layerNumber;
};
self.setLayerNumber = function (data) {
layerNumber = data;
};
3 years ago
self.getPoiNumber = function () {
return poiNumber;
};
self.setPoiNumber = function (data) {
poiNumber = data;
};
3 years ago
4 years ago
self.isUsed = function () {
return isUsed;
};
self.setUsed = function (data) {
isUsed = data;
};
3 years ago
self.isAttached = function () {
return isAttached;
};
self.setAttached = function (data) {
isAttached = data;
};
4 years ago
self.getLon = function () {
return lon;
};
3 years ago
self.getLonMap = function () {
return lon / 10000000;
};
4 years ago
self.setLon = function (data) {
lon = data;
};
self.getLat = function () {
return lat;
};
3 years ago
self.getLatMap = function () {
return lat / 10000000;
};
4 years ago
self.setLat = function (data) {
lat = data;
};
3 years ago
4 years ago
self.getAction = function () {
return action;
};
3 years ago
4 years ago
self.setAction = function (data) {
action = data;
};
3 years ago
4 years ago
self.getAlt = function () {
return alt;
};
3 years ago
4 years ago
self.setAlt = function (data) {
alt = data;
};
3 years ago
4 years ago
self.getP1 = function () {
return p1;
};
3 years ago
4 years ago
self.setP1 = function (data) {
p1 = data;
};
3 years ago
4 years ago
self.getP2 = function () {
return p2;
};
3 years ago
4 years ago
self.setP2 = function (data) {
p2 = data;
};
3 years ago
4 years ago
self.getP3 = function () {
return p3;
};
3 years ago
4 years ago
self.setP3 = function (data) {
p3 = data;
};
3 years ago
4 years ago
self.getEndMission = function () {
return endMission;
};
3 years ago
4 years ago
self.setEndMission = function (data) {
endMission = data;
};
3 years ago
self.getAttachedId = function () {
return attachedId;
};
self.setAttachedId = function (data) {
attachedId = data;
};
3 years ago
self.getAttachedNumber = function () {
return attachedNumber;
};
self.setAttachedNumber = function (data) {
attachedNumber = data;
};
3 years ago
3 years ago
self.getElevation = async function (globalSettings) {
3 years ago
let elevation = "N/A";
3 years ago
if (globalSettings.mapProviderType == 'bing') {
let elevationEarthModel = $('#elevationEarthModel').prop("checked") ? "sealevel" : "ellipsoid";
3 years ago
const response = await fetch('http://dev.virtualearth.net/REST/v1/Elevation/List?points='+self.getLatMap()+','+self.getLonMap()+'&heights='+elevationEarthModel+'&key='+globalSettings.mapApiKey);
3 years ago
const myJson = await response.json();
3 years ago
elevation = myJson.resourceSets[0].resources[0].elevations[0];
}
else {
3 years ago
const response = await fetch('https://api.opentopodata.org/v1/aster30m?locations='+self.getLatMap()+','+self.getLonMap());
const myJson = await response.json();
3 years ago
if (myJson.status == "OK" && myJson.results[0].elevation != null) {
elevation = myJson.results[0].elevation;
3 years ago
}
3 years ago
}
return elevation;
}
4 years ago
return self;
};