Compare commits
32 Commits
v.1
..
V.2.8.0-2.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 14d17b6b4d | |||
| b786943a84 | |||
| 7ad3ae0bb7 | |||
| 5aa6a8f117 | |||
| d6ef71482c | |||
| 4b5bc572c3 | |||
| 3f2ae14792 | |||
| 1a4acae26e | |||
| 3eaeeb391a | |||
| 5fb4dd1ee7 | |||
| ed761c6857 | |||
| 2b52c40be5 | |||
| 6c72ff39ca | |||
| a5cd676455 | |||
| 9f5b64a580 | |||
| fe6888258b | |||
| 9b96e36b63 | |||
| 8d9cbef27e | |||
| 72b16ee76c | |||
| 8393775111 | |||
| 857ac0632e | |||
| b941b231ae | |||
| 8166a39495 | |||
| 0d5e11dbf6 | |||
| 0cae431a7c | |||
| 38fd59f4d3 | |||
| ffea65bce6 | |||
| 582d0a880e | |||
| d8ecc33149 | |||
| dd6771f3e0 | |||
| 800d858350 | |||
| b6ce9fd733 |
Vendored
+2
-1
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"python.pythonPath": "/usr/bin/python3",
|
||||
"liveServer.settings.port": 5501
|
||||
"liveServer.settings.port": 5501,
|
||||
"docwriter.progress.trackFunctions": false
|
||||
}
|
||||
@@ -571,7 +571,6 @@
|
||||
.close:hover,
|
||||
.close:focus {
|
||||
color: black;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@@ -672,9 +671,6 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.selected {
|
||||
background-color: #dddddd;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<link rel="stylesheet" href="ol/ol.css">
|
||||
<script src="js/ol-layerswitcher.js"></script>
|
||||
<link rel="stylesheet" href="css/ol-layerswitcher.css" />
|
||||
<script type="text/javascript" src="js/luxon.js"></script>
|
||||
|
||||
<script type="text/javascript" src="js/flightinfo.js"></script>
|
||||
<script type="text/javascript" src="js/config.js"></script>
|
||||
<script type="text/javascript" src="js/liveatc.js"></script>
|
||||
@@ -26,14 +26,14 @@
|
||||
<script type="text/javascript" src="js/script2.js"></script>
|
||||
<script type="text/javascript" src="js/excanvas.min.js"></script>
|
||||
<script type="text/javascript" src="js/schedules.js"></script>
|
||||
<script type="text/javascript" src="js/liveatc.js"></script>
|
||||
<script async type="text/javascript" src="js/liveatc.js"></script>
|
||||
<link rel="stylesheet" href="material/material.min.css">
|
||||
<script src="material/material.min.js"></script>
|
||||
<link rel="stylesheet" href="material/font.css">
|
||||
<title>Aviation Assistant</title>
|
||||
</head>
|
||||
|
||||
<body onload="initialize()" scroll="no">
|
||||
<body id="body" onload="initialize()" scroll="no">
|
||||
<div id="loader" class="hidden">
|
||||
<img src="images/spinny.gif" id="spinny" alt="Loading...">
|
||||
<progress id="loader_progress"></progress>
|
||||
@@ -121,11 +121,13 @@
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<button id="button_background" class=" mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect"
|
||||
<button id="button_background"
|
||||
class=" mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect"
|
||||
style="width: 40px; height: 40px; min-width: initial;" onclick="setBrightness('down')">
|
||||
<i class="material-icons">remove</i>
|
||||
</button> <span id="brightness-text">Brightness (<span id="brightness_level"></span>)</span>
|
||||
<button id="button_background" class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect"
|
||||
<button id="button_background"
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect"
|
||||
style="width: 40px; height: 40px; min-width: initial;" onclick="setBrightness('up')">
|
||||
<i class="material-icons">add</i>
|
||||
</button>
|
||||
@@ -245,7 +247,7 @@
|
||||
</button>
|
||||
|
||||
</span>
|
||||
|
||||
|
||||
</div>
|
||||
<div id="map_container">
|
||||
<div id="map_canvas"></div>
|
||||
@@ -263,15 +265,17 @@
|
||||
<div id="itin_airport_long_name"></div>
|
||||
<div id="itin_airport_city"></div>
|
||||
<div id="itin_airport_loc"></div>
|
||||
<button id="itin_arrivals" onclick="itinAirportArrivals()" class="mdl-button mdl-js-button mdl-button--raised">
|
||||
<button id="itin_arrivals" onclick="itinAirportArrivals()"
|
||||
class="mdl-button mdl-js-button mdl-button--raised">
|
||||
Arrivals Chart
|
||||
</button>
|
||||
<button id="itin_departures" onclick="itinAirportDepartures()" class="mdl-button mdl-js-button mdl-button--raised">
|
||||
</button>
|
||||
<button id="itin_departures" onclick="itinAirportDepartures()"
|
||||
class="mdl-button mdl-js-button mdl-button--raised">
|
||||
Departures Chart
|
||||
</button>
|
||||
<button id="itin_back" class="mdl-button mdl-js-button mdl-button--raised">
|
||||
</button>
|
||||
<button id="itin_back" class="mdl-button mdl-js-button mdl-button--raised">
|
||||
Back
|
||||
</button>
|
||||
</button>
|
||||
</div>
|
||||
<div id="itin_arr" style="display: none"></div>
|
||||
<div id="itin_dep" style="display: none"></div>
|
||||
@@ -340,8 +344,7 @@
|
||||
<td style="text-align: right">
|
||||
<b><span id="flight_airport_short_destination"
|
||||
style="font-size: 18px;"></span></b><br>
|
||||
<span id="flight_airport_long_destination"
|
||||
style="font-size: 12px;"></span><br>
|
||||
<span id="flight_airport_long_destination" style="font-size: 12px;"></span><br>
|
||||
<span id="flight_airport_loc_destination" style="font-size: 10px;"></span>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -502,7 +505,7 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- sidebar_container -->
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,11 @@
|
||||
var baseurl = "https://avwx.rest/api/"
|
||||
|
||||
/**
|
||||
* "This function takes two arguments, x and y, and uses them to make an AJAX call to a weather API,
|
||||
* then it takes the data returned from the API and displays it on the page."
|
||||
* @param x - longitude
|
||||
* @param y - latitude
|
||||
*/
|
||||
function nearestStations(x, y) {
|
||||
FetchPending = $.ajax({
|
||||
url: baseurl + 'metar/' + x + ',' + y + '?token=' + keys['AVWX'] + '&options=info&format=json',
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ xhr1.send();
|
||||
|
||||
var flight_info = {}
|
||||
var TAB = "Radar"
|
||||
var DateTime = luxon.DateTime;
|
||||
//var DateTime = luxon.DateTime;
|
||||
var graph_types = ["/dump1090-localhost-local_trailing_rate-", "/dump1090-localhost-aircraft-", "/dump1090-localhost-tracks-", "/dump1090-localhost-signal-", "/dump1090-localhost-local_rate-", "/dump1090-localhost-aircraft_message_rate-", "/dump1090-localhost-cpu-", "/system-localhost-cpu-", "/system-localhost-temperature-", "/system-localhost-memory-", "/system-localhost-network_bandwidth-", "/system-localhost-df_root-", "/system-localhost-disk_io_iops-", "/system-localhost-disk_io_octets-"]
|
||||
/* var graph_types = {
|
||||
"ADSB Message Rate": "/dump1090-localhost-local_trailing_rate-",
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* It takes a URL and a title, and then it plays the audio stream at the URL.
|
||||
* @param url - The URL of the PLS file
|
||||
* @param title - The title of the stream
|
||||
*/
|
||||
function playPLS(url, title) {
|
||||
window.setInterval(function () {
|
||||
if (document.getElementById("player").readyState === 3 || document.getElementById("player").readyState === 4) {
|
||||
@@ -65,6 +70,10 @@ function playPLS(url, title) {
|
||||
})
|
||||
|
||||
}
|
||||
/**
|
||||
* If the icon is a play button, play the audio and change the icon to a pause button. If the icon is a
|
||||
* pause button, pause the audio and change the icon to a play button.
|
||||
*/
|
||||
|
||||
function playPause() {
|
||||
var text = document.getElementById("audioControl_icon").innerHTML
|
||||
@@ -76,6 +85,10 @@ function playPause() {
|
||||
document.getElementById("audioControl_icon").innerHTML = "play_arrow"
|
||||
}
|
||||
}
|
||||
/**
|
||||
* It creates a div for each state in the JSON file, and then adds a div with a bunch of line breaks to
|
||||
* the end.
|
||||
*/
|
||||
|
||||
function listStations() {
|
||||
document.getElementById("atc_selector").innerHTML = ""
|
||||
@@ -100,6 +113,10 @@ function listStations() {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* It takes a state name as an argument, and then it creates a list of airports in that state.
|
||||
* @param state - The state that the user has selected
|
||||
*/
|
||||
|
||||
function selectState(state) {
|
||||
document.getElementById("atc_selector").innerHTML = ""
|
||||
@@ -143,6 +160,12 @@ function selectState(state) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* It takes the airport code and state code and then uses the airport code to find the feeds for that
|
||||
* airport in the JSON file.
|
||||
* @param airport - The airport code
|
||||
* @param state - The state that the airport is in
|
||||
*/
|
||||
|
||||
function selectAirport(airport, state) {
|
||||
document.getElementById("atc_selector").innerHTML = ""
|
||||
|
||||
File diff suppressed because one or more lines are too long
+17
-3
@@ -1,5 +1,9 @@
|
||||
var us_airports = {}
|
||||
|
||||
/**
|
||||
* It creates a div for each state in the us_airports object, and when clicked, it calls the
|
||||
* loadAirport function with the state as the argument.
|
||||
*/
|
||||
function initializeSchedulesPage() {
|
||||
document.getElementById("itin_body").innerHTML = ""
|
||||
document.getElementById("itin_img").setAttribute("src", 'images/black.jpg')
|
||||
@@ -21,6 +25,10 @@ function initializeSchedulesPage() {
|
||||
}
|
||||
})
|
||||
}
|
||||
/**
|
||||
* It loads the airports in a state.
|
||||
* @param state - The state that the user has selected
|
||||
*/
|
||||
|
||||
function loadAirport(state) {
|
||||
document.getElementById("itin_img").setAttribute("src", 'images/black.jpg')
|
||||
@@ -51,7 +59,13 @@ function loadAirport(state) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Retrieving the schedule for a given airport. */
|
||||
/**
|
||||
* It takes in an airport code and state, and then it uses ajax to retrieve the airport's schedule from
|
||||
* a server.
|
||||
* @param airport - "KLAX"
|
||||
* @param state - "California"
|
||||
*/
|
||||
function retrieveSchedule(airport, state) {
|
||||
document.getElementById("itin_arr").style.display = "none"
|
||||
document.getElementById("itin_dep").style.display = "none"
|
||||
@@ -141,7 +155,7 @@ function retrieveSchedule(airport, state) {
|
||||
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "http://"+window.location.hostname+":5000/cmd", true);
|
||||
xhr.open("POST", "http://"+window.location.hostname+":5000/curl", true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4) {
|
||||
@@ -251,7 +265,7 @@ function retrieveSchedule(airport, state) {
|
||||
}
|
||||
}
|
||||
xhr.send(JSON.stringify({
|
||||
command: "curl https://flightaware.com/live/airport/" + airport
|
||||
url: "https://flightaware.com/live/airport/" + airport
|
||||
}));
|
||||
|
||||
}
|
||||
@@ -246,6 +246,12 @@ function initialize() {
|
||||
document.getElementById("graphs_holder").setAttribute("class", "graphs_s")
|
||||
document.getElementById("graphs_holder").setAttribute("src", "http://localhost/graphs1090/graphs" + graph_types[starting_graph] + "2h.png")
|
||||
$("#loader").removeClass("hidden");
|
||||
|
||||
if (navigator.userAgent === "RPI") {
|
||||
document.getElementById("body").style.cursor = "none"
|
||||
} else {
|
||||
|
||||
}
|
||||
// Get receiver metadata, reconfigure using it, then continue
|
||||
// with initialization
|
||||
$.ajax({
|
||||
|
||||
+12
-19
@@ -128,6 +128,7 @@ function changeMapBounds(btm_left, top_right) {
|
||||
long_east: btm_left[0],
|
||||
long_west: top_right[0]
|
||||
}
|
||||
console.log(json)
|
||||
xhr.send(JSON.stringify(json));
|
||||
}
|
||||
|
||||
@@ -203,7 +204,7 @@ function getInitialVolume() {
|
||||
|
||||
function getCPUTemp() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "http://" + window.location.hostname + ":5000/cmd", true);
|
||||
xhr.open("GET", "http://" + window.location.hostname + ":5000/cputemp", true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4) {
|
||||
@@ -215,9 +216,7 @@ function getCPUTemp() {
|
||||
document.getElementById("internal_temperature").style.color = hsl_col_perc(temp_percentage, 0, 120)
|
||||
}
|
||||
}
|
||||
xhr.send(JSON.stringify({
|
||||
command: "vcgencmd measure_temp"
|
||||
}));
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
function readBrightnessLevel() {
|
||||
@@ -274,7 +273,7 @@ function sendCMD(cmd) {
|
||||
if (cmd === "update") {
|
||||
var output = ""
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "http://" + window.location.hostname + ":5000/cmd", true);
|
||||
xhr.open("GET", "http://" + window.location.hostname + ":5000/update", true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4) {
|
||||
@@ -294,14 +293,12 @@ function sendCMD(cmd) {
|
||||
}
|
||||
}
|
||||
}
|
||||
xhr.send(JSON.stringify({
|
||||
command: "sudo git pull"
|
||||
}));
|
||||
xhr.send();
|
||||
}
|
||||
if (cmd === "getbranch") {
|
||||
var output = ""
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "http://" + window.location.hostname + ":5000/cmd", true);
|
||||
xhr.open("GET", "http://" + window.location.hostname + ":5000/branch", true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4) {
|
||||
@@ -330,7 +327,7 @@ function sendCMD(cmd) {
|
||||
snackbarContainer.MaterialSnackbar.showSnackbar(data);
|
||||
var output = ""
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "http://" + window.location.hostname + ":5000/cmd", true);
|
||||
xhr.open("GET", "http://" + window.location.hostname + ":5000/shutdown", true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4) {
|
||||
@@ -338,9 +335,7 @@ function sendCMD(cmd) {
|
||||
output = xhr.response
|
||||
}
|
||||
}
|
||||
xhr.send(JSON.stringify({
|
||||
command: "cd /usr/local/bin && sudo x728softsd.sh"
|
||||
}));
|
||||
xhr.send();
|
||||
}
|
||||
if (cmd === "restart") {
|
||||
var snackbarContainer = document.getElementById('no-updates-snackbar');
|
||||
@@ -350,7 +345,7 @@ function sendCMD(cmd) {
|
||||
snackbarContainer.MaterialSnackbar.showSnackbar(data);
|
||||
var output = ""
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "http://" + window.location.hostname + ":5000/cmd", true);
|
||||
xhr.open("GET", "http://" + window.location.hostname + ":5000/reboot", true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4) {
|
||||
@@ -358,9 +353,7 @@ function sendCMD(cmd) {
|
||||
output = xhr.response
|
||||
}
|
||||
}
|
||||
xhr.send(JSON.stringify({
|
||||
command: "cd /usr/local/bin && sudo reboot"
|
||||
}));
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
|
||||
@@ -430,10 +423,10 @@ function changeColorMode() {
|
||||
|
||||
function changeBranch(branch) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "http://" + window.location.hostname + ":5000/cmd", true);
|
||||
xhr.open("POST", "http://" + window.location.hostname + ":5000/setbranch", true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.send(JSON.stringify({
|
||||
command: "sudo git checkout " + branch
|
||||
command: branch
|
||||
}));
|
||||
sendCMD("getbranch")
|
||||
}
|
||||
|
||||
+41
-3
@@ -50,14 +50,52 @@ def volume():
|
||||
level = os.popen('vol').read()
|
||||
return str(level)
|
||||
|
||||
@app.route('/cmd',methods = ['POST'])
|
||||
def command():
|
||||
@app.route('/curl',methods = ['POST'])
|
||||
def curl():
|
||||
if request.method == 'POST':
|
||||
json = request.get_json()
|
||||
output = os.popen("cd /usr/share/dump1090-mutability/html && "+json['command']).read()
|
||||
output = os.popen("curl "+json['url']).read()
|
||||
#output = os.popen(json['command']).read()
|
||||
return str(output)
|
||||
|
||||
@app.route('/cputemp',methods = ['GET'])
|
||||
def cputemp():
|
||||
if request.method == 'GET':
|
||||
output = os.popen("vcgencmd measure_temp").read()
|
||||
return str(output)
|
||||
|
||||
@app.route('/update',methods = ['GET'])
|
||||
def update():
|
||||
if request.method == 'GET':
|
||||
output = os.popen("sudo git pull").read()
|
||||
return str(output)
|
||||
|
||||
@app.route('/branch',methods = ['GET'])
|
||||
def branch():
|
||||
if request.method == 'GET':
|
||||
output = os.popen("sudo git branch | grep -F '*'").read()
|
||||
return str(output)
|
||||
|
||||
@app.route('/shutdown',methods = ['GET'])
|
||||
def shutdown():
|
||||
if request.method == 'GET':
|
||||
output = os.popen("cd /usr/local/bin && sudo x728softsd.sh").read()
|
||||
return str(output)
|
||||
|
||||
|
||||
@app.route('/reboot',methods = ['GET'])
|
||||
def reboot():
|
||||
if request.method == 'GET':
|
||||
output = os.popen("cd /usr/local/bin && sudo reboot").read()
|
||||
return str(output)
|
||||
|
||||
@app.route('/setbranch',methods = ['POST'])
|
||||
def setbranch():
|
||||
if request.method == 'POST':
|
||||
json = request.get_json()
|
||||
output = os.popen("cd /usr/share/dump1090-mutability/html && sudo git checkout " +json['branch']).read()
|
||||
return str(output)
|
||||
|
||||
|
||||
@app.after_request
|
||||
def after_request(response):
|
||||
|
||||
+77
-94
@@ -1,124 +1,107 @@
|
||||
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
|
||||
const request = require('request');
|
||||
const fs = require('fs')
|
||||
var json = {}
|
||||
var bounds = {
|
||||
lat_north: 0,
|
||||
lat_south: 0,
|
||||
long_east: 0,
|
||||
long_west: 0
|
||||
lat_north: 0,
|
||||
lat_south: 0,
|
||||
long_east: 0,
|
||||
long_west: 0
|
||||
}
|
||||
const express = require('express')
|
||||
const bodyParser = require("body-parser");
|
||||
const app = express()
|
||||
var cluster = require('cluster');
|
||||
if (cluster.isMaster) {
|
||||
cluster.fork();
|
||||
|
||||
cluster.on('exit', function(worker, code, signal) {
|
||||
cluster.fork();
|
||||
});
|
||||
}
|
||||
|
||||
if (cluster.isWorker) {
|
||||
|
||||
app.use(bodyParser.urlencoded({
|
||||
extended: false
|
||||
}));
|
||||
app.use(bodyParser.urlencoded({ extended: false }));
|
||||
app.use(bodyParser.json());
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||
next();
|
||||
app.use(function(req, res, next) {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||
next();
|
||||
});
|
||||
|
||||
function getData() {
|
||||
var xhr = new XMLHttpRequest()
|
||||
xhr.open("POST", "http://127.0.0.1:5000/cmd", true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.timeout = 8000;
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4) {
|
||||
parseData(xhr.responseText)
|
||||
}
|
||||
//console.log('http://localhost:7000/data-live.flightradar24.com/zones/fcgi/feed.js?faa=1&bounds='+bounds.lat_north.toFixed(3)+'%2C'+bounds.lat_south.toFixed(3)+'%2C'+bounds.long_east.toFixed(3)+'%2C'+bounds.long_west.toFixed(3)+'&satellite=1&mlat=1&flarm=1&adsb=1&gnd=1&air=1&vehicles=1&estimated=1&maxage=14400&gliders=1&stats=1')
|
||||
const options = {
|
||||
url: 'http://localhost:7000/data-live.flightradar24.com/zones/fcgi/feed.js?faa=1&bounds='+bounds.lat_north.toFixed(3)+'%2C'+bounds.lat_south.toFixed(3)+'%2C'+bounds.long_east.toFixed(3)+'%2C'+bounds.long_west.toFixed(3)+'&satellite=1&mlat=1&flarm=1&adsb=1&gnd=1&air=1&vehicles=1&estimated=1&maxage=14400&gliders=1&stats=1',
|
||||
headers: {
|
||||
'x-requested-with': 'request'
|
||||
}
|
||||
xhr.send(JSON.stringify({
|
||||
command: 'curl "http://data-live.flightradar24.com/zones/fcgi/feed.js?faa=1&bounds=' + bounds.lat_north.toFixed(3) + '%2C' + bounds.lat_south.toFixed(3) + '%2C' + bounds.long_east.toFixed(3) + '%2C' + bounds.long_west.toFixed(3) + '&satellite=1&mlat=1&flarm=1&adsb=1&gnd=1&air=1&vehicles=1&estimated=1&maxage=14400&gliders=1&stats=1"'
|
||||
}));
|
||||
};
|
||||
request(options, function (error, response, body) {
|
||||
if (body) {
|
||||
parseData(body)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function parseData(data) {
|
||||
data = JSON.parse(data)
|
||||
json.now = new Date()
|
||||
json.now = json.now.getTime() - json.now.getMilliseconds() / 1000
|
||||
json.messages = 0
|
||||
json.aircraft = []
|
||||
for (element in data) {
|
||||
if (element != "stats" && element != "full_count" && element != "version") {
|
||||
json.aircraft.push({
|
||||
hex: data[element][0].toLowerCase(),
|
||||
flight: data[element][16],
|
||||
lat: data[element][1],
|
||||
lon: data[element][2],
|
||||
altitude: data[element][4],
|
||||
track: data[element][3],
|
||||
speed: data[element][5],
|
||||
squawk: data[element][6],
|
||||
seen: 0,
|
||||
seen_pos: 0,
|
||||
rssi: 0,
|
||||
messages: 0,
|
||||
internet: true,
|
||||
dep: data[element][11],
|
||||
arr: data[element][12],
|
||||
airline: data[element][18]
|
||||
})
|
||||
// console.log(element)
|
||||
//console.log(data[element][1])
|
||||
//console.log(data[element][2])
|
||||
}
|
||||
data = JSON.parse(data)
|
||||
json.now = new Date()
|
||||
json.now = json.now.getTime() - json.now.getMilliseconds() / 1000
|
||||
json.messages = 0
|
||||
json.aircraft = []
|
||||
for (element in data) {
|
||||
if (element != "stats" && element != "full_count" && element != "version") {
|
||||
json.aircraft.push({
|
||||
hex: data[element][0].toLowerCase(),
|
||||
flight: data[element][16],
|
||||
lat: data[element][1],
|
||||
lon: data[element][2],
|
||||
altitude: data[element][4],
|
||||
track: data[element][3],
|
||||
speed: data[element][5],
|
||||
squawk: data[element][6],
|
||||
seen: 0,
|
||||
seen_pos: 0,
|
||||
rssi: 0,
|
||||
messages: 0,
|
||||
internet: true,
|
||||
dep: data[element][11],
|
||||
arr: data[element][12],
|
||||
airline: data[element][18]
|
||||
})
|
||||
// console.log(element)
|
||||
//console.log(data[element][1])
|
||||
//console.log(data[element][2])
|
||||
}
|
||||
for (element in json.aircraft) {
|
||||
if (json.aircraft[element].messages != 0) {
|
||||
json.aircraft[element] = {}
|
||||
} else {
|
||||
json.aircraft[element].messages = json.aircraft[element].messages + 1
|
||||
}
|
||||
}
|
||||
for (element in json.aircraft) {
|
||||
if (json.aircraft[element].messages != 0) {
|
||||
json.aircraft[element] = {}
|
||||
} else {
|
||||
json.aircraft[element].messages = json.aircraft[element].messages +1
|
||||
}
|
||||
fs.writeFileSync("/run/dump1090-mutability/aircraft1.json", JSON.stringify(json))
|
||||
// fs.writeFileSync("../data/aircraft1.json", JSON.stringify(json))
|
||||
//console.log(json)
|
||||
}
|
||||
fs.writeFileSync("/run/dump1090-mutability/aircraft1.json", JSON.stringify(json))
|
||||
//console.log(json)
|
||||
}
|
||||
|
||||
function changeTime() {
|
||||
fs.readFile('/run/dump1090-mutability/aircraft1.json', 'utf8', function (err,data) {
|
||||
//fs.readFile('../data/aircraft1.json', 'utf8', function (err, data) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
data = JSON.parse(data)
|
||||
for (element in data.aircraft) {
|
||||
data.aircraft[element].seen = data.aircraft[element].seen + 1
|
||||
data.aircraft[element].seen_pos = data.aircraft[element].seen_pos + 1
|
||||
}
|
||||
fs.writeFileSync("/run/dump1090-mutability/aircraft1.json", JSON.stringify(data))
|
||||
//fs.writeFileSync("../data/aircraft1.json", JSON.stringify(data))
|
||||
});
|
||||
fs.readFile('/run/dump1090-mutability/aircraft1.json', 'utf8', function (err,data) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
data = JSON.parse(data)
|
||||
for (element in data.aircraft) {
|
||||
data.aircraft[element].seen = data.aircraft[element].seen + 1
|
||||
data.aircraft[element].seen_pos = data.aircraft[element].seen_pos +1
|
||||
}
|
||||
fs.writeFileSync("/run/dump1090-mutability/aircraft1.json", JSON.stringify(data))
|
||||
});
|
||||
}
|
||||
|
||||
setInterval(function () {
|
||||
getData()
|
||||
getData()
|
||||
}, 10000);
|
||||
setInterval(function () {
|
||||
changeTime()
|
||||
changeTime()
|
||||
}, 1000);
|
||||
|
||||
app.post("/internet", function (req, res) {
|
||||
//console.log(req.body)
|
||||
bounds = req.body
|
||||
getData()
|
||||
return res.send("Recieved")
|
||||
app.post("/internet", function(req, res) {
|
||||
//console.log(req.body)
|
||||
bounds = req.body
|
||||
getData()
|
||||
return res.send("Recieved")
|
||||
})
|
||||
|
||||
app.listen(8000);
|
||||
}
|
||||
app.listen(8000);
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
sudo python /usr/share/dump1090-mutability/html/python/battery.py & > /dev/null 2>&1 &
|
||||
sudo python /usr/share/dump1090-mutability/html/python/api.py & > /dev/null 2>&1 &
|
||||
sudo node /usr/share/dump1090-mutability/html/scripts/internet_data.js & > /usr/share/dump1090-mutability/html/scripts/log &
|
||||
sudo node /usr/share/dump1090-mutability/html/scripts/internet_data.js & > /dev/null 2>&1 &
|
||||
/usr/bin/wget http://server1.nicholaspease.com:6500/reports/liveatc.json -O /home/pi/dump1090-info/liveatc.json
|
||||
|
||||
export PORT=8080
|
||||
sudo node /home/pi/cors-anywhere/server.js
|
||||
Reference in New Issue
Block a user