Merge branch 'mapRefactor' of https://github.com/bdavenport/dump1090 into mapRefactor
Conflicts: public_html/script.js
This commit is contained in:
commit
5c3f6dac50
|
@ -3487,7 +3487,7 @@ int decodeHexMessage(struct client *c, char *hex) {
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a description of planes in json. */
|
/* Return a description of planes in json. No metric conversion. */
|
||||||
char *aircraftsToJson(int *len) {
|
char *aircraftsToJson(int *len) {
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
struct aircraft *a = Modes.aircrafts;
|
struct aircraft *a = Modes.aircrafts;
|
||||||
|
@ -3498,7 +3498,6 @@ char *aircraftsToJson(int *len) {
|
||||||
l = snprintf(p,buflen,"[\n");
|
l = snprintf(p,buflen,"[\n");
|
||||||
p += l; buflen -= l;
|
p += l; buflen -= l;
|
||||||
while(a) {
|
while(a) {
|
||||||
int altitude = a->altitude, speed = a->speed;
|
|
||||||
int position = 0;
|
int position = 0;
|
||||||
int track = 0;
|
int track = 0;
|
||||||
|
|
||||||
|
@ -3507,11 +3506,6 @@ char *aircraftsToJson(int *len) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert units to metric if --metric was specified. */
|
|
||||||
if (Modes.metric) {
|
|
||||||
altitude = (int) (altitude / 3.2828);
|
|
||||||
speed = (int) (speed * 1.852);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (a->bFlags & MODES_ACFLAGS_LATLON_VALID) {
|
if (a->bFlags & MODES_ACFLAGS_LATLON_VALID) {
|
||||||
position = 1;
|
position = 1;
|
||||||
|
@ -3521,6 +3515,7 @@ char *aircraftsToJson(int *len) {
|
||||||
track = 1;
|
track = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No metric conversion
|
||||||
l = snprintf(p,buflen,
|
l = snprintf(p,buflen,
|
||||||
"{\"hex\":\"%06x\", \"squawk\":\"%04x\", \"flight\":\"%s\", \"lat\":%f, "
|
"{\"hex\":\"%06x\", \"squawk\":\"%04x\", \"flight\":\"%s\", \"lat\":%f, "
|
||||||
"\"lon\":%f, \"validposition\":%d, \"altitude\":%d, \"track\":%d, \"validtrack\":%d,"
|
"\"lon\":%f, \"validposition\":%d, \"altitude\":%d, \"track\":%d, \"validtrack\":%d,"
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
//
|
//
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
|
|
||||||
|
// -- Output Settings -------------------------------------
|
||||||
|
// Show metric values
|
||||||
|
Metric = false; // true or false
|
||||||
|
|
||||||
// -- Map settings ----------------------------------------
|
// -- Map settings ----------------------------------------
|
||||||
// The Latitude and Longitude in decimal format
|
// The Latitude and Longitude in decimal format
|
||||||
CONST_CENTERLAT = 45.0;
|
CONST_CENTERLAT = 45.0;
|
||||||
|
@ -23,3 +27,7 @@ SiteShow = false; // true or false
|
||||||
SiteLat = 45.0;
|
SiteLat = 45.0;
|
||||||
SiteLon = 9.0;
|
SiteLon = 9.0;
|
||||||
|
|
||||||
|
SiteCircles = true; // true or false (Only shown if SiteShow is true)
|
||||||
|
// In nautical miles or km (depending settings value 'Metric')
|
||||||
|
SiteCirclesDistances = new Array(100,150,200);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css" />
|
<link rel="stylesheet" type="text/css" href="style.css" />
|
||||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
|
||||||
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
|
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=geometry"></script>
|
||||||
<script type="text/javascript" src="config.js"></script>
|
<script type="text/javascript" src="config.js"></script>
|
||||||
<script type="text/javascript" src="untrackedDeveloperSettings.js"></script> <!-- Developers -->
|
<script type="text/javascript" src="untrackedDeveloperSettings.js"></script> <!-- Developers -->
|
||||||
<script type="text/javascript" src="planeObject.js"></script>
|
<script type="text/javascript" src="planeObject.js"></script>
|
||||||
|
|
|
@ -146,9 +146,10 @@ function initialize() {
|
||||||
GoogleMap.mapTypes.set("dark_map", styledMap);
|
GoogleMap.mapTypes.set("dark_map", styledMap);
|
||||||
|
|
||||||
// Add home marker if requested
|
// Add home marker if requested
|
||||||
if (SiteShow) {
|
if (SiteShow && (typeof SiteLat !== 'undefined' || typeof SiteLon !== 'undefined')) {
|
||||||
var siteMarker = new google.maps.LatLng(SiteLat, SiteLon);
|
var siteMarker = new google.maps.LatLng(SiteLat, SiteLon);
|
||||||
var markerImage = new google.maps.MarkerImage('http://maps.google.com/mapfiles/kml/pal4/icon57.png',
|
var markerImage = new google.maps.MarkerImage(
|
||||||
|
'http://maps.google.com/mapfiles/kml/pal4/icon57.png',
|
||||||
new google.maps.Size(32, 32), // Image size
|
new google.maps.Size(32, 32), // Image size
|
||||||
new google.maps.Point(0, 0), // Origin point of image
|
new google.maps.Point(0, 0), // Origin point of image
|
||||||
new google.maps.Point(16, 16)); // Position where marker should point
|
new google.maps.Point(16, 16)); // Position where marker should point
|
||||||
|
@ -158,6 +159,12 @@ function initialize() {
|
||||||
icon: markerImage,
|
icon: markerImage,
|
||||||
title: 'My Radar Site'
|
title: 'My Radar Site'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (SiteCircles) {
|
||||||
|
for (var i=0;i<SiteCirclesDistances.length;i++) {
|
||||||
|
drawCircle(marker, SiteCirclesDistances[i]); // in meters
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Did our crafty user need some setup?
|
// Did our crafty user need some setup?
|
||||||
|
@ -212,9 +219,11 @@ function refreshSelected() {
|
||||||
|
|
||||||
// Flight header line including squawk if needed
|
// Flight header line including squawk if needed
|
||||||
if (selected && selected.flight == "") {
|
if (selected && selected.flight == "") {
|
||||||
html += '<tr><td colspan="' + columns + '" id="selectedinfotitle"><b>N/A (' + selected.icao + ')</b>';
|
html += '<tr><td colspan="' + columns + '" id="selectedinfotitle"><b>N/A (' +
|
||||||
|
selected.icao + ')</b>';
|
||||||
} else if (selected && selected.flight != "") {
|
} else if (selected && selected.flight != "") {
|
||||||
html += '<tr><td colspan="' + columns + '" id="selectedinfotitle"><b>' + selected.flight + '</b>';
|
html += '<tr><td colspan="' + columns + '" id="selectedinfotitle"><b>' +
|
||||||
|
selected.flight + '</b>';
|
||||||
} else {
|
} else {
|
||||||
html += '<tr><td colspan="' + columns + '" id="selectedinfotitle"><b>DUMP1090</b>';
|
html += '<tr><td colspan="' + columns + '" id="selectedinfotitle"><b>DUMP1090</b>';
|
||||||
}
|
}
|
||||||
|
@ -232,7 +241,11 @@ function refreshSelected() {
|
||||||
html += '<td></tr>';
|
html += '<td></tr>';
|
||||||
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
html += '<tr><td>Altitude: ' + selected.altitude + '</td>';
|
if (Metric) {
|
||||||
|
html += '<tr><td>Altitude: ' + Math.round(selected.altitude / 3.2828) + ' m</td>';
|
||||||
|
} else {
|
||||||
|
html += '<tr><td>Altitude: ' + selected.altitude + ' ft</td>';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
html += '<tr><td>Altitude: n/a</td>';
|
html += '<tr><td>Altitude: n/a</td>';
|
||||||
}
|
}
|
||||||
|
@ -245,7 +258,11 @@ function refreshSelected() {
|
||||||
|
|
||||||
html += '<tr><td>Speed: '
|
html += '<tr><td>Speed: '
|
||||||
if (selected) {
|
if (selected) {
|
||||||
html += selected.speed + ' kt';
|
if (Metric) {
|
||||||
|
html += Math.round(selected.speed * 1.852) + ' km/h';
|
||||||
|
} else {
|
||||||
|
html += selected.speed + ' kt';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
html += 'n/a';
|
html += 'n/a';
|
||||||
}
|
}
|
||||||
|
@ -271,43 +288,29 @@ function refreshSelected() {
|
||||||
|
|
||||||
// Let's show some extra data if we have site coordinates
|
// Let's show some extra data if we have site coordinates
|
||||||
if (SiteShow) {
|
if (SiteShow) {
|
||||||
// Converts numeric degrees to radians
|
var siteLatLon = new google.maps.LatLng(SiteLat, SiteLon);
|
||||||
if (typeof Number.prototype.toRad == 'undefined') {
|
var planeLatLon = new google.maps.LatLng(selected.latitude, selected.longitude);
|
||||||
Number.prototype.toRad = function() {
|
var dist = google.maps.geometry.spherical.computeDistanceBetween (siteLatLon, planeLatLon);
|
||||||
return this * Math.PI / 180;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Converts radians to numeric (signed) degrees
|
if (Metric) {
|
||||||
if (typeof Number.prototype.toDeg == 'undefined') {
|
dist /= 1000;
|
||||||
Number.prototype.toDeg = function() {
|
} else {
|
||||||
return this * 180 / Math.PI;
|
dist /= 1852;
|
||||||
}
|
}
|
||||||
}
|
dist = (Math.round((dist)*10)/10).toFixed(1);
|
||||||
|
html += '<tr><td colspan="' + columns + '">Distance from Site: ' + dist +
|
||||||
// Calculate distance
|
(Metric ? ' km' : ' NM') + '</td></tr>';
|
||||||
var R = 6371; // km
|
|
||||||
var dLat = (selected.latitude-SiteLat).toRad();
|
|
||||||
var dLon = (selected.longitude-SiteLon).toRad();
|
|
||||||
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
|
|
||||||
Math.cos(SiteLat.toRad()) * Math.cos(selected.latitude.toRad()) *
|
|
||||||
Math.sin(dLon/2) * Math.sin(dLon/2);
|
|
||||||
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
|
||||||
var dist = (R * c) / 1.852;
|
|
||||||
dist = (Math.round(dist*10)/10).toFixed(1);
|
|
||||||
|
|
||||||
html += '<tr><td colspan="' + columns + '">Distance from Site: ' + dist + ' NM</td></tr>';
|
|
||||||
} // End of SiteShow
|
} // End of SiteShow
|
||||||
} else {
|
} else {
|
||||||
if (SiteShow) {
|
if (SiteShow) {
|
||||||
html += '<tr><td colspan="' + columns + '">Distance from Site: n/a NM</td></tr>';
|
html += '<tr><td colspan="' + columns + '">Distance from Site: n/a ' +
|
||||||
|
(Metric ? ' km' : ' NM') + '</td></tr>';
|
||||||
} else {
|
} else {
|
||||||
html += 'n/a</td></tr>';
|
html += 'n/a</td></tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
html += '</table>';
|
html += '</table>';
|
||||||
|
|
||||||
document.getElementById('plane_detail').innerHTML = html;
|
document.getElementById('plane_detail').innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,12 +364,18 @@ function refreshTableInfo() {
|
||||||
html += '<thead style="background-color: #BBBBBB; cursor: pointer;">';
|
html += '<thead style="background-color: #BBBBBB; cursor: pointer;">';
|
||||||
html += '<td onclick="setASC_DESC(\'0\');sortTable(\'tableinfo\',\'0\');">ICAO</td>';
|
html += '<td onclick="setASC_DESC(\'0\');sortTable(\'tableinfo\',\'0\');">ICAO</td>';
|
||||||
html += '<td onclick="setASC_DESC(\'1\');sortTable(\'tableinfo\',\'1\');">Flight</td>';
|
html += '<td onclick="setASC_DESC(\'1\');sortTable(\'tableinfo\',\'1\');">Flight</td>';
|
||||||
html += '<td onclick="setASC_DESC(\'2\');sortTable(\'tableinfo\',\'2\');" align="right">Squawk</td>';
|
html += '<td onclick="setASC_DESC(\'2\');sortTable(\'tableinfo\',\'2\');" ' +
|
||||||
html += '<td onclick="setASC_DESC(\'3\');sortTable(\'tableinfo\',\'3\');" align="right">Altitude</td>';
|
'align="right">Squawk</td>';
|
||||||
html += '<td onclick="setASC_DESC(\'4\');sortTable(\'tableinfo\',\'4\');" align="right">Speed</td>';
|
html += '<td onclick="setASC_DESC(\'3\');sortTable(\'tableinfo\',\'3\');" ' +
|
||||||
html += '<td onclick="setASC_DESC(\'5\');sortTable(\'tableinfo\',\'5\');" align="right">Track</td>';
|
'align="right">Altitude</td>';
|
||||||
html += '<td onclick="setASC_DESC(\'6\');sortTable(\'tableinfo\',\'6\');" align="right">Msgs</td>';
|
html += '<td onclick="setASC_DESC(\'4\');sortTable(\'tableinfo\',\'4\');" ' +
|
||||||
html += '<td onclick="setASC_DESC(\'7\');sortTable(\'tableinfo\',\'7\');" align="right">Seen</td></thead><tbody>';
|
'align="right">Speed</td>';
|
||||||
|
html += '<td onclick="setASC_DESC(\'5\');sortTable(\'tableinfo\',\'5\');" ' +
|
||||||
|
'align="right">Track</td>';
|
||||||
|
html += '<td onclick="setASC_DESC(\'6\');sortTable(\'tableinfo\',\'6\');" ' +
|
||||||
|
'align="right">Msgs</td>';
|
||||||
|
html += '<td onclick="setASC_DESC(\'7\');sortTable(\'tableinfo\',\'7\');" ' +
|
||||||
|
'align="right">Seen</td></thead><tbody>';
|
||||||
for (var tablep in Planes) {
|
for (var tablep in Planes) {
|
||||||
var tableplane = Planes[tablep]
|
var tableplane = Planes[tablep]
|
||||||
if (!tableplane.reapable) {
|
if (!tableplane.reapable) {
|
||||||
|
@ -401,8 +410,15 @@ function refreshTableInfo() {
|
||||||
} else {
|
} else {
|
||||||
html += '<td align="right"> </td>';
|
html += '<td align="right"> </td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Metric) {
|
||||||
|
html += '<td align="right">' + Math.round(tableplane.altitude / 3.2828) + '</td>';
|
||||||
|
html += '<td align="right">' + Math.round(tableplane.speed * 1.852) + '</td>';
|
||||||
|
} else {
|
||||||
html += '<td align="right">' + tableplane.altitude + '</td>';
|
html += '<td align="right">' + tableplane.altitude + '</td>';
|
||||||
html += '<td align="right">' + tableplane.speed + '</td>';
|
html += '<td align="right">' + tableplane.speed + '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
html += '<td align="right">';
|
html += '<td align="right">';
|
||||||
if (tableplane.vTrack) {
|
if (tableplane.vTrack) {
|
||||||
html += normalizeTrack(tableplane.track, tableplane.vTrack)[2];
|
html += normalizeTrack(tableplane.track, tableplane.vTrack)[2];
|
||||||
|
@ -537,3 +553,28 @@ function settingToggle() {
|
||||||
console.log("Settings Click");
|
console.log("Settings Click");
|
||||||
$("#options").toggleClass("notvisable");
|
$("#options").toggleClass("notvisable");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function drawCircle(marker, distance) {
|
||||||
|
if (typeof distance === 'undefined') {
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!(!isNaN(parseFloat(distance)) && isFinite(distance)) || distance < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
distance *= 1000.0;
|
||||||
|
if (!Metric) {
|
||||||
|
distance *= 1.852;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add circle overlay and bind to marker
|
||||||
|
var circle = new google.maps.Circle({
|
||||||
|
map: GoogleMap,
|
||||||
|
radius: distance, // In meters
|
||||||
|
fillOpacity: 0.0,
|
||||||
|
strokeWeight: 1,
|
||||||
|
strokeOpacity: 0.3
|
||||||
|
});
|
||||||
|
circle.bindTo('center', marker, 'position');
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue