Add ability to map aircraft type descriptions to markers
This commit is contained in:
parent
e13b09f1a4
commit
d5293cc0ed
|
@ -121,6 +121,21 @@ var _balloon = {
|
|||
markerRadius: 32
|
||||
};
|
||||
|
||||
var _helicopter = {
|
||||
key : "helicopter",
|
||||
scale : 0.50,
|
||||
size : [64, 64],
|
||||
anchor : [22, 32],
|
||||
path : _rotorcraft_svg
|
||||
};
|
||||
|
||||
var _single_prop = {
|
||||
key : "single_prop",
|
||||
scale : 0.30,
|
||||
size : [64, 64],
|
||||
anchor : [32, 25],
|
||||
path : _beechcraft_svg
|
||||
};
|
||||
|
||||
// by Oliver Jowett <oliver@mutability.co.uk>
|
||||
// licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
|
||||
|
@ -140,7 +155,7 @@ var _b738 = {
|
|||
path: "m 32,61 -1,-1 -9,2 -2,1 0,-2 9,-6 1,-1 -1,-9 0,-11 -7,0 -1,1 0,-1 -3,1 -1,1 0,-1 -3,1 -9,3 -1,1 0,-2 1,-2 17,-9 1,-1 -1,-2 0,-3 1,-1 2,0 1,1 0,3 3,-2 0,-13 1,-5 1,-3 1,-1 1,1 1,3 1,5 0,13 3,2 0,-3 1,-1 2,0 1,1 0,3 -1,2 1,1 17,9 1,2 0,2 -1,-1 -9,-3 -3,-1 0,1 -1,-1 -3,-1 0,1 -1,-1 -7,0 0,11 -1,9 1,1 9,6 0,2 -2,-1 -9,-2 -1,1 z"
|
||||
};
|
||||
|
||||
var TypeIcons = {
|
||||
var TypeDesignatorIcons = {
|
||||
'A318': _a320, // shortened a320
|
||||
'A319': _a320, // shortened a320
|
||||
'A320': _a320,
|
||||
|
@ -182,14 +197,30 @@ var TypeIcons = {
|
|||
'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")
|
||||
// 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").
|
||||
|
||||
var TypeDescriptionIcons = {
|
||||
'H': _helicopter,
|
||||
|
||||
'L1J': _g650,
|
||||
'L1P': _single_prop,
|
||||
'L1T': _single_prop,
|
||||
|
||||
'L2P': _b200,
|
||||
'L2T': _b200,
|
||||
|
||||
'L2J-L': _g650,
|
||||
'L2J-M': _a320,
|
||||
'L2J-H': _b777,
|
||||
};
|
||||
|
||||
var CategoryIcons = {
|
||||
"A1" : {
|
||||
key : "A1",
|
||||
scale : 0.30,
|
||||
size : [64, 64],
|
||||
anchor : [32, 25],
|
||||
path : _beechcraft_svg
|
||||
},
|
||||
"A1" : _single_prop,
|
||||
|
||||
"A2" : {
|
||||
key : "A2",
|
||||
|
@ -215,13 +246,7 @@ var CategoryIcons = {
|
|||
path : _heavy_svg
|
||||
},
|
||||
|
||||
"A7" : {
|
||||
key : "A7",
|
||||
scale : 0.50,
|
||||
size : [64, 64],
|
||||
anchor : [22, 32],
|
||||
path : _rotorcraft_svg
|
||||
},
|
||||
"A7" : _helicopter,
|
||||
|
||||
"B2" : _balloon
|
||||
};
|
||||
|
@ -234,9 +259,27 @@ var DefaultIcon = {
|
|||
path : _generic_plane_svg
|
||||
};
|
||||
|
||||
function getBaseMarker(category, type) {
|
||||
if (type in TypeIcons) {
|
||||
return TypeIcons[type];
|
||||
function getBaseMarker(category, typeDesignator, typeDescription, wtc) {
|
||||
if (typeDesignator in TypeDesignatorIcons) {
|
||||
return TypeDesignatorIcons[typeDesignator];
|
||||
}
|
||||
|
||||
if (typeDescription !== undefined && typeDescription !== null && typeDescription.length === 3) {
|
||||
if (wtc !== undefined && wtc !== null && wtc.length === 1) {
|
||||
var typeDescriptionWithWtc = typeDescription + "-" + wtc;
|
||||
if (typeDescriptionWithWtc in TypeDescriptionIcons) {
|
||||
return TypeDescriptionIcons[typeDescriptionWithWtc];
|
||||
}
|
||||
}
|
||||
|
||||
if (typeDescription in TypeDescriptionIcons) {
|
||||
return TypeDescriptionIcons[typeDescription];
|
||||
}
|
||||
|
||||
var basicType = typeDescription.charAt(0);
|
||||
if (basicType in TypeDescriptionIcons) {
|
||||
return TypeDescriptionIcons[basicType];
|
||||
}
|
||||
}
|
||||
|
||||
if (category in CategoryIcons) {
|
||||
|
|
|
@ -48,9 +48,7 @@ function PlaneObject(icao) {
|
|||
// request metadata
|
||||
this.registration = null;
|
||||
this.icaotype = null;
|
||||
this.aircraftTypeCode = null;
|
||||
this.engineCount = null;
|
||||
this.engineType = null;
|
||||
this.typeDescription = null;
|
||||
this.wtc = null;
|
||||
getAircraftData(this.icao).done(function(data) {
|
||||
if ("r" in data) {
|
||||
|
@ -62,13 +60,11 @@ function PlaneObject(icao) {
|
|||
}
|
||||
|
||||
if ("desc" in data) {
|
||||
this.aircraftTypeCode = data.desc.charAt(0);
|
||||
this.engineCount = parseInt(data.desc.charAt(1));
|
||||
this.engineTypeCode = data.desc.charAt(2);
|
||||
this.typeDescription = data.desc;
|
||||
}
|
||||
|
||||
if ("wtc" in data) {
|
||||
this.wtc = data.wtc;
|
||||
this.wtc = data.wtc;
|
||||
}
|
||||
|
||||
if (this.selected) {
|
||||
|
@ -303,7 +299,7 @@ PlaneObject.prototype.updateIcon = function() {
|
|||
var col = this.getMarkerColor();
|
||||
var opacity = (this.position_from_mlat ? 0.75 : 1.0);
|
||||
var outline = (this.position_from_mlat ? OutlineMlatColor : OutlineADSBColor);
|
||||
var baseMarker = getBaseMarker(this.category, this.icaotype);
|
||||
var baseMarker = getBaseMarker(this.category, this.icaotype, this.typeDescription, this.wtc);
|
||||
var weight = ((this.selected ? 2 : 1) / baseMarker.scale).toFixed(1);
|
||||
var rotation = (this.track === null ? 0 : this.track);
|
||||
|
||||
|
|
Loading…
Reference in a new issue