// -*- mode: javascript; indent-tabs-mode: nil; c-basic-offset: 8 -*-
"use strict";
// FA icons
let shapes = {
'airliner': {
svg: '',
size: [25,26]
},
'balloon': {
svg: '',
size: [9,13],
noRotate: true
},
'cessna': {
svg: '',
size: [22,16]
},
'heavy_2e': {
svg: '',
size: [28,29]
},
//MD Series
//MD11 - Standard Scale 63px, 3in4 Non-linear Scale 53px
'md11': {
svg: '',
size: [36,31]
},
'heavy_4e': {
svg: '',
size: [28,30]
},
'helicopter': {
svg: '',
size: [16,18]
},
'hi_perf': {
svg: '',
size: [15,21]
},
'single_turbo': {
svg: '',
size: [18,18]
},
'jet_nonswept': {
svg: '',
size: [22,22]
},
'jet_swept': {
svg: '',
size: [18,24]
},
'twin_large': {
svg: '',
size: [21,20]
},
'twin_small': {
svg: '',
size: [21,18]
},
'ground_emergency': {
svg: '',
size: [6, 15]
},
'ground_service': {
svg: '',
size: [6, 15]
},
'ground_unknown': {
svg: '',
size: [6, 15]
},
'ground_fixed': {
svg: '',
size: [12, 12]
},
'unknown': {
svg: '',
size: [17,17]
}
}
let TypeDesignatorIcons = {
'SHIP': ['balloon', 1], // Blimp
'A318': ['airliner', 0.88], // shortened a320 68t
'A319': ['airliner', 0.92], // shortened a320 75t
'A19N': ['airliner', 0.92], // shortened a320
'A320': ['airliner', 0.96], // 78t
'A20N': ['airliner', 0.96],
'A321': ['airliner', 1.02], // stretched a320 93t
'A21N': ['airliner', 1.02], // stretched a320
'A306': ['heavy_2e', 0.96],
'A330': ['heavy_2e', 1],
'A332': ['heavy_2e', 1],
'A333': ['heavy_2e', 1],
'A338': ['heavy_2e', 1], // 800 neo
'A339': ['heavy_2e', 1], // 900 neo
'DC10': ['md11', 0.96],
'MD11': ['md11', 1],
'A359': ['heavy_2e', 1.04],
'A35K': ['heavy_2e', 1.06],
'A388': ['heavy_4e', 1.08],
// dubious since these are old-generation 737s
// but the shape is similar
'B731': ['airliner', 0.88],
'B732': ['airliner', 0.88],
'B733': ['airliner', 0.88],
'B734': ['airliner', 0.94],
'B735': ['airliner', 0.96],
// these probably need reworking
// since they vary in length
'B736': ['airliner', 0.92],
'B737': ['airliner', 0.94],
'B738': ['airliner', 0.96],
'B739': ['airliner', 1],
'J328': ['airliner', 0.78], // 15t
'E170': ['airliner', 0.82], // 38t
'E75S/L': ['airliner', 0.82],
'E75L': ['airliner', 0.82],
'E75S': ['airliner', 0.82], // 40t
'E190': ['airliner', 0.84], // 52t
'E195': ['airliner', 0.84], // 52t
'E290': ['airliner', 0.84], // 56t
'E295': ['airliner', 0.86], // 62t
'BCS1': ['airliner', 0.86], // 64t
'BCS3': ['airliner', 0.88], // 70t
'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.02],
'B752': ['airliner', 1.04],
'B753': ['airliner', 1.04],
'B772': ['heavy_2e', 1.04], // all pretty similar except for length
'B773': ['heavy_2e', 1.06],
'B77L': ['heavy_2e', 1.06],
'B77W': ['heavy_2e', 1.08],
'C680': ['jet_swept', 0.92], // 14t
'C68A': ['jet_swept', 0.92], // 14t
'C750': ['jet_swept', 0.94], // 17t
'FA50': ['jet_swept', 0.94], // 18t
'CL30': ['jet_swept', 0.92], // 14t
'CL35': ['jet_swept', 0.92],
'CL60': ['jet_swept', 0.96], // 22t
'GLEX': ['jet_swept', 1],
'G200': ['jet_swept', 0.92], // 16t
'G280': ['jet_swept', 0.92], // 18t
'GL5T': ['jet_swept', 1],
'GLF2': ['jet_swept', 0.96], // 29t
'GLF3': ['jet_swept', 0.96], // 31t
'GLF4': ['jet_swept', 0.96], // 34t
'GLF5': ['jet_swept', 0.98], // 41t
'GLF6': ['jet_swept', 1], // 48t
'E135': ['jet_swept', 0.92], // 20t
'E35L': ['jet_swept', 0.92], // 24t
'E145': ['jet_swept', 0.92], // 22t
'E45X': ['jet_swept', 0.92], // 24t
'CRJ1': ['jet_swept', 0.92], // 24t
'CRJ2': ['jet_swept', 0.92], // 24t
'CRJ7': ['jet_swept', 0.94], // 34t
'CRJ9': ['jet_swept', 0.96], // 38t
'CRJX': ['jet_swept', 0.98], // 41t
'MD80': ['jet_swept', 1.04], // 60t
'MD81': ['jet_swept', 1.04],
'MD82': ['jet_swept', 1.04],
'MD83': ['jet_swept', 1.04],
'MD87': ['jet_swept', 1.04],
'MD88': ['jet_swept', 1.04], // 72t
'B712': ['jet_swept', 1.04], // 54t
'F100': ['jet_swept', 1], // 45t
'C501': ['jet_nonswept', 1],
'C510': ['jet_nonswept', 1],
'C25A': ['jet_nonswept', 1],
'C525': ['jet_nonswept', 1],
'C550': ['jet_nonswept', 1],
'C560': ['jet_nonswept', 1],
'C56X': ['jet_nonswept', 1], // 9t
'C650': ['jet_nonswept', 1], // 11t
'LJ35': ['jet_nonswept', 1], // 8t
'LR35': ['jet_nonswept', 1], // wrong but in database
'LJ60': ['jet_nonswept', 1], // 10t
'LR45': ['jet_nonswept', 1], // 10t
'G150': ['jet_nonswept', 1], // 11t
'H25A': ['jet_nonswept', 1.04], // 11t
'H25B': ['jet_nonswept', 1.04], // 11t
'H25C': ['jet_nonswept', 1.04], // 11t
'PRM1': ['jet_nonswept', 0.96],
'E55P': ['jet_nonswept', 0.96],
'E50P': ['jet_nonswept', 0.96],
'EA50': ['jet_nonswept', 0.96],
'HDJT': ['jet_nonswept', 0.96],
'SF50': ['jet_nonswept', 0.94],
'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],
'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],
// 'C130': [_c130, 1],
//
'GND': ['ground_unknown', 1],
'GRND': ['ground_unknown', 1],
'SERV': ['ground_service', 1],
'EMER': ['ground_emergency', 1],
'TWR': ['ground_fixed', 1],
};
// Maps ICAO aircraft type description codes (e.g. "L2J") to aircraft icons. This is used if the ICAO type designator (e.g. "B731")
// cannot be found in the TypeDesignatorIcons mappings. The key can be one of the following:
// - Single character: The basic aircraft type letter code (e.g. "H" for helicopter).
// - Three characters: The ICAO type description code (e.g. "L2J" for landplanes with 2 jet engines).
// - Five characters: The ICAO type description code concatenated with the wake turbulence category code, separated by
// a dash (e.g. "L2J-M").
let TypeDescriptionIcons = {
'H': ['helicopter', 1],
'L1P': ['cessna', 1],
'L1T': ['single_turbo', 1],
'L1J': ['hi_perf', 1],
'L2P': ['twin_small', 1],
'L2T': ['twin_large', 0.96],
'L2T-M': ['twin_large', 1.12],
'L1J-L': ['jet_nonswept', 1], // < 7t
'L2J-L': ['jet_nonswept', 1], // < 7t
'L2J-M': ['airliner', 1], // < 136t
'L2J-H': ['heavy_2e', 1], // > 136t
'L3J-H': ['md11', 1], // > 136t
'L4T-M': ['heavy_4e', 0.84],
'L4T-H': ['heavy_4e', 1],
'L4J-H': ['heavy_4e' , 1],
};
let CategoryIcons = {
"A1" : 'cessna', // < 7t
"A2" : 'jet_swept', // < 34t
"A3" : 'airliner', // < 136t
"A4" : 'airliner', // < 136t
"A5" : 'heavy_4e', // > 136t
"A6" : 'hi_perf',
"A7" : 'helicopter',
"B2" : 'balloon',
'C0' : 'ground_unknown',
'C1' : 'ground_emergency',
'C2' : 'ground_service',
'C3' : 'ground_fixed'
};
function getBaseMarker(category, typeDesignator, typeDescription, wtc) {
if (typeDesignator in TypeDesignatorIcons) {
let shape = TypeDesignatorIcons[typeDesignator][0];
let scaling = TypeDesignatorIcons[typeDesignator][1];
return [shape, scaling];
}
if (typeDescription !== undefined && typeDescription !== null && typeDescription.length === 3) {
if (wtc !== undefined && wtc !== null && wtc.length === 1) {
let typeDescriptionWithWtc = typeDescription + "-" + wtc;
if (typeDescriptionWithWtc === "L2J-M" && category === "A2") {
return ["jet_swept", 1];
}
if (typeDescriptionWithWtc in TypeDescriptionIcons) {
let shape = TypeDescriptionIcons[typeDescriptionWithWtc][0];
let scaling = TypeDescriptionIcons[typeDescriptionWithWtc][1];
return [shape, scaling];
}
}
if (typeDescription in TypeDescriptionIcons) {
let shape = TypeDescriptionIcons[typeDescription][0];
let scaling = TypeDescriptionIcons[typeDescription][1];
return [shape, scaling];
}
let basicType = typeDescription.charAt(0);
if (basicType in TypeDescriptionIcons) {
return [TypeDescriptionIcons[basicType][0], 1];
}
}
if (category in CategoryIcons) {
return [CategoryIcons[category], 1];
}
return ['unknown', 1];
}
function svgPathToSvg(path, stroke, fill, selected_stroke) {
path = path.replace('aircraft_color_fill', fill).replace('aircraft_color_stroke', stroke).replace('add_stroke_selected', selected_stroke);
return path;
}
function svgPathToURI(path, stroke, fill, selected_stroke) {
return "data:image/svg+xml;base64," + btoa(svgPathToSvg(path, stroke, fill, selected_stroke));
}