From fddb2298ee4832617f6483591d80ce1a009f2b4d Mon Sep 17 00:00:00 2001 From: James Wilson Date: Fri, 10 Feb 2017 12:18:13 -0600 Subject: [PATCH] Clean up SVG rendering. Use the new flightfeeder key in status.json --- public_html/markers.js | 9 ++++---- public_html/planeObject.js | 45 ++++++-------------------------------- public_html/script.js | 2 +- 3 files changed, 13 insertions(+), 43 deletions(-) diff --git a/public_html/markers.js b/public_html/markers.js index 90ab58c..444296d 100755 --- a/public_html/markers.js +++ b/public_html/markers.js @@ -10,7 +10,8 @@ var shapes = { }, 'balloon': { svg: 'balloon_live', - size: [9,13] + size: [9,13], + noRotate: true }, 'cessna': { svg: 'cessna_live', @@ -285,12 +286,12 @@ function getBaseMarker(category, typeDesignator, typeDescription, wtc) { return shapes['unknown']; } -function svgPathToSvg(path, size, stroke, width, fill, transparentBorderWidth) { +function svgPathToSvg(path, stroke, fill) { path = path.replace('aircraft_color_fill', fill).replace('aircraft_color_stroke', stroke); return path; } -function svgPathToURI(path, size, stroke, width, fill, transparentBorderWidth) { - return "data:image/svg+xml;base64," + btoa(svgPathToSvg(path, size, stroke, width, fill, transparentBorderWidth)); +function svgPathToURI(path, stroke, fill) { + return "data:image/svg+xml;base64," + btoa(svgPathToSvg(path, stroke, fill)); } diff --git a/public_html/planeObject.js b/public_html/planeObject.js index 7442a94..c117408 100644 --- a/public_html/planeObject.js +++ b/public_html/planeObject.js @@ -353,7 +353,6 @@ PlaneObject.prototype.updateIcon = function() { var opacity = 1.0; var outline = (this.position_from_mlat ? OutlineMlatColor : OutlineADSBColor); var baseMarker = getBaseMarker(this.category, this.icaotype, this.typeDescription, this.wtc); - //var weight = ((this.selected && !SelectedAllPlanes ? 2 : 1) / baseMarker.scale / scaleFactor).toFixed(1); var rotation = (this.track === null ? 0 : this.track); //var transparentBorderWidth = (32 / baseMarker.scale / scaleFactor).toFixed(1); @@ -369,48 +368,18 @@ PlaneObject.prototype.updateIcon = function() { anchorYUnits: 'fraction', scale: 1.2 * scaleFactor, imgSize: baseMarker.size, - src: svgPathToURI(baseMarker.svg, baseMarker.size, outline, '', col, ''), + src: svgPathToURI(baseMarker.svg, outline, col), rotation: (baseMarker.noRotate ? 0 : rotation * Math.PI / 180.0), opacity: opacity, rotateWithView: (baseMarker.noRotate ? false : true) }); - if (baseMarker.noRotate) { - // the base marker won't be rotated - this.markerStaticIcon = icon; - this.markerStaticStyle = new ol.style.Style({ - image: this.markerStaticIcon - }); - - // create an arrow that we will rotate around the base marker - // to indicate heading - - var offset = baseMarker.markerRadius * baseMarker.scale + 6; - var size = offset * 2; - - var arrowPath = "M " + offset + ",0 m 4,4 -8,0 4,-4 z"; - this.markerIcon = new ol.style.Icon({ - anchor: [offset, offset], - anchorXUnits: 'pixels', - anchorYUnits: 'pixels', - scale: 1.0 * scaleFactor, - imgSize: [size, size], - src: svgPathToURI(arrowPath, [size, size], outline, 1, outline, 0), - rotation: rotation * Math.PI / 180.0, - opacity: opacity, - rotateWithView: true - }); - this.markerStyle = new ol.style.Style({ - image: this.markerIcon - }); - } else { - this.markerIcon = icon; - this.markerStyle = new ol.style.Style({ - image: this.markerIcon - }); - this.markerStaticIcon = null; - this.markerStaticStyle = new ol.style.Style({}); - } + this.markerIcon = icon; + this.markerStyle = new ol.style.Style({ + image: this.markerIcon + }); + this.markerStaticIcon = null; + this.markerStaticStyle = new ol.style.Style({}); this.markerStyleKey = styleKey; this.markerSvgKey = svgKey; diff --git a/public_html/script.js b/public_html/script.js index 59509f2..ea3431f 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -1632,7 +1632,7 @@ function toggleLayer(element, layer) { function flightFeederCheck() { $.ajax('/status.json', { success: function(data) { - if (typeof data.serial !== 'undefined') { + if (data.type === "flightfeeder") { isFlightFeeder = true; updatePiAwareOrFlightFeeder(); }