From a1f6cd20c54a7d03eb09ee772d7d4452750bb45f Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Thu, 15 Aug 2019 20:20:06 +0200 Subject: [PATCH] scale icons a bit depending on aircraft size --- html/markers.js | 262 +++++++++++++++++++++++--------------------- html/planeObject.js | 14 ++- html/script.js | 3 +- 3 files changed, 151 insertions(+), 128 deletions(-) diff --git a/html/markers.js b/html/markers.js index 088cc5d..1227909 100644 --- a/html/markers.js +++ b/html/markers.js @@ -72,142 +72,156 @@ var shapes = { } var TypeDesignatorIcons = { - 'A318': 'airliner', // shortened a320 - 'A319': 'airliner', // shortened a320 - 'A320': 'airliner', - 'A321': 'airliner', // stretched a320 + 'A318': ['airliner', 0.90], // shortened a320 + 'A319': ['airliner', 0.92], // shortened a320 + 'A320': ['airliner', 0.96], + 'A321': ['airliner', 1.02], // stretched a320 - 'A330': 'heavy_2e', - 'A332': 'heavy_2e', - 'A333': 'heavy_2e', - 'DC10': 'heavy_2e', - 'MD11': 'heavy_2e', + 'A330': ['heavy_2e', 1], + 'A332': ['heavy_2e', 1], + 'A333': ['heavy_2e', 1], + 'DC10': ['heavy_2e', 1], + 'MD11': ['heavy_2e', 1], - 'A388': 'heavy_4e', + 'A388': ['heavy_4e', 1.08], // dubious since these are old-generation 737s // but the shape is similar - 'B731': 'airliner', - 'B732': 'airliner', - 'B733': 'airliner', - 'B734': 'airliner', - 'B735': 'airliner', + 'B731': ['airliner', 0.8], + 'B732': ['airliner', 0.8], + 'B733': ['airliner', 0.8], + 'B734': ['airliner', 0.9], + 'B735': ['airliner', 1], // these probably need reworking // since they vary in length - 'B736': 'airliner', - 'B737': 'airliner', - 'B738': 'airliner', - 'B739': 'airliner', + 'B736': ['airliner', 0.90], + 'B737': ['airliner', 0.92], + 'B738': ['airliner', 0.96], + 'B739': ['airliner', 1], - 'B741': 'heavy_4e', - 'B742': 'heavy_4e', - 'B743': 'heavy_4e', - 'B744': 'heavy_4e', - 'B74D': 'heavy_4e', - 'B74S': 'heavy_4e', - 'B74R': 'heavy_4e', - 'BLCF': 'heavy_2e', - 'BSCA': 'heavy_4e', // hah! - 'B748': 'heavy_4e', + 'B741': ['heavy_4e', 1], + 'B742': ['heavy_4e', 1], + 'B743': ['heavy_4e', 1], + 'B744': ['heavy_4e', 1], + 'B74D': ['heavy_4e', 1], + 'B74S': ['heavy_4e', 1], + 'B74R': ['heavy_4e', 1], + 'BLCF': ['heavy_2e', 1], + 'BSCA': ['heavy_4e', 1], // hah! + 'B748': ['heavy_4e', 1], - 'B772': 'heavy_2e', // all pretty similar except for length - 'B77W': 'heavy_2e', - 'B773': 'heavy_2e', - 'B77L': 'heavy_2e', + 'B752': ['airliner', 1.04], + 'B753': ['airliner', 1.04], - 'E170': 'jet_swept', - 'E45X': 'jet_swept', - 'B712': 'jet_swept', - 'C650': 'jet_swept', - 'C750': 'jet_swept', - 'E135': 'jet_swept', - 'E145': 'jet_swept', - 'CL30': 'jet_swept', - 'CL35': 'jet_swept', - 'CL60': 'jet_swept', - 'GL5T': 'jet_swept', - 'GLF2': 'jet_swept', // close enough - 'GLF3': 'jet_swept', - 'GLF4': 'jet_swept', - 'GLF5': 'jet_swept', - 'GLF6': 'jet_swept', - 'CRJ1': 'jet_swept', - 'CRJ2': 'jet_swept', - 'CRJ7': 'jet_swept', - 'CRJ9': 'jet_swept', - 'H25A': 'jet_swept', - 'H25B': 'jet_swept', - 'H25C': 'jet_swept', - 'MD80': 'jet_swept', - 'MD81': 'jet_swept', - 'MD82': 'jet_swept', - 'MD83': 'jet_swept', - 'MD87': 'jet_swept', - 'MD88': 'jet_swept', + 'B772': ['heavy_2e', 1.04], // all pretty similar except for length + 'B77W': ['heavy_2e', 1.04], + 'B773': ['heavy_2e', 1.04], + 'B77L': ['heavy_2e', 1.04], + + 'E170': ['jet_swept', 1], + 'E45X': ['jet_swept', 1], + 'B712': ['jet_swept', 1], + 'C56X': ['jet_swept', 0.92], + 'C510': ['jet_swept', 0.92], + 'C25A': ['jet_swept', 0.92], + 'C525': ['jet_swept', 0.92], + 'C550': ['jet_swept', 0.92], + 'C560': ['jet_swept', 0.92], + 'C650': ['jet_swept', 0.92], + 'C68A': ['jet_swept', 0.92], + 'C750': ['jet_swept', 0.92], + 'E55P': ['jet_swept', 0.88], + 'E135': ['jet_swept', 1], + 'E145': ['jet_swept', 1], + 'CL30': ['jet_swept', 1], + 'CL35': ['jet_swept', 1], + 'CL60': ['jet_swept', 1], + 'GLEX': ['jet_swept', 1], + 'GL5T': ['jet_swept', 1], + 'GLF2': ['jet_swept', 1], + 'GLF3': ['jet_swept', 1], + 'GLF4': ['jet_swept', 1], + 'GLF5': ['jet_swept', 1], + 'GLF6': ['jet_swept', 1], + 'CRJ1': ['jet_swept', 1], + 'CRJ2': ['jet_swept', 1], + 'CRJ7': ['jet_swept', 1], + 'CRJ9': ['jet_swept', 1], + 'H25A': ['jet_swept', 0.92], + 'H25B': ['jet_swept', 0.92], + 'H25C': ['jet_swept', 0.92], + 'LR45': ['jet_swept', 0.92], + 'MD80': ['jet_swept', 1], + 'MD81': ['jet_swept', 1], + 'MD82': ['jet_swept', 1], + 'MD83': ['jet_swept', 1], + 'MD87': ['jet_swept', 1], + 'MD88': ['jet_swept', 1], + + 'PRM1': ['jet_swept', 0.88], + 'A37': ['hi_perf', 1], + 'A700': ['hi_perf', 1], + 'LEOP': ['hi_perf', 1], + 'ME62': ['hi_perf', 1], + 'T2': ['hi_perf', 1], + 'T37': ['hi_perf', 1], + 'T38': ['hi_perf', 1], + 'A10': ['hi_perf', 1], + 'A148': ['hi_perf', 1], + 'A3': ['hi_perf', 1], + 'A6': ['hi_perf', 1], + 'AJET': ['hi_perf', 1], + 'AT3': ['hi_perf', 1], + 'CKUO': ['hi_perf', 1], + 'EUFI': ['hi_perf', 1], + 'F1': ['hi_perf', 1], + 'F100': ['hi_perf', 1], + 'F111': ['hi_perf', 1], + 'F117': ['hi_perf', 1], + 'F14': ['hi_perf', 1], + 'F15': ['hi_perf', 1], + 'F18': ['hi_perf', 1], + 'F22': ['hi_perf', 1], + 'F22A': ['hi_perf', 1], + 'F4': ['hi_perf', 1], + 'F5': ['hi_perf', 1], + 'FOUG': ['hi_perf', 1], + 'J8A': ['hi_perf', 1], + 'J8B': ['hi_perf', 1], + 'JH7': ['hi_perf', 1], + 'LTNG': ['hi_perf', 1], + 'METR': ['hi_perf', 1], + 'MG19': ['hi_perf', 1], + 'MG25': ['hi_perf', 1], + 'MG29': ['hi_perf', 1], + 'MG31': ['hi_perf', 1], + 'MG44': ['hi_perf', 1], + 'MIR4': ['hi_perf', 1], + 'MT2': ['hi_perf', 1], + 'Q5': ['hi_perf', 1], + 'RFAL': ['hi_perf', 1], + 'S3': ['hi_perf', 1], + 'S37': ['hi_perf', 1], + 'SR71': ['hi_perf', 1], + 'SU15': ['hi_perf', 1], + 'SU24': ['hi_perf', 1], + 'SU25': ['hi_perf', 1], + 'SU27': ['hi_perf', 1], + 'T22M': ['hi_perf', 1], + 'T4': ['hi_perf', 1], + 'TOR': ['hi_perf', 1], + 'TU22': ['hi_perf', 1], + 'VAUT': ['hi_perf', 1], + 'WB57': ['hi_perf', 1], + 'Y130': ['hi_perf', 1], + 'YK28': ['hi_perf', 1], + // 'BE20': [_b200, 1], - 'A37': 'hi_perf', - 'A700': 'hi_perf', - 'LEOP': 'hi_perf', - 'ME62': 'hi_perf', - 'T2': 'hi_perf', - 'T37': 'hi_perf', - 'T38': 'hi_perf', - 'A10': 'hi_perf', - 'A148': 'hi_perf', - 'A3': 'hi_perf', - 'A6': 'hi_perf', - 'AJET': 'hi_perf', - 'AT3': 'hi_perf', - 'CKUO': 'hi_perf', - 'EUFI': 'hi_perf', - 'F1': 'hi_perf', - 'F100': 'hi_perf', - 'F111': 'hi_perf', - 'F117': 'hi_perf', - 'F14': 'hi_perf', - 'F15': 'hi_perf', - 'F18': 'hi_perf', - 'F22': 'hi_perf', - 'F22A': 'hi_perf', - 'F4': 'hi_perf', - 'F5': 'hi_perf', - 'FOUG': 'hi_perf', - 'J8A': 'hi_perf', - 'J8B': 'hi_perf', - 'JH7': 'hi_perf', - 'LTNG': 'hi_perf', - 'METR': 'hi_perf', - 'MG19': 'hi_perf', - 'MG25': 'hi_perf', - 'MG29': 'hi_perf', - 'MG31': 'hi_perf', - 'MG44': 'hi_perf', - 'MIR4': 'hi_perf', - 'MT2': 'hi_perf', - 'Q5': 'hi_perf', - 'RFAL': 'hi_perf', - 'S3': 'hi_perf', - 'S37': 'hi_perf', - 'SR71': 'hi_perf', - 'SU15': 'hi_perf', - 'SU24': 'hi_perf', - 'SU25': 'hi_perf', - 'SU27': 'hi_perf', - 'T22M': 'hi_perf', - 'T4': 'hi_perf', - 'TOR': 'hi_perf', - 'TU22': 'hi_perf', - 'VAUT': 'hi_perf', - 'WB57': 'hi_perf', - 'Y130': 'hi_perf', - 'YK28': 'hi_perf', - // 'BE20': _b200, - - // 'C130': _c130, - // 'C30J': _c130 + // 'C130': [_c130, 1], + // 'C30J': [_c130 }; // Maps ICAO aircraft type description codes (e.g. "L2J") to aircraft icons. This is used if the ICAO type designator (e.g. "B731") @@ -259,7 +273,9 @@ var CategoryIcons = { function getBaseMarker(category, typeDesignator, typeDescription, wtc) { if (typeDesignator in TypeDesignatorIcons) { - return shapes[TypeDesignatorIcons[typeDesignator]]; + var shape = TypeDesignatorIcons[typeDesignator][0]; + var scaling = TypeDesignatorIcons[typeDesignator][1]; + return [shapes[shape], scaling]; } if (typeDescription !== undefined && typeDescription !== null && typeDescription.length === 3) { diff --git a/html/planeObject.js b/html/planeObject.js index 4cce646..b82dfa4 100644 --- a/html/planeObject.js +++ b/html/planeObject.js @@ -83,6 +83,7 @@ function PlaneObject(icao) { this.markerIcon = null; this.markerStyleKey = null; this.markerSvgKey = null; + this.baseScale = 1; this.filter = {}; // start from a computed registration, let the DB override it @@ -495,6 +496,10 @@ PlaneObject.prototype.updateIcon = function() { if (this.baseMarkerKey != baseMarkerKey) { this.baseMarkerKey = baseMarkerKey; this.baseMarker = getBaseMarker(this.category, this.icaotype, this.typeDescription, this.wtc); + if (this.baseMarker.length == 2) { + this.baseScale = this.baseMarker[1]; + this.baseMarker = this.baseMarker[0]; + } } var rotation = this.track; if (rotation == null) { @@ -513,12 +518,13 @@ PlaneObject.prototype.updateIcon = function() { //console.log(this.icao + " new icon and style " + this.markerSvgKey + " -> " + svgKey); this.markerSvgKey = svgKey; + this.scaleCache = scaleFactor * this.baseScale; var icon = new ol.style.Icon({ anchor: [0.5, 0.5], anchorXUnits: 'fraction', anchorYUnits: 'fraction', - scale: scaleFactor, + scale: this.scaleCache, imgSize: this.baseMarker.size, src: svgPathToURI(this.baseMarker.svg, outline, col, add_stroke), rotation: (this.baseMarker.noRotate ? 0 : rotation * Math.PI / 180.0), @@ -542,9 +548,9 @@ PlaneObject.prototype.updateIcon = function() { this.markerIcon.setRotation(rotation * Math.PI / 180.0); } - if (this.scaleFactorCache != scaleFactor) { - this.scaleCache = scaleFactor; - this.markerIcon.setScale(scaleFactor); + if (this.scaleCache != scaleFactor * this.baseScale) { + this.scaleCache = scaleFactor * this.baseScale; + this.markerIcon.setScale(this.scaleCache); } /* diff --git a/html/script.js b/html/script.js index bb93003..742ac3b 100644 --- a/html/script.js +++ b/html/script.js @@ -800,7 +800,8 @@ function initialize_map() { scaleFactor = 1.2*Math.max(0.2, Math.min(1.2, 0.15 * Math.pow(1.25, ZoomLvl))); for (var plane in Planes) { if (Planes[plane].markerIcon) - Planes[plane].markerIcon.setScale(scaleFactor); + this.scaleCache = scaleFactor * this.baseScale; + Planes[plane].markerIcon.setScale(this.scaleCache); } });