Merge branch 'more_mode_s' into dev

This commit is contained in:
Oliver Jowett 2018-05-09 16:20:58 +01:00
commit f4fa94f842
45 changed files with 3533 additions and 1459 deletions

View file

@ -119,11 +119,7 @@ ChartBundleLayers = false;
//
BingMapsAPIKey = null;
// Provide a Mapzen API key here to enable the Mapzen vector tile layer.
// You can obtain a free key at https://mapzen.com/developers/
// (you need a "vector tiles" key)
//
// Be sure to quote your key:
// MapzenAPIKey = "your key here";
//
MapzenAPIKey = null;
// Turn on display of extra Mode S EHS / ADS-B v1/v2 data
// This is not polished yet (and so is disabled by default),
// currently it's just a data dump of the new fields with no UX work.
ExtendedData = false;

View file

@ -103,10 +103,10 @@
<span id="selected_squawk"></span>
</div>
<div class="infoHeading infoRowFluid fourColumnSection3">
Speed:
Groundspeed:
</div>
<div class="infoData infoRowFluid fourColumnSection4">
<span id="selected_speed">n/a</span>
<span id="selected_gs">n/a</span>
</div>
</div>
<div>
@ -127,7 +127,7 @@
<div class="infoBlockSection lightGreyBackground">
<div>
<div class="infoHeading infoRowFluid fourColumnSection1">
Heading:
Ground track:
</div>
<div class="infoData infoRowFluid fourColumnSection2">
<span id="selected_track">n/a</span>
@ -170,11 +170,73 @@
</div>
</div>
</div>
<a href="http://www.airframes.org/" onclick="document.getElementById('horrible_hack').submit.call(document.getElementById('airframes_post')); return false;" class="link rightLink">
<div id="extendedData" class="hidden">
<div class="infoBlockSection lightGreyBackground">
<div>
<div class="infoHeading infoRowFluid fourColumnSection1">Alt (geom):</div>
<div class="infoData infoRowFluid fourColumnSection2"><span id="selected_alt_geom"/></div>
<div class="infoHeading infoRowFluid fourColumnSection3">Geom rate:</div>
<div class="infoData infoRowFluid fourColumnSection4"><span id="selected_geom_rate"/></div>
</div>
</div>
<div class="infoBlockSection">
<div>
<div class="infoHeading infoRowFluid fourColumnSection1">Mag heading:</div>
<div class="infoData infoRowFluid fourColumnSection2"><span id="selected_mag_heading"/></div>
<div class="infoHeading infoRowFluid fourColumnSection3">True heading:</div>
<div class="infoData infoRowFluid fourColumnSection4"><span id="selected_true_heading"/></div>
</div>
<div>
<div class="infoHeading infoRowFluid fourColumnSection1">Roll:</div>
<div class="infoData infoRowFluid fourColumnSection2"><span id="selected_roll"/></div>
<div class="infoHeading infoRowFluid fourColumnSection3">Track rate:</div>
<div class="infoData infoRowFluid fourColumnSection4"><span id="selected_track_rate"/></div>
</div>
</div>
<div class="infoBlockSection lightGreyBackground">
<div>
<div class="infoHeading infoRowFluid fourColumnSection1">IAS:</div>
<div class="infoData infoRowFluid fourColumnSection2"><span id="selected_ias"/></div>
<div class="infoHeading infoRowFluid fourColumnSection3">TAS:</div>
<div class="infoData infoRowFluid fourColumnSection4"><span id="selected_tas"/></div>
</div>
<div>
<div class="infoHeading infoRowFluid fourColumnSection1">Mach:</div>
<div class="infoData infoRowFluid fourColumnSection2"><span id="selected_mach"/></div>
</div>
</div>
<div class="infoBlockSection">
<div>
<div class="infoHeading infoRowFluid fourColumnSection1">Nav alt:</div>
<div class="infoData infoRowFluid fourColumnSection2"><span id="selected_nav_altitude"/></div>
<div class="infoHeading infoRowFluid fourColumnSection3">Nav heading:</div>
<div class="infoData infoRowFluid fourColumnSection4"><span id="selected_nav_heading"/></div>
</div>
<div>
<div class="infoHeading infoRowFluid fourColumnSection1">Nav modes:</div>
<div class="infoData infoRowFluid fourColumnSection2"><span id="selected_nav_modes"/></div>
<div class="infoHeading infoRowFluid fourColumnSection3">Nav QNH:</div>
<div class="infoData infoRowFluid fourColumnSection4"><span id="selected_nav_qnh"/></div>
</div>
</div>
<div class="infoBlockSection lightGreyBackground">
<div>
<div class="infoHeading infoRowFluid fourColumnSection1">ADS-B:</div>
<div class="infoData infoRowFluid fourColumnSection2"><span id="selected_version"/></div>
</div>
</div>
</div>
<a href="http://www.airframes.org/" onclick="document.getElementById('horrible_hack').submit.call(document.getElementById('airframes_post')); return false;" class="link rightLink">
AirFrames.org
</a>
<span id="selected_photo_link" class="link"></span>
</div>
</div>
</div> <!-- selected_infoblock -->

