Skip to content

Commit 5e11eb4

Browse files
committed
better flag creation for SIDC
1 parent 26bca44 commit 5e11eb4

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ SIDC codes can be generated using the online tool - https://www.spatialillusions
144144

145145
There are lots of extra options you can specify as `msg.payload.options` - see the <a href="https://spatialillusions.com/milsymbol/documentation.html" target="mapinfo">milsymbol docs here</a>.
146146

147+
Note: If the SIDC code is a 2525C 15 characters long, where chars 13 and 14 are a country code - then the country flag emoji is added to the staffComments field of the icon. If it's a 20 char 2525D code then the options:country property will be used to create the flag.
148+
147149
#### TAK Visualisation
148150

149151
Users of [TAK](https://tak.gov) can use the [TAK ingest node](https://flows.nodered.org/node/node-red-contrib-tak-registration) to create a JSON formatted TAK event object, received from a TAK server. This can be fed directly into the worldmap node.

worldmap/worldmap.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,13 +2123,19 @@ function setMarker(data) {
21232123
}
21242124
opts.size = opts.size || sz;
21252125
opts.size = opts.size * (opts.scale || 1);
2126-
if (data.SIDC.length > 12 && data.SIDC.substr(12,2) !== "**") {
2126+
if (data.SIDC.length > 12 && /^[A-Za-z]{2}$/gm.test(data.SIDC.substr(12,2))) {
21272127
var cc = data.SIDC.substr(12,2).toLowerCase();
21282128
opts.country = cc.toUpperCase();
21292129
opts.staffComments = emojify(":flag-"+cc+":") + " " + (opts?.staffComments || "");
2130-
data.flag = emojify(":flag-"+cc+":");
2130+
data.flag = opts.country.toUpperCase() + " " + emojify(":flag-"+cc+":");
21312131
}
2132-
if (data?.speed) { opts.direction = data?.bearing || data?.hdg || data?.COG }
2132+
if (data.SIDC.length == 20 && opts?.country && opts.country.length == 2) {
2133+
data.flag = opts.country.toUpperCase() + " " + emojify(":flag-"+opts.country.toLowerCase()+":");
2134+
opts.country = data.flag;
2135+
}
2136+
data.speed = opts?.speed || data?.speed; // If SIDC then options.speed can override the speed.
2137+
if (data?.speed && !opts?.direction) { opts.direction = data?.track || data?.hdg || data?.heading || data?.COG || data?.bearing }
2138+
if (data.speed == undefined) { delete data.speed; }
21332139
// escape out any isocodes eg flag symbols
21342140
var optfields = ["additionalInformation","higherFormation","specialHeadquarters","staffComments","type","uniqueDesignation","speed","country"];
21352141
//const regex = /\p{Extended_Pictographic}/ug;
@@ -2229,8 +2235,10 @@ function setMarker(data) {
22292235
// data.flag = mmsiToCountry(data.MMSI)
22302236
// }
22312237
if (data?.flag && data.flag.length == 2) {
2232-
const tflg = emojify(":flag-"+data.flag.toLowerCase()+":");
2233-
if (!tflg.includes("flag-")) { data.flag = tflg; }
2238+
const tflg = data.flag.toUpperCase() + " " + emojify(":flag-"+data.flag.toLowerCase()+":")
2239+
if (!tflg.includes("flag-")) {
2240+
data.flag = tflg;
2241+
}
22342242
}
22352243
if (data.hasOwnProperty("photourl")) {
22362244
words += "<img src=\"" + data.photourl + "\" style=\"max-width:100%; max-height:250px; margin-top:10px;\"><br/>";
@@ -2308,7 +2316,6 @@ function setMarker(data) {
23082316

23092317
// Add right click contextmenu
23102318
marker = rightmenu(marker);
2311-
23122319
// Delete more already handled properties
23132320
var llc = data.lineColor ?? data.color;
23142321
delete data.lat;

0 commit comments

Comments
 (0)