diff --git a/html/config.js b/html/config.js index 8f316c3..7d60a13 100644 --- a/html/config.js +++ b/html/config.js @@ -361,6 +361,10 @@ HideCols = [ //tableInView = false; // only show aircraft in current view (V button) + +// aiscatcher_server = "http://192.168.1.113:8100"; // update with your server address +// aiscatcher_refresh = 15; // refresh interval in seconds + /* tableColors = { unselected: { diff --git a/html/defaults.js b/html/defaults.js index f877499..988b72f 100644 --- a/html/defaults.js +++ b/html/defaults.js @@ -372,6 +372,10 @@ let darkModeDefault = true; // turn on dark mode by default (change in browser p let tableInView = false; // only show aircraft in current view (V button) + +let aiscatcher_server = ""; +let aiscatcher_refresh = 15; + // legacy variables let OutlineMlatColor = null; diff --git a/html/layers.js b/html/layers.js index 07e10ea..6029344 100644 --- a/html/layers.js +++ b/html/layers.js @@ -820,6 +820,66 @@ function createBaseLayers() { } } + if (aiscatcher_server) { + + g.aiscatcher_source = new ol.source.Vector({ + url: aiscatcher_server + '/geojson', + format: new ol.format.GeoJSON() + }); + + const aiscatcher_mapping = { + 0: { size: [20, 20], offset: [120, 20], comment: 'CLASS_OTHER' }, + 1: { size: [20, 20], offset: [120, 20], comment: 'CLASS_UNKNOWN' }, + 2: { size: [20, 20], offset: [0, 20], comment: 'CLASS_CARGO' }, + 3: { size: [20, 20], offset: [20, 20], comment: 'CLASS_B' }, + 4: { size: [20, 20], offset: [40, 20], comment: 'CLASS_PASSENGER' }, + 5: { size: [20, 20], offset: [60, 20], comment: 'CLASS_SPECIAL' }, + 6: { size: [20, 20], offset: [80, 20], comment: 'CLASS_TANKER' }, + 7: { size: [20, 20], offset: [100, 20], comment: 'CLASS_HIGHSPEED' }, + 8: { size: [20, 20], offset: [140, 20], comment: 'CLASS_FISHING' }, + 9: { size: [25, 25], offset: [0, 60], comment: 'CLASS_PLANE' }, + 10: { size: [25, 25], offset: [0, 85], comment: 'CLASS_HELICOPTER' }, + 11: { size: [20, 20], offset: [20, 40], comment: 'CLASS_STATION' }, + 12: { size: [20, 20], offset: [0, 40], comment: 'CLASS_ATON' }, + 13: { size: [20, 20], offset: [40, 40], comment: 'CLASS_SARTEPIRB' } + }; + + var aiscatcher_overlay = new ol.layer.Vector({ + type: 'overlay', + title: "aiscatcher", + name: "aiscatcher", + zIndex: 99, + source: g.aiscatcher_source, + + style: function (feature) { + const cog = feature.get('cog'); + const rotation = (cog || 0) * (Math.PI / 180); + const shipclass = feature.get('shipclass'); + const speed = feature.get('speed'); + + const ofs = aiscatcher_mapping[shipclass].offset; + const size = aiscatcher_mapping[shipclass].size; + + let o + if (speed && speed > 0.5) + o = [ofs[0], 0]; + else + o = ofs; + + return new ol.style.Style({ + image: new ol.style.Icon({ + src: aiscatcher_server + '/icons.png', + anchor: [0.5, 0.5], + rotation: rotation, + size: size, + offset: o + }) + }); + } + }); + world.push(aiscatcher_overlay); + } + layers.push(new ol.layer.Group({ name: 'custom', title: 'Custom', diff --git a/html/script.js b/html/script.js index 99e10a6..9f96f70 100644 --- a/html/script.js +++ b/html/script.js @@ -1862,6 +1862,8 @@ function parseHistory() { } let replay_was_active = false; + + let timers = {}; let timersActive = false; function clearIntervalTimers(arg) { @@ -1915,6 +1917,12 @@ function setIntervalTimers() { timers.drawOutline = window.setInterval(drawOutlineJson, actualOutline.refresh); drawOutlineJson(); } + + if (aiscatcher_server) { + function updateAIScatcher() { g.aiscatcher_source.refresh(); } + setInterval(updateAIScatcher, aiscatcher_refresh * 1000); + updateAIScatcher(); + } } let djson;