mirror of
https://github.com/30hours/blah2.git
synced 2024-11-08 12:25:42 +00:00
Add truth display to ddmap if enabled in config
This commit is contained in:
parent
0e16141eda
commit
db6d9656cf
2 changed files with 76 additions and 6 deletions
|
@ -69,6 +69,25 @@ app.get('/api/iqdata', (req, res) => {
|
|||
app.get('/api/config', (req, res) => {
|
||||
res.send(config);
|
||||
});
|
||||
app.get('/api/adsb2dd', (req, res) => {
|
||||
if (config.truth.adsb.enabled == true) {
|
||||
const api_url = "http://adsb2dd.30hours.dev/api/dd";
|
||||
const api_query =
|
||||
api_url +
|
||||
"?rx=" + config.location.rx.latitude + "," +
|
||||
config.location.rx.longitude + "," +
|
||||
config.location.rx.altitude +
|
||||
"&tx=" + config.location.tx.latitude + "," +
|
||||
config.location.tx.longitude + "," +
|
||||
config.location.tx.altitude +
|
||||
"&fc=" + (config.capture.fs / 1000000) +
|
||||
"&server=" + "http://" + config.truth.adsb.ip;
|
||||
res.send(api_query);
|
||||
}
|
||||
else {
|
||||
res.status(400).end();
|
||||
}
|
||||
});
|
||||
|
||||
// stash API
|
||||
app.get('/stash/map', (req, res) => {
|
||||
|
|
|
@ -8,6 +8,8 @@ var range_y = [];
|
|||
// setup API
|
||||
var urlTimestamp;
|
||||
var urlDetection;
|
||||
var urlAdsb;
|
||||
var urlConfig;
|
||||
if (isLocalHost) {
|
||||
urlTimestamp = '//' + host + ':3000/api/timestamp';
|
||||
} else {
|
||||
|
@ -23,10 +25,29 @@ if (isLocalHost) {
|
|||
} else {
|
||||
urlMap = '//' + host + urlMap;
|
||||
}
|
||||
if (isLocalHost) {
|
||||
urlAdsb = '//' + host + ':3000/api/adsb2dd';
|
||||
} else {
|
||||
urlAdsb = '//' + host + '/api/adsb2dd';
|
||||
}
|
||||
if (isLocalHost) {
|
||||
urlConfig = '//' + host + ':3000/api/config';
|
||||
} else {
|
||||
urlConfig = '//' + host + '/api/config';
|
||||
}
|
||||
urlTimestamp = urlTimestamp + '?timestamp=' + Date.now();
|
||||
urlDetection = urlDetection + '?timestamp=' + Date.now();
|
||||
urlMap = urlMap + '?timestamp=' + Date.now();
|
||||
|
||||
// get truth flag
|
||||
var isTruth = false;
|
||||
var configData = $.getJSON(urlConfig, function () { })
|
||||
.done(function (data_config) {
|
||||
if (data_config.truth.adsb.enabled === true) {
|
||||
isTruth = true;
|
||||
}
|
||||
});
|
||||
|
||||
// setup plotly
|
||||
var layout = {
|
||||
autosize: true,
|
||||
|
@ -65,7 +86,8 @@ var layout = {
|
|||
ticksuffix: ' ',
|
||||
autosize: false,
|
||||
categoryorder: "total descending"
|
||||
}
|
||||
},
|
||||
showlegend: false
|
||||
};
|
||||
var config = {
|
||||
responsive: true,
|
||||
|
@ -82,6 +104,7 @@ var data = [
|
|||
}
|
||||
];
|
||||
var detection = [];
|
||||
var adsb = {};
|
||||
|
||||
Plotly.newPlot('data', data, layout, config);
|
||||
|
||||
|
@ -101,6 +124,23 @@ var intervalId = window.setInterval(function () {
|
|||
detection = data_detection;
|
||||
});
|
||||
|
||||
// get ADS-B data if enabled in config
|
||||
if (isTruth) {
|
||||
var adsbData = $.getJSON(urlAdsb, function () { })
|
||||
.done(function (data_adsb) {
|
||||
adsb['delay'] = [];
|
||||
adsb['doppler'] = [];
|
||||
adsb['flight'] = [];
|
||||
for (const aircraft in data_adsb) {
|
||||
if ('doppler' in data_adsb[aircraft]) {
|
||||
adsb['delay'].push(data_adsb[aircraft]['delay'])
|
||||
adsb['doppler'].push(data_adsb[aircraft]['doppler'])
|
||||
adsb['flight'].push(data_adsb[aircraft]['flight'])
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// get new map data
|
||||
var apiData = $.getJSON(urlMap, function () { })
|
||||
.done(function (data) {
|
||||
|
@ -136,17 +176,28 @@ var intervalId = window.setInterval(function () {
|
|||
opacity: 0.6
|
||||
}
|
||||
};
|
||||
var trace3 = {
|
||||
x: adsb.delay,
|
||||
y: adsb.doppler,
|
||||
mode: 'markers',
|
||||
type: 'scatter',
|
||||
marker: {
|
||||
size: 16,
|
||||
opacity: 0.6
|
||||
}
|
||||
};
|
||||
|
||||
var data_trace = [trace1, trace2];
|
||||
var data_trace = [trace1, trace2, trace3];
|
||||
Plotly.newPlot('data', data_trace, layout, config);
|
||||
}
|
||||
// case update plot
|
||||
else {
|
||||
var trace_update = {
|
||||
x: [data.delay, detection.delay],
|
||||
y: [data.doppler, detection.doppler],
|
||||
z: [data.data, []],
|
||||
zmax: [Math.max(13, data.maxPower), []]
|
||||
x: [data.delay, detection.delay, adsb.delay],
|
||||
y: [data.doppler, detection.doppler, adsb.doppler],
|
||||
z: [data.data, [], []],
|
||||
zmax: [Math.max(13, data.maxPower), [], []],
|
||||
text: [[], [], adsb.flight]
|
||||
};
|
||||
Plotly.update('data', trace_update);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue