Skip to content

Commit

Permalink
Add TAK input capability
Browse files Browse the repository at this point in the history
  • Loading branch information
dceejay committed Aug 11, 2023
1 parent a30d8bb commit 9421860
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap

- v2.40.0 - Add handling for TAK event points from TAK ingest node.
- v2.39.0 - Add client timezone to connect message. PR #245
- v2.38.3 - Better fix for geojson multipoint icons.
- v2.38.1 - Fix for geojson multipoint icons.
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Feel free to [![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%

### Updates

- v2.40.0 - Add handling for TAK event points from TAK ingest node.
- v2.39.0 - Add client timezone to connect message. PR #245
- v2.38.3 - Better fix for geojson multipoint icons.
- v2.38.1 - Fix for geojson multipoint icons.
Expand Down Expand Up @@ -118,10 +119,18 @@ To do this you need to supply a `msg.payload.SIDC` 2525 code instead of an icon,
"options": { "fillOpacity":0.8, "additionalInformation":"Extra info" }
}

SIDC codes can be generated using the online tool - https://spatialillusions.com/unitgenerator/
SIDC codes can be generated using the online tool - https://www.spatialillusions.com/unitgenerator-legacy/

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>.

#### TAK Visualisation

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.

![Tak Flow](https://github.com/dceejay/pages/blob/master/TAKflow.png?raw=true)
![Tak Image](https://github.com/dceejay/pages/blob/master/TAKicons.png?raw=true)


### Areas, Rectangles, Lines, and GreatCircles

If the msg.payload contains an **area** property - that is an array of co-ordinates, e.g.
Expand Down Expand Up @@ -698,7 +707,7 @@ and use a url like `"url": "http://localhost:1882/?map=/maps/my-app.map",`

To use a vector mbtiles server like **MapTiler** then you can download your mbtiles file into a directory and then from that directory run
```
docker run --name maptiler -d -v $(pwd):/data -p 1884:8080 maptiler/tileserver-gl -p 8080
docker run --name maptiler -d -v $(pwd):/data -p 1884:8080 maptiler/tileserver-gl -p 8080 --mbtiles yourMapFile.mbtiles
```
and use a url like `"url": "http://localhost:1884/styles/basic-preview/{z}/{x}/{y}.png"`

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-web-worldmap",
"version": "2.39.0",
"version": "2.40.0",
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": {
"@turf/bezier-spline": "~6.5.0",
Expand All @@ -24,7 +24,8 @@
"keywords": [
"node-red",
"map",
"world"
"world",
"tak"
],
"node-red": {
"version": ">=1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions worldmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<p>Icons of type <i>plane</i>, <i>ship</i>, <i>car</i>, <i>uav</i> or <i>arrow</i> will use built in SVG icons that align to the
<code>bearing</code> value.</p>
<p>Font Awesome (<a href="https://fontawesome.com/v4.7.0/icons/" target="_new">fa-icons 4.7</a>) can also be used, as can
NATO symbology codes (<a href="https://spatialillusions.com/unitgenerator/">SIDC</a>), or <a href="https://github.com/dceejay/RedMap/blob/master/emojilist.md" target="_new">:emoji name:</a>,
NATO symbology codes (<a href="https://www.spatialillusions.com/unitgenerator-legacy/">SIDC</a>), or <a href="https://github.com/dceejay/RedMap/blob/master/emojilist.md" target="_new">:emoji name:</a>,
or the url of a small icon image (32x32)</p>
<p>See the <a href="https://www.npmjs.com/package/node-red-contrib-web-worldmap" target="_new">README</a> for further
details and examples of icons and commands for drawing <b>lines</b> and <b>areas</b>, and to <b>add layers</b> and
Expand Down Expand Up @@ -312,7 +312,7 @@
<p>Icons of type <i>plane</i>, <i>ship</i>, <i>car</i>, <i>uav</i> or <i>arrow</i> will use built in SVG icons that align to the
<code>bearing</code> value.</p>
<p>Font Awesome (<a href="https://fontawesome.com/v4.7.0/icons/" target="_new">fa-icons 4.7</a>) can also be used, as can
NATO symbology codes (<a href="https://spatialillusions.com/unitgenerator/">SIDC</a>), or <a href="https://github.com/dceejay/RedMap/blob/master/emojilist.md" target="_new">:emoji name:</a>,
NATO symbology codes (<a href="https://www.spatialillusions.com/unitgenerator-legacy/">SIDC</a>), or <a href="https://github.com/dceejay/RedMap/blob/master/emojilist.md" target="_new">:emoji name:</a>,
or the url of a small icon image (32x32)</p>
<p>See the <a href="https://www.npmjs.com/package/node-red-contrib-web-worldmap" target="_new">README</a> for further
details and examples of icons and commands for drawing <b>lines</b> and <b>areas</b>, and to <b>add layers</b> and
Expand Down
69 changes: 68 additions & 1 deletion worldmap/worldmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var menuOpen = false;
var clusterAt = 0;
var maxage = 900; // default max age of icons on map in seconds - cleared after 10 mins
var baselayername = "OSM grey"; // Default base layer OSM but uniform grey
var pagefoot = "&nbsp;&copy; DCJ 2022"
var pagefoot = "&nbsp;&copy; DCJ 2023"
var inIframe = false;
var showUserMenu = true;
var showLayerMenu = true;
Expand Down Expand Up @@ -117,12 +117,23 @@ var handleData = function(data) {
}
}
if (data.command) { doCommand(data.command); delete data.command; }

// handle raw geojson type msg
if (data.hasOwnProperty("type") && data.type.indexOf("Feature") === 0) {
if (data.hasOwnProperty('properties') && data.properties.hasOwnProperty('title')) {
doGeojson(data.properties.title,data)
}
else { doGeojson("geojson",data); }
}
// handle TAK json (from tak-ingest node or fastxml node)
else if (data.hasOwnProperty("event") && data.event.hasOwnProperty("point")) {
doTAKjson(data.event);
}
// handle TAK json (from multicast Protobuf)
else if (data.hasOwnProperty("cotEvent") && data.cotEvent.hasOwnProperty("lat") && data.cotEvent.hasOwnProperty("lon")) {
doTAKMCjson(data.cotEvent);
}
// handle default worldmap json msg
else if (data.hasOwnProperty("name")) { setMarker(data); }
else {
if (JSON.stringify(data) !== '{}') {
Expand Down Expand Up @@ -2910,3 +2921,59 @@ function doGeojson(n,g,l,o) {
layers[lay].addLayer(markers[n]);
map.addLayer(layers[lay]);
}

// handle TAK messages from TAK server tcp - XML->JSON
function doTAKjson(p) {
// console.log("TAK event",p);
if (p.type.indexOf('a') === 0) {
var d = {};
d.lat = Number(p.point.lat);
d.lon = Number(p.point.lon);
d.group = p.detail?.__group?.name;
d.role = p.detail?.__group?.role;
d.type = p.type;
d.uid = p.uid;
d.name = p.detail?.contact?.callsign || p.uid;
d.hdg = p.detail?.track?.course;
d.speed = p.detail?.track?.speed;
var i = d.type.split('-').join('').toUpperCase();
if (i[0] === 'A') { i = 'S' + i.substr(1,2) + 'P' + i.substr(3); }
d.SIDC = (i + '------------').substr(0,12);
d.timestamp = Date.parse(p.time);
d.ttl = Date.parse(p.stale);
// d.now = Date.now();
d.alt = Number(p.point.hae) || 9999999;
setMarker(d);
}
else {
console.log("Skip TAK type",p.type);
}
}

// handle TAK messages from TAK Multicast - Protobuf->JSON
function doTAKMCjson(p) {
// console.log("TAK Multicast event",p);
if (p.type.indexOf('a') === 0) {
var d = {};
d.lat = p.lat;
d.lon = p.lon;
d.group = p.detail?.group?.name;
d.role = p.detail?.group?.role;
d.type = p.type;
d.uid = p.uid;
d.name = p.detail?.contact?.callsign || p.uid;
d.hdg = p.detail?.track?.course;
d.speed = p.detail?.track?.speed;
var i = d.type.split('-').join('').toUpperCase();
if (i[0] === 'A') { i = 'S' + i.substr(1,2) + 'P' + i.substr(3); }
d.SIDC = (i + '------------').substr(0,12);
d.timestamp = Number(p.sendTime);
d.ttl = Number(p.staleTime);
// d.now = Date.now();
d.alt = p.hae || 9999999;
setMarker(d);
}
else {
console.log("Skip TAK type",p.type);
}
}

0 comments on commit 9421860

Please sign in to comment.