### Generate Documentation Locally Source: https://github.com/dfpc-coe/node-cot/blob/main/README.md Run this command to generate API documentation locally. Ensure you have npm installed. ```sh npm run doc ``` -------------------------------- ### Install Node-CoT Package Source: https://context7.com/dfpc-coe/node-cot/llms.txt Install the Node-CoT library using npm. Requires Node.js version 22 or higher. ```bash npm install @tak-ps/node-cot ``` -------------------------------- ### Install Node-CoT with NPM Source: https://github.com/dfpc-coe/node-cot/blob/main/README.md Install the node-cot library using npm. This command adds the package to your project's dependencies. ```bash npm install @tak-ps/node-cot ``` -------------------------------- ### CLI for Data Package Validation and CoT Conversion Source: https://context7.com/dfpc-coe/node-cot/llms.txt Use the provided CLI tool for validating Data Package zip files and converting between GeoJSON and CoT XML formats. Examples show command syntax and expected output for valid and invalid packages. ```bash # Validate a Data Package ./cli.ts package validate mission-data.zip # Output (valid package): # { # "valid": true, # "package": "/path/to/mission-data.zip", # "manifest": { # "uid": "package-uid", # "name": "Mission Data" # }, # "counts": { # "contents": 15, # "cots": 10, # "attachments": 3, # "files": 2 # } # } # Output (invalid package): # { # "valid": false, # "package": "/path/to/mission-data.zip", # "errors": [ # { "entry": "path/to/file.cot", "uid": "marker-1", "error": "Invalid CoT format" } # ] # } # Convert GeoJSON to CoT XML ./cli.ts feature convert input.geojson > output.cot ``` -------------------------------- ### Display CLI Help Source: https://context7.com/dfpc-coe/node-cot/llms.txt Command-line interface command to display help information for the Node-CoT CLI. ```bash ./cli.ts --help ``` -------------------------------- ### Create TAK Data Package Source: https://context7.com/dfpc-coe/node-cot/llms.txt Use DataPackage to create ZIP files containing CoTs, attachments, and other files for distribution. You can add CoT markers and files, set package behavior (ephemeral or permanent), and finalize the package. ```typescript import { DataPackage, CoTParser } from '@tak-ps/node-cot'; import fs from 'fs'; // Create a new data package const pkg = new DataPackage( "package-uid-123", // Optional UID "Mission Briefing" // Package name ); // Add CoT markers const marker1 = await CoTParser.from_geojson({ id: "objective-1", type: "Feature", properties: { type: "a-f-G", callsign: "Objective Alpha" }, geometry: { type: "Point", coordinates: [-108.537, 39.078] } }); const marker2 = await CoTParser.from_geojson({ id: "objective-2", type: "Feature", properties: { type: "a-f-G", callsign: "Objective Bravo" }, geometry: { type: "Point", coordinates: [-108.540, 39.080] } }); await pkg.addCoT(marker1); await pkg.addCoT(marker2); // Add files await pkg.addFile( fs.createReadStream('./briefing.pdf'), { name: 'briefing.pdf' } ); // Add file as attachment to a specific CoT await pkg.addFile( fs.createReadStream('./photo.jpg'), { name: 'objective-photo.jpg', attachment: 'objective-1' // Links to marker1's UID } ); // Set package behavior pkg.setEphemeral(); // Import and delete after receipt // OR pkg.setPermanent(); // Import and retain package // Finalize and get ZIP path const zipPath = await pkg.finalize(); console.log('Package created:', zipPath); // Clean up when done await pkg.destroy(); ``` -------------------------------- ### Enable Debugging Output Source: https://github.com/dfpc-coe/node-cot/blob/main/README.md Set the DEBUG_COTS environment variable to a truthy value to print the raw JSONified XML on each constructor invocation. This is useful for debugging. ```bash export DEBUG_COTS=1 ``` -------------------------------- ### Convert CoT XML to GeoJSON CLI Source: https://context7.com/dfpc-coe/node-cot/llms.txt Command-line interface for converting CoT XML files to GeoJSON format. Output is redirected to a file. ```bash ./cli.ts feature convert input.cot > output.geojson ``` -------------------------------- ### Create File Share CoT Message Source: https://context7.com/dfpc-coe/node-cot/llms.txt Use FileShare to create CoT messages that notify TAK clients about available files on TAK Server. Include filename, name, sender details, SHA256 hash, and size. ```typescript import { FileShare, CoTParser } from '@tak-ps/node-cot'; // Create a file share notification const fileShare = new FileShare({ filename: "situation-report.pdf.zip", name: "Situation Report", senderCallsign: "Command Post", senderUid: "ANDROID-command123", senderUrl: "https://tak-server.example.com:8443/Marti/sync/content?hash=abc123def456", sha256: "abc123def456789...", sizeInBytes: 1048576 }); // Convert to XML const xml = CoTParser.to_xml(fileShare); console.log(xml); // Includes and elements // Convert to GeoJSON to inspect const geojson = await CoTParser.to_geojson(fileShare); console.log(geojson.properties.fileshare); // { // filename: "situation-report.pdf.zip", // name: "Situation Report", // senderCallsign: "Command Post", // senderUid: "ANDROID-command123", // senderUrl: "https://...", // sha256: "abc123def456789...", // sizeInBytes: 1048576 // } ``` -------------------------------- ### Parse TAK Data Package from File Source: https://context7.com/dfpc-coe/node-cot/llms.txt Parse a TAK Data Package from a local file path. Options include strict manifest validation and cleanup of the source ZIP. Useful for processing mission data archives. ```typescript import { DataPackage } from '@tak-ps/node-cot'; // Parse a data package from file path const pkg = await DataPackage.parse('./mission-data.zip', { strict: true, // Require valid manifest (default: true) cleanup: true // Remove source ZIP after parsing (default: true) }); // Check if it's a Mission Archive export if (pkg.isMissionArchive()) { console.log('Mission:', pkg.settings.mission_name); console.log('GUID:', pkg.settings.mission_guid); } // Package metadata console.log('Package Name:', pkg.settings.name); console.log('Package UID:', pkg.settings.uid); console.log('Contents:', pkg.contents.length, 'items'); // Extract all CoT markers const cots = await pkg.cots({ respectIgnore: true, // Skip ignored content (default: true) parseAttachments: true // Populate attachment_list on CoTs (default: true) }); for (const cot of cots) { console.log(`- ${cot.callsign()} (${cot.uid()})`); } // Get attachments mapped to CoT UIDs const attachments = await pkg.attachments({ respectIgnore: true }); for (const [cotUid, files] of attachments) { console.log(`Attachments for ${cotUid}:`); for (const file of files) { console.log(` - ${file._attributes.zipEntry}`); } } // Get standalone files (not CoTs or attachments) const files = await pkg.files({ respectIgnore: true }); for (const filePath of files) { console.log('File:', filePath); const stream = await pkg.getFile(filePath); // Process stream... } // Get file as buffer const buffer = await pkg.getFileBuffer('path/to/file.pdf'); // Calculate file hash (SHA-256) const hash = await pkg.hash('path/to/file.pdf'); console.log('File hash:', hash); // Clean up await pkg.destroy(); ``` -------------------------------- ### Convert GeoJSON to Protobuf and back Source: https://context7.com/dfpc-coe/node-cot/llms.txt Parse GeoJSON into a CoT object using CoTParser.from_geojson, then serialize it to Protobuf using CoTParser.to_proto for efficient transmission. The Protobuf can be parsed back into a CoT object using CoTParser.from_proto. ```typescript import { CoTParser } from '@tak-ps/node-cot'; // Create a CoT and convert to Protobuf const cot = await CoTParser.from_geojson({ id: "proto-test", type: "Feature", properties: { type: "a-f-G", how: "m-g", callsign: "Protobuf Test", time: new Date().toISOString(), start: new Date().toISOString(), stale: new Date(Date.now() + 300000).toISOString() }, geometry: { type: "Point", coordinates: [-108.537452, 39.078503] } }); // Serialize to Protobuf (returns Uint8Array) const protoBuffer = await CoTParser.to_proto(cot); console.log('Protobuf size:', protoBuffer.length, 'bytes'); // Parse Protobuf back to CoT const parsedCot = await CoTParser.from_proto(protoBuffer); console.log(parsedCot.callsign()); // "Protobuf Test" // Reset flow tags when forwarding const protoReset = await CoTParser.to_proto(cot, 1, { resetFlow: true }); ``` -------------------------------- ### Parse and Convert CoT Messages Source: https://github.com/dfpc-coe/node-cot/blob/main/README.md Import the CoT class and instantiate it with an XML string. Use methods to convert to GeoJSON or XML, or access the raw JSON representation. ```javascript import CoT from '@tak-ps/node-cot'; const cot = new CoT(` `); // Export Formats cot.to_geojson(); // Output GeoJSON Representation cot.to_xml(); // Output String XML Representation cot.raw; // JSON XML Representation ``` -------------------------------- ### Attach Video Streams to CoT Messages Source: https://context7.com/dfpc-coe/node-cot/llms.txt Attach video stream information to CoT messages for sharing live video feeds with TAK clients. Supports basic URL and full connection configuration. ```typescript import { CoTParser } from '@tak-ps/node-cot'; const cot = await CoTParser.from_geojson({ id: "drone-feed", type: "Feature", properties: { type: "a-f-A-M-F-Q-r", // Friendly UAV callsign: "Drone Camera" }, geometry: { type: "Point", coordinates: [-108.537, 39.078, 500] } }); // Add video stream with basic URL cot.addVideo({ url: "rtsp://192.168.1.100:8554/stream" }); // Add video with full connection configuration cot.addVideo( { url: "rtsp://192.168.1.100:8554/stream", uid: "video-feed-123" }, { uid: "video-feed-123", networkTimeout: 12000, path: "/stream", protocol: "rtsp", bufferTime: 2000, address: "192.168.1.100", port: 8554, roverPort: -1, rtspReliable: 1, ignoreEmbeddedKLV: false, alias: "Drone Camera Feed" } ); console.log(CoTParser.to_xml(cot)); ``` -------------------------------- ### CoTParser - Parse CoT from XML Source: https://context7.com/dfpc-coe/node-cot/llms.txt Parse XML CoT messages into JavaScript objects using the `CoTParser.from_xml()` method. This is the primary way to ingest CoT messages from TAK clients and servers. ```APIDOC ## CoTParser - Parse CoT from XML ### Description Parse XML CoT messages into JavaScript objects using the `CoTParser.from_xml()` method. This is the primary way to ingest CoT messages from TAK clients and servers. ### Method `CoTParser.from_xml(xmlString: string): CoT` ### Parameters #### Request Body - **xmlString** (string) - Required - The XML string representing the CoT message. ### Request Example ```typescript import { CoTParser } from '@tak-ps/node-cot'; const cot = CoTParser.from_xml(` `); // Access CoT properties console.log(cot.uid()); // "ANDROID-deadbeef" console.log(cot.type()); // "a-f-G-U-C" console.log(cot.callsign()); // "Alpha-1" console.log(cot.position()); // [-108.537452, 39.078503] // Check CoT type classifications console.log(cot.is_friend()); // true (type starts with "a-f-") console.log(cot.is_ground()); // true (type contains "-G") console.log(cot.is_stale()); // true/false based on current time vs stale attribute ``` ### Response #### Success Response (200) - **CoT** (object) - A JavaScript object representing the parsed CoT message. #### Response Example ```json { "uid": "ANDROID-deadbeef", "type": "a-f-G-U-C", "callsign": "Alpha-1", "position": [-108.537452, 39.078503], "is_friend": true, "is_ground": true, "is_stale": false } ``` ``` -------------------------------- ### CoTParser - Convert CoT to XML Source: https://context7.com/dfpc-coe/node-cot/llms.txt Convert a CoT object back to XML string format for transmission to TAK clients and servers. ```APIDOC ## CoTParser - Convert CoT to XML ### Description Convert a CoT object back to XML string format for transmission to TAK clients and servers. ### Method `CoTParser.to_xml(cot: CoT, options?: { resetFlow: boolean }): string` ### Parameters #### Request Body - **cot** (object) - Required - The CoT object to convert. - **options** (object) - Optional - Configuration options. - **resetFlow** (boolean) - Optional - If true, resets flow tags when forwarding messages. ### Request Example ```typescript import { CoTParser } from '@tak-ps/node-cot'; const cot = await CoTParser.from_geojson({ id: "marker-123", type: "Feature", properties: { type: "a-f-G-U-C", how: "m-g", callsign: "Command Post", time: "2024-01-15T10:30:00Z", start: "2024-01-15T10:30:00Z", stale: "2024-01-15T11:30:00Z" }, geometry: { type: "Point", coordinates: [-108.537452, 39.078503, 1500] } }); // Convert to XML string const xml = CoTParser.to_xml(cot); console.log(xml); // // // // // Reset flow tags when forwarding messages const xmlReset = CoTParser.to_xml(cot, { resetFlow: true }); ``` ### Response #### Success Response (200) - **xmlString** (string) - The XML string representation of the CoT message. #### Response Example ```xml ``` ``` -------------------------------- ### Create Mission Chat Message Source: https://context7.com/dfpc-coe/node-cot/llms.txt Use MissionChat to create messages for TAK Server Mission Sync conversations. Specify sender, mission details, and message content. The message is automatically routed to the mission. ```typescript import { MissionChat, CoTParser } from '@tak-ps/node-cot'; // Create a mission chat message const missionMessage = new MissionChat({ from: { uid: "ANDROID-user123", type: "a-f-G-E-V-C" // Friendly ground vehicle }, mission: { name: "Search and Rescue Op", id: "tak-server.example.com-8443-ssl-Search and Rescue Op", guid: "mission-guid-12345" // Optional }, senderCallsign: "Rescue Team Lead", message: "Area 3 cleared. Moving to Area 4.", parent: "DataSyncMissionsList", // Optional, defaults to DataSyncMissionsList groupOwner: false // Optional }); // The message is automatically routed to the mission const xml = CoTParser.to_xml(missionMessage); // Inspect the message structure const geojson = await CoTParser.to_geojson(missionMessage); console.log(geojson.properties.dest); // { mission: "Search and Rescue Op", "mission-guid": "mission-guid-12345" } console.log(geojson.properties.remarks); // "Area 3 cleared. Moving to Area 4." ``` -------------------------------- ### Parse TAK Data Package from Buffer or Stream Source: https://context7.com/dfpc-coe/node-cot/llms.txt Parse TAK Data Packages directly from memory buffers or Node.js ReadableStreams, avoiding filesystem operations. Useful for data received over networks. Provide a 'name' option for manifest-less archives and set 'strict' to false to allow packages without a manifest. ```typescript import { DataPackage } from '@tak-ps/node-cot'; import { Readable } from 'stream'; // Parse from Buffer (e.g., from HTTP request) const buffer = await fetch('https://example.com/package.zip') .then(res => res.arrayBuffer()) .then(ab => Buffer.from(ab)); const pkgFromBuffer = await DataPackage.parse(buffer, { name: 'downloaded-package.zip', // Provide name for manifest-less archives strict: false // Allow packages without manifest }); // Parse from ReadableStream const response = await fetch('https://example.com/package.zip'); const stream = Readable.fromWeb(response.body); const pkgFromStream = await DataPackage.parse(stream, { name: 'streamed-package.zip' }); // Process packages const cots = await pkgFromBuffer.cots(); console.log('Markers:', cots.length); await pkgFromBuffer.destroy(); await pkgFromStream.destroy(); ``` -------------------------------- ### Add Links and Creator Information to CoT Source: https://context7.com/dfpc-coe/node-cot/llms.txt Add relationship links between CoT messages and track message origin with creator information. Supports linking by UID, type, relation, and URL. ```typescript import { CoTParser } from '@tak-ps/node-cot'; // Create a CoT with creator tracking const parentCot = await CoTParser.from_geojson({ id: "parent-unit", type: "Feature", properties: { type: "a-f-G-U-C", callsign: "Command Unit" }, geometry: { type: "Point", coordinates: [-108.537, 39.078] } }); // Create child CoT with creator reference const childCot = await CoTParser.from_geojson({ id: "child-marker", type: "Feature", properties: { type: "a-f-G", callsign: "Observation Point" }, geometry: { type: "Point", coordinates: [-108.540, 39.080] } }, { creator: parentCot // Pass parent CoT as creator }); // Or set creator manually childCot.creator({ uid: "parent-unit", type: "a-f-G-U-C", callsign: "Command Unit", time: new Date() }); // Add additional links childCot.addLink({ uid: "related-marker", type: "a-f-G", relation: "p-p", // parent-to-point relation parent_callsign: "Related Marker" }); // Add URL links childCot.addLink({ uid: "doc-link", url: "https://example.com/details", relation: "r-r" }); console.log(CoTParser.to_xml(childCot)); ``` -------------------------------- ### Send Direct Chat Messages Source: https://context7.com/dfpc-coe/node-cot/llms.txt Create direct chat messages between TAK users using the DirectChat builder class. Supports sending messages and converting to XML or GeoJSON. ```typescript import { DirectChat, CoTParser } from '@tak-ps/node-cot'; // Create a direct message between two users const chatMessage = new DirectChat({ to: { uid: "ANDROID-recipient123", callsign: "Alpha Operator" }, from: { uid: "ANDROID-sender456", callsign: "Bravo Operator" }, message: "Proceeding to rally point. ETA 10 minutes." }); // Verify it's a chat message console.log(chatMessage.is_chat()); // true console.log(chatMessage.type()); // "b-t-f" // Convert to XML for transmission const xml = CoTParser.to_xml(chatMessage); console.log(xml); // Convert to GeoJSON to inspect structure const geojson = await CoTParser.to_geojson(chatMessage); console.log(geojson.properties.chat); // { // parent: "RootContactGroup", // groupOwner: "false", // messageId: "...", // chatroom: "Alpha Operator", // id: "ANDROID-recipient123", // senderCallsign: "Bravo Operator", // chatgrp: { ... } // } ``` -------------------------------- ### Parse TAK Iconset XML Documents Source: https://context7.com/dfpc-coe/node-cot/llms.txt Use the Iconset.parse method to load and access properties from TAK Iconset XML documents. This is useful for custom icon collections. ```typescript import { Iconset } from '@tak-ps/node-cot'; // Parse iconset XML const iconsetXml = ` `; const iconset = Iconset.parse(iconsetXml); // Access iconset properties console.log(iconset.uid); // "custom-icons-v1" console.log(iconset.name); // "Custom Icons" // Get all icons const icons = iconset.icons(); for (const icon of icons) { console.log(`Icon: ${icon.name} -> ${icon.type2525b}`); } // Convert to JSON const json = iconset.to_json(); console.log(json); // { // uid: "custom-icons-v1", // version: "1", // name: "Custom Icons", // skip_resize: false, // default_group: "default", // default_friendly: "friendly.png", // default_hostile: "hostile.png", // default_neutral: "neutral.png", // default_unknown: "unknown.png" // } ``` -------------------------------- ### Convert CoT XML to GeoJSON Source: https://context7.com/dfpc-coe/node-cot/llms.txt Use CoTParser.from_xml to parse an XML CoT message and CoTParser.to_geojson to convert it into a GeoJSON Feature. This is useful for integrating with mapping libraries. ```typescript import { CoTParser } from '@tak-ps/node-cot'; const cot = CoTParser.from_xml(` En route to incident `); const geojson = await CoTParser.to_geojson(cot); console.log(JSON.stringify(geojson, null, 2)); ``` -------------------------------- ### Convert CoT Types and MIL-STD-2525 SIDC Source: https://context7.com/dfpc-coe/node-cot/llms.txt Utilize MilSymType for converting between CoT types and MIL-STD-2525 Symbol Identification Codes (SIDC). This includes checking convertibility and extracting domain/identity. ```typescript import { MilSymType } from '@tak-ps/node-cot'; // Or: import Type2525 from '@tak-ps/node-cot/2525'; // Check if CoT type can be converted to SIDC const cotType = "a-f-G-U-C"; console.log(MilSymType.default.is2525BConvertable(cotType)); // true // Convert CoT type to 2525B SIDC const sidc2525B = MilSymType.default.to2525B(cotType); console.log(sidc2525B); // "SFGPUC--------" // Convert CoT type to 2525D SIDC const sidc2525D = MilSymType.default.to2525D(cotType); console.log(sidc2525D); // "1203100000000000000" // Convert 2525B SIDC back to CoT type const backToCot = MilSymType.default.from2525B("SFGPUC--------"); console.log(backToCot); // "a-f-G-U-C" // Check if SIDC can be converted to CoT console.log(MilSymType.default.isTypeConvertable("SFGPUC--------")); // true // Get domain and standard identity console.log(MilSymType.default.domain(cotType)); // "a" (ATOM) console.log(MilSymType.default.standardIdentity(cotType)); // "f" (FRIEND) ``` ```typescript import { CoTParser } from '@tak-ps/node-cot'; // Enable automatic 2525D augmentation when parsing const cot = await CoTParser.from_geojson({ id: "mil-marker", type: "Feature", properties: { type: "a-f-G-U-C", callsign: "Friendly Unit" }, geometry: { type: "Point", coordinates: [-108.537, 39.078] } }, { milsym: { augment: true } // Automatically add __milicon with 2525D SIDC }); ``` -------------------------------- ### Compare CoT Messages for Differences Source: https://context7.com/dfpc-coe/node-cot/llms.txt Use CoTParser.isDiff to detect changes between two CoT messages. Customize comparison by including or excluding time fields and metadata. ```typescript import { CoTParser } from '@tak-ps/node-cot'; const cot1 = await CoTParser.from_geojson({ id: "marker-1", type: "Feature", properties: { type: "a-f-G", callsign: "Original Name", time: "2024-01-15T10:00:00Z", start: "2024-01-15T10:00:00Z", stale: "2024-01-15T10:30:00Z" }, geometry: { type: "Point", coordinates: [-108.537, 39.078] } }); const cot2 = await CoTParser.from_geojson({ id: "marker-1", type: "Feature", properties: { type: "a-f-G", callsign: "Updated Name", // Changed time: "2024-01-15T10:05:00Z", start: "2024-01-15T10:05:00Z", stale: "2024-01-15T10:35:00Z" }, geometry: { type: "Point", coordinates: [-108.537, 39.078] } }); // Check if messages are different (ignores time/stale/start by default) const hasDiff = await CoTParser.isDiff(cot1, cot2); console.log('Has differences:', hasDiff); // true (callsign changed) // Include time fields in comparison const hasDiffWithTime = await CoTParser.isDiff(cot1, cot2, { diffStaleStartTime: true, diffMetadata: false, diffDest: false, diffFlow: false }); console.log('Has differences (with time):', hasDiffWithTime); // true ``` -------------------------------- ### CoTParser - Convert from GeoJSON Source: https://context7.com/dfpc-coe/node-cot/llms.txt Create CoT messages from GeoJSON Features. Supports Point, Polygon, and LineString geometries with automatic type inference for shapes. ```APIDOC ## CoTParser - Convert from GeoJSON ### Description Create CoT messages from GeoJSON Features. Supports Point, Polygon, and LineString geometries with automatic type inference for shapes. ### Method `CoTParser.from_geojson(geojsonFeature: GeoJSON.Feature): Promise` ### Parameters #### Request Body - **geojsonFeature** (GeoJSON.Feature) - Required - The GeoJSON Feature object to convert. ### Request Example ```typescript import { CoTParser } from '@tak-ps/node-cot'; // Create CoT from GeoJSON Point Feature const pointCot = await CoTParser.from_geojson({ id: "unit-alpha", type: "Feature", properties: { type: "a-f-G-U-C", // Friendly ground unit combat how: "m-g", // Machine GPS callsign: "Alpha Team", time: "2024-01-15T10:00:00Z", start: "2024-01-15T10:00:00Z", stale: "2024-01-15T10:15:00Z", speed: 5.2, // Speed in m/s course: 45, // Course in degrees from north remarks: "Moving to objective", "marker-color": "#FF0000", // Simple Style Spec color "marker-opacity": 0.8 }, geometry: { type: "Point", coordinates: [-108.537452, 39.078503, 1500] // [lon, lat, altitude] } }); // Create CoT from GeoJSON Polygon (automatically becomes u-d-f type) const polygonCot = await CoTParser.from_geojson({ id: "area-of-interest", type: "Feature", properties: { callsign: "Objective Area", stroke: "#0000FF", "stroke-width": 2, "stroke-opacity": 1, fill: "#0000FF", "fill-opacity": 0.3 }, geometry: { type: "Polygon", coordinates: [[ [-108.54, 39.08], [-108.53, 39.08], [-108.53, 39.07], [-108.54, 39.07], [-108.54, 39.08] ]] } }); // Convert to XML for transmission console.log(CoTParser.to_xml(pointCot)); ``` ### Response #### Success Response (200) - **CoT** (object) - A JavaScript object representing the CoT message created from the GeoJSON. #### Response Example ```json { "uid": "unit-alpha", "type": "a-f-G-U-C", "callsign": "Alpha Team", "time": "2024-01-15T10:00:00Z", "start": "2024-01-15T10:00:00Z", "stale": "2024-01-15T10:15:00Z", "speed": 5.2, "course": 45, "remarks": "Moving to objective", "marker_color": "#FF0000", "marker_opacity": 0.8, "position": [-108.537452, 39.078503, 1500] } ``` ``` -------------------------------- ### Add Destination Tags to CoT Messages Source: https://context7.com/dfpc-coe/node-cot/llms.txt Add Marti destination tags to route CoT messages to specific users, groups, or missions through TAK Server. Supports routing by UID, callsign, or mission. ```typescript import { CoTParser } from '@tak-ps/node-cot'; const cot = await CoTParser.from_geojson({ id: "targeted-msg", type: "Feature", properties: { type: "a-f-G", callsign: "Targeted Message" }, geometry: { type: "Point", coordinates: [-108.537, 39.078] } }); // Send to specific user by UID cot.addDest({ uid: "ANDROID-user123" }); // Send to a callsign cot.addDest({ callsign: "Command" }); // Send to a mission cot.addDest({ mission: "Operation Alpha" }); // Send to mission with GUID cot.addDest({ mission: "Operation Alpha", "mission-guid": "abc-123-def-456" }); // Multiple destinations can be added cot.addDest({ uid: "ANDROID-user456" }); const xml = CoTParser.to_xml(cot); // XML will include: ... ``` -------------------------------- ### Create Force Delete CoT Message Source: https://context7.com/dfpc-coe/node-cot/llms.txt Use ForceDelete to create messages that remove CoT markers from TAK clients. Provide the UID of the marker to be deleted. The message type is 't-x-d-d'. ```typescript import { ForceDelete, CoTParser } from '@tak-ps/node-cot'; // Create a force delete message for a specific marker const deleteMsg = new ForceDelete("marker-to-delete-uid"); console.log(deleteMsg.type()); // "t-x-d-d" console.log(deleteMsg.uid()); // "marker-to-delete-uid" // Convert to XML and send to TAK Server/clients const xml = CoTParser.to_xml(deleteMsg); console.log(xml); // // // // <__forcedelete/> // // ``` -------------------------------- ### Convert CoT Object to XML String Source: https://context7.com/dfpc-coe/node-cot/llms.txt Convert a CoT JavaScript object back into an XML string format using CoTParser.to_xml(). This is useful for sending messages to TAK clients or servers. You can optionally reset flow tags when forwarding messages. ```typescript import { CoTParser } from '@tak-ps/node-cot'; const cot = await CoTParser.from_geojson({ id: "marker-123", type: "Feature", properties: { type: "a-f-G-U-C", how: "m-g", callsign: "Command Post", time: "2024-01-15T10:30:00Z", start: "2024-01-15T10:30:00Z", stale: "2024-01-15T11:30:00Z" }, geometry: { type: "Point", coordinates: [-108.537452, 39.078503, 1500] } }); // Convert to XML string const xml = CoTParser.to_xml(cot); console.log(xml); // // // // // Reset flow tags when forwarding messages const xmlReset = CoTParser.to_xml(cot, { resetFlow: true }); ``` -------------------------------- ### Convert GeoJSON to CoT Source: https://context7.com/dfpc-coe/node-cot/llms.txt Create CoT messages from GeoJSON Features using CoTParser.from_geojson(). Supports Point, Polygon, and LineString geometries with automatic type inference for shapes. Properties like speed, course, and marker styles can be included. ```typescript import { CoTParser } from '@tak-ps/node-cot'; // Create CoT from GeoJSON Point Feature const pointCot = await CoTParser.from_geojson({ id: "unit-alpha", type: "Feature", properties: { type: "a-f-G-U-C", // Friendly ground unit combat how: "m-g", // Machine GPS callsign: "Alpha Team", time: "2024-01-15T10:00:00Z", start: "2024-01-15T10:00:00Z", stale: "2024-01-15T10:15:00Z", speed: 5.2, // Speed in m/s course: 45, // Course in degrees from north remarks: "Moving to objective", "marker-color": "#FF0000", // Simple Style Spec color "marker-opacity": 0.8 }, geometry: { type: "Point", coordinates: [-108.537452, 39.078503, 1500] // [lon, lat, altitude] } }); // Create CoT from GeoJSON Polygon (automatically becomes u-d-f type) const polygonCot = await CoTParser.from_geojson({ id: "area-of-interest", type: "Feature", properties: { callsign: "Objective Area", stroke: "#0000FF", "stroke-width": 2, "stroke-opacity": 1, fill: "#0000FF", "fill-opacity": 0.3 }, geometry: { type: "Polygon", coordinates: [[ [-108.54, 39.08], [-108.53, 39.08], [-108.53, 39.07], [-108.54, 39.07], [-108.54, 39.08] ]] } }); // Convert to XML for transmission console.log(CoTParser.to_xml(pointCot)); ``` -------------------------------- ### Parse Basemap XML Document Source: https://context7.com/dfpc-coe/node-cot/llms.txt Parse TAK Basemap XML documents to extract custom map tile source configurations. The parsed object can be converted to JSON for easier manipulation or accessed via its raw XML-JS structure. ```typescript import { Basemap } from '@tak-ps/node-cot'; // Parse basemap XML const basemapXml = ` OpenStreetMap https://tile.openstreetmap.org/{z}/{x}/{y}.png 0 19 png #000000 `; const basemap = Basemap.parse(basemapXml); // Convert to JSON for easier manipulation const json = basemap.to_json(); console.log(json); // { // name: "OpenStreetMap", // url: "https://tile.openstreetmap.org/{z}/{x}/{y}.png", // minZoom: 0, // maxZoom: 19, // tileType: "png", // tileUpdate: undefined, // backgroundColor: "#000000", // serverParts: undefined // } // Access raw XML-JS structure console.log(basemap.raw); ``` -------------------------------- ### Inspect and Modify CoT Messages Source: https://context7.com/dfpc-coe/node-cot/llms.txt The CoT class provides methods to check message types (e.g., is_hostile, is_ground) and modify properties like UID, type, callsign, and position. It also supports setting an archive flag and checking staleness. ```typescript import CoT, { CoTParser } from '@tak-ps/node-cot'; const cot = CoTParser.from_xml(` `); // Type classification methods console.log(cot.is_atom()); // true - is an element (starts with 'a-') console.log(cot.is_hostile()); // true - hostile element ('a-h-') console.log(cot.is_friend()); // false console.log(cot.is_neutral()); // false console.log(cot.is_unknown()); // false console.log(cot.is_ground()); // true - ground element ('-G') console.log(cot.is_airborne()); // false console.log(cot.is_surface()); // false - sea surface console.log(cot.is_subsurface()); // false console.log(cot.is_vehicle()); // false console.log(cot.is_uav()); // false console.log(cot.is_chat()); // false console.log(cot.is_tasking()); // false // Getter/setter methods cot.uid("new-uid-123"); cot.type("a-h-G-E-V"); // Change to hostile ground vehicle cot.callsign("Enemy Vehicle"); cot.position([-108.55, 39.09]); // Update position [lon, lat] // Archive flag (TAK clients retain archived features) cot.archived(true); console.log(cot.archived()); // true // Check staleness console.log(cot.is_stale()); // Compare stale time vs current time // Create a TAK server ping message const ping = CoT.ping(); console.log(ping.type()); // "t-x-c-t" ``` -------------------------------- ### Normalize GeoJSON Features for Node-CoT Source: https://context7.com/dfpc-coe/node-cot/llms.txt Normalizes standard GeoJSON features to the format expected by node-cot, adding required fields like id, path, and default properties. This is a prerequisite for converting GeoJSON to CoT. ```typescript import { CoTParser } from '@tak-ps/node-cot'; // Standard GeoJSON (not node-cot format) const rawGeoJSON = { type: "Feature", properties: { name: "My Marker" }, geometry: { type: "Point", coordinates: [-108.537, 39.078, 1500] } }; // Normalize to node-cot format (adds required fields) const normalized = await CoTParser.normalize_geojson(rawGeoJSON); console.log(normalized); // { // id: "generated-uuid", // type: "Feature", // path: "/", // properties: { // type: "a-f-G", // Default type // how: "h-g-i-g-o", // Default how // callsign: "UNKNOWN", // center: [-108.537, 39.078, 1500], // time: "2024-...". // start: "2024-...". // stale: "2024-...". // metadata: {} // }, // geometry: { // type: "Point", // coordinates: [-108.537, 39.078, 1500] // } // } // Now convert to CoT const cot = await CoTParser.from_geojson(normalized); ```