dceejay / RedMap

A web map app for Node-RED to put blobs on
Apache License 2.0
110 stars 61 forks source link

need Attitude and Type to generate TAK types #184

Closed brothercorvo closed 2 years ago

brothercorvo commented 2 years ago

This is Corvo from FreeTAKServer's project. We got some request to transform RedMap this into a full TAK client so if you ware willing to implement some functions I will take over the implementation of the API the main functionality is to be able to create the different types of drop points (friendly, Hostile, neutral and unknow) when a marker is clicked, depending from the status of 2 buttons attitude and Type are set

{ "action": "click", "name":"Putin", "layer":"gps", "attitude": "hostile", "Type": "Sniper", "icon":"male", "iconColor":"blue", "lat":38.889, "lon":-77.0104 }  

Based on that I can send to the FTS rest API a message like this:

{
"longitude": -77.0104,
"latitude": 38.889,
"attitude": "hostile",
"geoObject": "Gnd Combat Infantry Sniper",
"how": "nonCoT",
"name": "Putin",
"timeout": 600  
}
dceejay commented 2 years ago

Hi @brothercorvo, great to see you. When you right click on the map to create an icon image

you can type in the name , then the icon - which can be a SIDC code (or short part thereof) eg Dave,SFGPU to create image

or Corvo,SSAPMF for a fixed wing suspected enemy aircraft image

You can usually change SIDC codes into COT codes quite easily I think SFGPU -> a-f-G-U
SSAPMF -> a-s-A-M-F

Is that OK ? I use the milsymbol js library which may also help decode. (edit: hmm looking at it I'm not sure it helps much) But their generator is useful for creating codes - https://spatialillusions.com/unitgenerator/

dceejay commented 2 years ago

I have pushed a change so that that if you are online the "form" now looks like image

v2.21.8

dceejay commented 2 years ago

The other way to do it is to re-write the right click menu to be whatever you want - eg a simple form

image

msg.payload = { command: {
contextmenu: String.raw`
Text <input type="text" id="sometext" value="hello"><br/>
Number <input type="number" id="somenum" value="5"><br/>
<input type="button" value="Send" onclick=
'feedback("myform",{
    "st":document.getElementById("sometext").value,
    "sn":document.getElementById("somenum").value,
})'
>
`
}}
return msg;

Example

[{"id":"7351100bacb1f5fe","type":"function","z":"4aa2ed2fd1b11362","name":"","func":"msg.payload = { command: {\ncontextmenu: String.raw`\nText <input type=\"text\" id=\"sometext\" value=\"hello\"><br/>\nNumber <input type=\"number\" id=\"somenum\" value=\"5\"><br/>\n<input type=\"button\" value=\"Send\" onclick=\n'feedback(\"myform\",{\n    \"st\":document.getElementById(\"sometext\").value,\n    \"sn\":document.getElementById(\"somenum\").value,\n})'\n>\n`\n}}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":360,"wires":[["a6a82f2e8efc44fc"]]},{"id":"7b595f0c8f6ac710","type":"worldmap in","z":"4aa2ed2fd1b11362","name":"","path":"/worldmap","events":"connect","x":195,"y":360,"wires":[["7351100bacb1f5fe"]]}]

sends image

If you do use your own form then you will need to feedback whatever actual marker you wish to use back to the map to make it visible.

brothercorvo commented 2 years ago

thanks, this is technically feasible, however it's not very comfortable for end users in a TAK scenario of Emergency. What I wonder is if we can have a new layer, with a toolbox containing the basic types and attitude. As soon the toolbox is activated, a new element is created with auto-name (Sniper1, sniper2, etc). The name can be edited later if necessary. It's feasible?

dceejay commented 2 years ago

That still "feels" like a custom contextmenu - albeit a somewhat more complex one than the example above... Let me see if I can create one.

dceejay commented 2 years ago

Maybe something like

[{"id":"7351100bacb1f5fe","type":"function","z":"4aa2ed2fd1b11362","name":"","func":"msg.payload = { command: {\ncontextmenu: String.raw`\n<table border=0><tr>\n<th>Attitude</th><td><select id=\"myatt\">\n  <option value=\"friend\">Friend</option>\n  <option value=\"hostile\">Hostile</option>\n  <option value=\"neutral\">Neutral</option>\n  <option value=\"unknown\">Unknown</option>\n  <option value=\"pending\">Pending</option>\n  <option value=\"suspect\">Suspect</option>\n  <option value=\"assumed\">Assumed Friend</option>\n  </select></td>\n</tr><tr>\n<th>Type</th><td><select id=\"mytyp\" onchange=\"document.getElementById('mynam').value = this.value+'-'+parseInt(Math.random()*9999)\">\n  <option selected=\"true\" style=\"display:none;\">Please select</option>\n  <option value=\"Rifleman\">Rifleman</option>\n  <option value=\"Grenadier\">Grenadier</option>\n  <option value=\"Mortar\">Mortar</option>\n  <option value=\"Medic\">Medic</option>\n  <option value=\"Teamleader\">Team Leader</option>\n  <option value=\"Hq\">HQ</option>\n  <option value=\"Sniper\">Sniper</option>\n  <option value=\"Recon\">Recon</option>\n  <option value=\"RTO\">RTO</option>\n  <option value=\"K9\">K9</option>\n</select></td>\n</tr><tr>\n<th>Timeout</th><td><input type=\"number\" id=\"mytout\" step=\"10\" value=\"300\">S</td>\n</tr><tr>\n<th>Name</th><td><input type=\"text\" id=\"mynam\"></td>\n</tr><tr>\n<th><input type=\"button\" value=\"Send\" onclick=\n'feedback(\"myform\",{\n    \"attitude\":document.getElementById(\"myatt\").value,\n    \"geobject\":document.getElementById(\"mytyp\").value,\n    \"timeout\":document.getElementById(\"mytout\").value,\n    \"name\":document.getElementById(\"mynam\").value,\n})'\n></th>\n</tr></table>\n`\n}}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":315,"y":90,"wires":[["a6a82f2e8efc44fc"]]}]

image

brothercorvo commented 2 years ago

Works now, will be included in the next release of FreeTAKServer! image

dceejay commented 2 years ago

More TAK like (default) names

[{"id":"7351100bacb1f5fe","type":"function","z":"bf6c9dc1a5062a3a","name":"add marker","func":"msg.payload = { command: {\ncontextmenu: String.raw`\n<table border=0><tr>\n<th>Attitude</th><td><select id=\"myatt\" style=\"width:153px;\" onchange=\"document.getElementById('mynam').value = this.value.substr(0,1).toUpperCase()+'.'+(new Date()).getDate()+'.'+(new Date()).getHours().toString().padStart(2,'0') + (new Date()).getMinutes().toString().padStart(2,'0') + (new Date()).getSeconds().toString().padStart(2,'0');\">\n  <option selected=\"true\" style=\"display:none;\">Please select</option>\n  <option value=\"friend\">Friend</option>\n  <option value=\"hostile\">Hostile</option>\n  <option value=\"neutral\">Neutral</option>\n  <option value=\"unknown\">Unknown</option>\n  <option value=\"pending\">Pending</option>\n  <option value=\"suspect\">Suspect</option>\n  <option value=\"assumed\">Assumed Friend</option>\n  </select></td>\n</tr><tr>\n<th>Type</th><td><select id=\"mytyp\" style=\"width:153px;\">\n  <option selected=\"true\" style=\"display:none;\">Please select</option>\n  <option value=\"Rifleman\">Rifleman</option>\n  <option value=\"Grenadier\">Grenadier</option>\n  <option value=\"Mortar\">Mortar</option>\n  <option value=\"Medic\">Medic</option>\n  <option value=\"Teamleader\">Team Leader</option>\n  <option value=\"Hq\">HQ</option>\n  <option value=\"Sniper\">Sniper</option>\n  <option value=\"Recon\">Recon</option>\n  <option value=\"RTO\">RTO</option>\n  <option value=\"K9\">K9</option>\n</select></td>\n</tr><tr>\n<th>Timeout</th><td><input type=\"number\" id=\"mytout\" step=\"10\" value=\"300\"> s</td>\n</tr><tr>\n<th>Name</th><td><input type=\"text\" id=\"mynam\"></td>\n</tr><tr>\n<th><input type=\"button\" value=\"Send\" onclick=\n'feedback(\"myform\",{\n    \"attitude\":document.getElementById(\"myatt\").value,\n    \"geobject\":document.getElementById(\"mytyp\").value,\n    \"timeout\":document.getElementById(\"mytout\").value,\n    \"name\":document.getElementById(\"mynam\").value,\n},\"FTS\",true)'\n></th>\n</tr></table>\n`\n}}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":330,"wires":[["6a201cf14cdeec50","12bddd2f58f614df"]]}]

image