View file

@ -37,15 +37,11 @@ function createBaseLayers() {
}));
}
if (MapzenAPIKey) {
world.push(createMapzenLayer());
}
if (ChartBundleLayers) {
var chartbundleTypes = {
sec: "Sectional Charts",
tac: "Terminal Area Charts",
wac: "World Aeronautical Charts",
hel: "Helicopter Charts",
enrl: "IFR Enroute Low Charts",
enra: "IFR Area Charts",
enrh: "IFR Enroute High Charts"
@ -105,99 +101,3 @@ function createBaseLayers() {
return layers;
}
function createMapzenLayer() {
// draw earth with a fat stroke;
// force water above earth
var earthStyle = new ol.style.Style({
fill: new ol.style.Fill({
color: '#a06000'
}),
stroke: new ol.style.Stroke({
color: '#a06000',
width: 5.0
}),
zIndex: 0
});
var waterStyle = new ol.style.Style({
fill: new ol.style.Fill({
color: '#0040a0'
}),
stroke: new ol.style.Stroke({
color: '#0040a0',
width: 1.0
}),
zIndex: 1
});
var boundaryStyle = new ol.style.Style({
stroke: new ol.style.Stroke({
color: '#804000',
width: 2.0
}),
zIndex: 2
});
var dashedBoundaryStyle = new ol.style.Style({
stroke: new ol.style.Stroke({
color: '#804000',
width: 1.0,
lineDash: [4, 4],
}),
zIndex: 2
});
var styleMap = {
earth: earthStyle,
water: waterStyle,
basin: waterStyle,
dock: waterStyle,
lake: waterStyle,
ocean: waterStyle,
riverbank: waterStyle,
river: waterStyle,
country: boundaryStyle,
disputed: dashedBoundaryStyle,
indefinite: dashedBoundaryStyle,
indeterminate: dashedBoundaryStyle,
line_of_control: dashedBoundaryStyle
};
return new ol.layer.VectorTile({
name: 'mapzen_vector',
title: 'Mapzen coastlines and water',
type: 'base',
renderMode: 'image',
renderOrder: function(a,b) {
return a.get('sort_key') - b.get('sort_key');
},
source: new ol.source.VectorTile({
url: '//vector.mapzen.com/osm/earth,water,boundaries/{z}/{x}/{y}.topojson?api_key=' + MapzenAPIKey,
format: new ol.format.TopoJSON(),
attributions: [
new ol.Attribution({
html: 'Tiles courtesy of <a href="http://mapzen.com">Mapzen</a>'
}),
new ol.Attribution({
html: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
})
],
tileGrid: ol.tilegrid.createXYZ({
preload: 3,
maxZoom: 14,
tileSize: [512, 512]
}),
wrapX: true
}),
style: function (feature) {
return (styleMap[feature.get('kind')]);
}
});
}

View file

@ -10,9 +10,32 @@ function PlaneObject(icao) {
this.category = null;
// Basic location information
this.altitude = null;
this.speed = null;
this.track = null;
this.altitude = null;
this.alt_baro = null;
this.alt_geom = null;
this.speed = null;
this.gs = null;
this.ias = null;
this.tas = null;
this.track = null;
this.track_rate = null;
this.mag_heading = null;
this.true_heading = null;
this.mach = null;
this.roll = null;
this.nav_altitude = null;
this.nav_heading = null;
this.nav_modes = null;
this.nav_qnh = null;
this.baro_rate = null;
this.geom_rate = null;
this.vert_rate = null;
this.version = null;
this.prev_position = null;
this.position = null;
this.position_from_mlat = false
@ -410,21 +433,35 @@ PlaneObject.prototype.updateData = function(receiver_timestamp, data) {
this.messages = data.messages;
this.rssi = data.rssi;
this.last_message_time = receiver_timestamp - data.seen;
// simple fields
var fields = ["alt_baro", "alt_geom", "gs", "ias", "tas", "track",
"track_rate", "mag_heading", "true_heading", "mach",
"roll", "nav_altitude", "nav_heading", "nav_modes",
"nav_qnh", "baro_rate", "geom_rate",
"squawk", "category", "version"];
for (var i = 0; i < fields.length; ++i) {
if (fields[i] in data) {
this[fields[i]] = data[fields[i]];
} else {
this[fields[i]] = null;
}
}
// fields with more complex behaviour
if (typeof data.type !== "undefined")
if ('type' in data)
this.addrtype = data.type;
else
this.addrtype = 'adsb_icao';
if (typeof data.altitude !== "undefined")
this.altitude = data.altitude;
if (typeof data.vert_rate !== "undefined")
this.vert_rate = data.vert_rate;
if (typeof data.speed !== "undefined")
this.speed = data.speed;
if (typeof data.track !== "undefined")
this.track = data.track;
if (typeof data.lat !== "undefined") {
// don't expire callsigns
if ('flight' in data)
this.flight = data.flight;
if ('lat' in data && 'lon' in data) {
this.position = [data.lon, data.lat];
this.last_position_time = receiver_timestamp - data.seen_pos;
@ -443,12 +480,36 @@ PlaneObject.prototype.updateData = function(receiver_timestamp, data) {
}
}
}
if (typeof data.flight !== "undefined")
this.flight = data.flight;
if (typeof data.squawk !== "undefined")
this.squawk = data.squawk;
if (typeof data.category !== "undefined")
this.category = data.category;
// Pick an altitude
if ('alt_baro' in data) {
this.altitude = data.alt_baro;
} else if ('alt_geom' in data) {
this.altitude = data.alt_geom;
} else {
this.altitude = null;
}
// Pick vertical rate from either baro or geom rate
// geometric rate is generally more reliable (smoothed etc)
if ('geom_rate' in data) {
this.vert_rate = data.geom_rate;
} else if ('baro_rate' in data) {
this.vert_rate = data.baro_rate;
} else {
this.vert_rate = null;
}
// Pick a speed
if ('gs' in data) {
this.speed = data.gs;
} else if ('tas' in data) {
this.speed = data.tas;
} else if ('ias' in data) {
this.speed = data.ias;
} else {
this.speed = null;
}
};
PlaneObject.prototype.updateTick = function(receiver_timestamp, last_timestamp) {

View file

@ -197,7 +197,11 @@ function initialize() {
refreshClock();
$("#loader").removeClass("hidden");
if (ExtendedData || window.location.hash == '#extended') {
$("#extendedData").removeClass("hidden");
}
// Set up map/sidebar splitter
$("#sidebar_container").resizable({handles: {w: '#splitter'}});
@ -883,7 +887,7 @@ function refreshSelected() {
$('#selected_squawk').text(selected.squawk);
}
$('#selected_speed').text(format_speed_long(selected.speed, DisplayUnits));
$('#selected_gs').text(format_speed_long(selected.gs, DisplayUnits));
$('#selected_vertical_rate').text(format_vert_rate_long(selected.vert_rate, DisplayUnits));
$('#selected_icao').text(selected.icao.toUpperCase());
$('#airframes_post_icao').attr('value',selected.icao);
@ -936,6 +940,52 @@ function refreshSelected() {
$('#selected_rssi').text(selected.rssi.toFixed(1) + ' dBFS');
$('#selected_message_count').text(selected.messages);
$('#selected_photo_link').html(getFlightAwarePhotoLink(selected.registration));
$('#selected_alt_geom').text(format_altitude_long(selected.alt_geom, selected.geom_rate, DisplayUnits));
$('#selected_mag_heading').text(format_track_long(selected.mag_heading));
$('#selected_true_heading').text(format_track_long(selected.true_heading));
$('#selected_ias').text(format_speed_long(selected.ias, DisplayUnits));
$('#selected_tas').text(format_speed_long(selected.tas, DisplayUnits));
if (selected.mach == null) {
$('#selected_mach').text('n/a');
} else {
$('#selected_mach').text(selected.mach.toFixed(3));
}
if (selected.roll == null) {
$('#selected_roll').text('n/a');
} else {
$('#selected_roll').text(selected.roll.toFixed(1));
}
if (selected.track_rate == null) {
$('#selected_track_rate').text('n/a');
} else {
$('#selected_track_rate').text(selected.track_rate.toFixed(2));
}
$('#selected_geom_rate').text(format_vert_rate_long(selected.geom_rate, DisplayUnits));
if (selected.nav_qnh == null) {
$('#selected_nav_qnh').text("n/a");
} else {
$('#selected_nav_qnh').text(selected.nav_qnh.toFixed(1) + " hPa");
}
$('#selected_nav_altitude').text(format_altitude_long(selected.nav_altitude, 0, DisplayUnits));
$('#selected_nav_heading').text(format_track_long(selected.nav_heading));
if (selected.nav_modes == null) {
$('#selected_nav_modes').text("n/a");
} else {
$('#selected_nav_modes').text(selected.nav_modes.join());
}
if (selected.version == null) {
$('#selected_version').text('none');
} else if (selected.version == 0) {
$('#selected_version').text('v0 (DO-260)');
} else if (selected.version == 1) {
$('#selected_version').text('v1 (DO-260A)');
} else if (selected.version == 2) {
$('#selected_version').text('v2 (DO-260B)');
} else {
$('#selected_version').text('v' + selected.version);
}
}
function refreshHighlighted() {
@ -1039,7 +1089,7 @@ function refreshTableInfo() {
tableplane.tr.cells[4].textContent = (tableplane.icaotype !== null ? tableplane.icaotype : "");
tableplane.tr.cells[5].textContent = (tableplane.squawk !== null ? tableplane.squawk : "");
tableplane.tr.cells[6].innerHTML = format_altitude_brief(tableplane.altitude, tableplane.vert_rate, DisplayUnits);
tableplane.tr.cells[7].textContent = format_speed_brief(tableplane.speed, DisplayUnits);
tableplane.tr.cells[7].textContent = format_speed_brief(tableplane.gs, DisplayUnits);
tableplane.tr.cells[8].textContent = format_vert_rate_brief(tableplane.vert_rate, DisplayUnits);
tableplane.tr.cells[9].textContent = format_distance_brief(tableplane.sitedist, DisplayUnits);
tableplane.tr.cells[10].textContent = format_track_brief(tableplane.track);
@ -1090,7 +1140,7 @@ function sortByRegistration() { sortBy('registration', compareAlpha, func
function sortByAircraftType() { sortBy('icaotype', compareAlpha, function(x) { return x.icaotype; }); }
function sortBySquawk() { sortBy('squawk', compareAlpha, function(x) { return x.squawk; }); }
function sortByAltitude() { sortBy('altitude',compareNumeric, function(x) { return (x.altitude == "ground" ? -1e9 : x.altitude); }); }
function sortBySpeed() { sortBy('speed', compareNumeric, function(x) { return x.speed; }); }
function sortBySpeed() { sortBy('speed', compareNumeric, function(x) { return x.gs; }); }
function sortByVerticalRate() { sortBy('vert_rate', compareNumeric, function(x) { return x.vert_rate; }); }
function sortByDistance() { sortBy('sitedist',compareNumeric, function(x) { return x.sitedist; }); }
function sortByTrack() { sortBy('track', compareNumeric, function(x) { return x.track; }); }