Migrate air icons to milsymbol.

All NATO icons are now generated by the milsymbol library based on their
SIDC.
This commit is contained in:
Dan Albert
2022-02-27 22:25:45 -08:00
parent 02383763ec
commit e3adcada52
6 changed files with 26 additions and 70 deletions

View File

@@ -34,66 +34,6 @@ const Colors = Object.freeze({
Highlight: "#ffff00",
});
const Categories = Object.freeze([
"aa",
"allycamp",
"ammo",
"armor",
"coastal",
"comms",
"derrick",
"ewr",
"factory",
"farp",
"fuel",
"missile",
"oil",
"power",
"ship",
"village",
"ware",
"ww2bunker",
]);
const UnitState = Object.freeze({
Alive: "alive",
Damaged: "damaged",
Destroyed: "destroyed",
});
class AirIcons {
constructor() {
this.icons = {};
for (const player of [true, false]) {
this.icons[player] = {};
for (const selected of [true, false]) {
this.icons[player][selected] = this.loadIcon(
"unspecified",
player,
selected
);
}
}
}
icon(_category, player, selected) {
return this.icons[player][selected];
}
loadIcon(category, player, selected) {
var color;
if (selected) {
color = "selected";
} else {
color = player ? "blue" : "red";
}
return new L.Icon({
iconUrl: `../air_assets/${category}_${color}.svg`,
iconSize: [24, 24],
});
}
}
function milSymbolIcon(sidc, options = {}) {
const symbol = new ms.Symbol(sidc, options);
return L.icon({
@@ -102,10 +42,6 @@ function milSymbolIcon(sidc, options = {}) {
});
}
const Icons = Object.freeze({
AirIcons: new AirIcons(),
});
function metersToNauticalMiles(meters) {
return meters * 0.000539957;
}
@@ -923,7 +859,7 @@ class Flight {
this.clearAircraftLocation();
if (this.position != null) {
this.aircraft = L.marker(this.position, {
icon: Icons.AirIcons.icon("fighter", this.flight.blue, this.selected),
icon: milSymbolIcon(this.flight.sidc, { size: 16 }),
}).addTo(aircraftLayer);
}
}