@tak-ps/node-cot 12.17.1 → 12.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/lib/data-package.js +64 -16
- package/dist/lib/data-package.js.map +1 -1
- package/dist/lib/types/iconset.js +12 -4
- package/dist/lib/types/iconset.js.map +1 -1
- package/dist/lib/xml/basemap.js +1 -1
- package/dist/lib/xml/basemap.js.map +1 -1
- package/dist/lib/xml/iconset.js +29 -2
- package/dist/lib/xml/iconset.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/data-package.ts +70 -17
- package/lib/types/iconset.ts +14 -4
- package/lib/xml/basemap.ts +2 -2
- package/lib/xml/iconset.ts +36 -3
- package/lib/xml-document.ts +1 -1
- package/package.json +1 -1
- package/tsconfig.json +1 -0
- package/dist/test/basemaps.test.js +0 -16
- package/dist/test/basemaps.test.js.map +0 -1
- package/dist/test/chat.test.js +0 -97
- package/dist/test/chat.test.js.map +0 -1
- package/dist/test/cot-fileshare.test.js +0 -89
- package/dist/test/cot-fileshare.test.js.map +0 -1
- package/dist/test/cot-itak.test.js +0 -95
- package/dist/test/cot-itak.test.js.map +0 -1
- package/dist/test/cot-mma.test.js +0 -108
- package/dist/test/cot-mma.test.js.map +0 -1
- package/dist/test/cot-polyline.test.js +0 -98
- package/dist/test/cot-polyline.test.js.map +0 -1
- package/dist/test/cot-range-and-bearing.test.js +0 -98
- package/dist/test/cot-range-and-bearing.test.js.map +0 -1
- package/dist/test/cot-routes.test.js +0 -466
- package/dist/test/cot-routes.test.js.map +0 -1
- package/dist/test/cot-types.test.js +0 -7
- package/dist/test/cot-types.test.js.map +0 -1
- package/dist/test/cot-uas-tool.test.js +0 -286
- package/dist/test/cot-uas-tool.test.js.map +0 -1
- package/dist/test/cot-video.test.js +0 -196
- package/dist/test/cot-video.test.js.map +0 -1
- package/dist/test/cot_is.test.js +0 -353
- package/dist/test/cot_is.test.js.map +0 -1
- package/dist/test/data-package.test.js +0 -234
- package/dist/test/data-package.test.js.map +0 -1
- package/dist/test/diff.test.js +0 -73
- package/dist/test/diff.test.js.map +0 -1
- package/dist/test/flow-tags.test.js +0 -19
- package/dist/test/flow-tags.test.js.map +0 -1
- package/dist/test/force-delete.js +0 -46
- package/dist/test/force-delete.js.map +0 -1
- package/dist/test/from_geojson.test.js +0 -287
- package/dist/test/from_geojson.test.js.map +0 -1
- package/dist/test/newlines.test.js +0 -79
- package/dist/test/newlines.test.js.map +0 -1
- package/dist/test/reversal-geojson.test.js +0 -15
- package/dist/test/reversal-geojson.test.js.map +0 -1
- package/dist/test/reversal-proto.test.js +0 -54
- package/dist/test/reversal-proto.test.js.map +0 -1
- package/dist/test/stream.js +0 -10
- package/dist/test/stream.js.map +0 -1
- package/dist/test/taskings-mission.test.js +0 -140
- package/dist/test/taskings-mission.test.js.map +0 -1
- package/dist/test/util.test.js +0 -25
- package/dist/test/util.test.js.map +0 -1
- package/dist/test/validation.test.js +0 -13
- package/dist/test/validation.test.js.map +0 -1
- package/test/basemaps/Bing_Hybrid.xml +0 -12
- package/test/basemaps/Bing_Maps.xml +0 -10
- package/test/basemaps/USGSBasemap.xml +0 -10
- package/test/basemaps/USGSImageryOnly.xml +0 -10
- package/test/basemaps/USGSImageryTopo.xml +0 -10
- package/test/basemaps/USGSShadedRelief.xml +0 -10
- package/test/basemaps/opentopomap.xml +0 -10
- package/test/basemaps.test.ts +0 -19
- package/test/chat.test.ts +0 -103
- package/test/cot-fileshare.test.ts +0 -92
- package/test/cot-itak.test.ts +0 -100
- package/test/cot-mma.test.ts +0 -111
- package/test/cot-polyline.test.ts +0 -103
- package/test/cot-range-and-bearing.test.ts +0 -100
- package/test/cot-routes.test.ts +0 -468
- package/test/cot-types.test.ts +0 -8
- package/test/cot-uas-tool.test.ts +0 -295
- package/test/cot-video.test.ts +0 -204
- package/test/cot_is.test.ts +0 -431
- package/test/data-package.test.ts +0 -314
- package/test/diff.test.ts +0 -80
- package/test/fixtures/archived.geojson +0 -20
- package/test/fixtures/attachments.geojson +0 -20
- package/test/fixtures/basic.geojson +0 -19
- package/test/fixtures/circle.geojson +0 -30
- package/test/fixtures/color.geojson +0 -21
- package/test/fixtures/fileshare.geojson +0 -28
- package/test/fixtures/geofence.geojson +0 -25
- package/test/fixtures/hae.geojson +0 -19
- package/test/fixtures/icon.geojson +0 -20
- package/test/fixtures/linestring.geojson +0 -28
- package/test/fixtures/marti-mission.geojson +0 -22
- package/test/fixtures/metadata.geojson +0 -24
- package/test/fixtures/mission-layer.geojson +0 -31
- package/test/fixtures/mission.geojson +0 -25
- package/test/fixtures/polygon.geojson +0 -33
- package/test/fixtures/props.geojson +0 -22
- package/test/fixtures/sensor.geojson +0 -31
- package/test/fixtures/video-connection.geojson +0 -27
- package/test/fixtures/video.geojson +0 -24
- package/test/flow-tags.test.ts +0 -21
- package/test/force-delete.ts +0 -50
- package/test/from_geojson.test.ts +0 -323
- package/test/newlines.test.ts +0 -83
- package/test/packages/AttachmentInManifest.zip +0 -0
- package/test/packages/COMilePosts.zip +0 -0
- package/test/packages/CameraCOTs.zip +0 -0
- package/test/packages/QuickPic.zip +0 -0
- package/test/reversal-geojson.test.ts +0 -19
- package/test/reversal-proto.test.ts +0 -60
- package/test/stream.ts +0 -10
- package/test/taskings-mission.test.ts +0 -148
- package/test/util.test.ts +0 -34
- package/test/validation.test.ts +0 -13
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "123",
|
|
3
|
-
"type": "Feature",
|
|
4
|
-
"path": "/",
|
|
5
|
-
"properties": {
|
|
6
|
-
"type": "a-f-G",
|
|
7
|
-
"how": "m-g",
|
|
8
|
-
"callsign": "BasicTest",
|
|
9
|
-
"center": [ 1.1, 2.2, 0 ],
|
|
10
|
-
"time": "2023-08-04T15:17:43.649Z",
|
|
11
|
-
"start": "2023-08-04T15:17:43.649Z",
|
|
12
|
-
"stale": "2023-08-04T15:17:43.649Z",
|
|
13
|
-
"metadata": {},
|
|
14
|
-
"mission": {
|
|
15
|
-
"type": "test-type",
|
|
16
|
-
"tool": "public",
|
|
17
|
-
"name": "Sample Mission",
|
|
18
|
-
"authorUid": "author",
|
|
19
|
-
"missionLayer": {
|
|
20
|
-
"name": "Sample Layer",
|
|
21
|
-
"type": "GROUP",
|
|
22
|
-
"parentUid": "parent",
|
|
23
|
-
"uid": "uid-123"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
"geometry": {
|
|
28
|
-
"type": "Point",
|
|
29
|
-
"coordinates": [1.1, 2.2, 0]
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "123",
|
|
3
|
-
"type": "Feature",
|
|
4
|
-
"path": "/",
|
|
5
|
-
"properties": {
|
|
6
|
-
"type": "a-f-G",
|
|
7
|
-
"how": "m-g",
|
|
8
|
-
"callsign": "BasicTest",
|
|
9
|
-
"center": [ 1.1, 2.2, 0 ],
|
|
10
|
-
"time": "2023-08-04T15:17:43.649Z",
|
|
11
|
-
"start": "2023-08-04T15:17:43.649Z",
|
|
12
|
-
"stale": "2023-08-04T15:17:43.649Z",
|
|
13
|
-
"metadata": {},
|
|
14
|
-
"mission": {
|
|
15
|
-
"type": "test-type",
|
|
16
|
-
"tool": "public",
|
|
17
|
-
"name": "Sample Mission",
|
|
18
|
-
"authorUid": "author"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"geometry": {
|
|
22
|
-
"type": "Point",
|
|
23
|
-
"coordinates": [1.1, 2.2, 0]
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "polygon",
|
|
3
|
-
"type": "Feature",
|
|
4
|
-
"path": "/",
|
|
5
|
-
"properties": {
|
|
6
|
-
"callsign": "Polygon",
|
|
7
|
-
"type": "u-d-f",
|
|
8
|
-
"how": "m-g",
|
|
9
|
-
"time": "2023-08-04T15:17:43.649Z",
|
|
10
|
-
"start": "2023-08-04T15:17:43.649Z",
|
|
11
|
-
"stale": "2023-08-04T15:17:43.649Z",
|
|
12
|
-
"center": [-108.44547861831613,39.080930442851155,0],
|
|
13
|
-
"stroke": "#FFFFFF",
|
|
14
|
-
"stroke-opacity": 0.4,
|
|
15
|
-
"stroke-width": 3,
|
|
16
|
-
"stroke-style": "solid",
|
|
17
|
-
"fill-opacity": 0.4,
|
|
18
|
-
"fill": "#000000",
|
|
19
|
-
"metadata": {}
|
|
20
|
-
},
|
|
21
|
-
"geometry": {
|
|
22
|
-
"type": "Polygon",
|
|
23
|
-
"coordinates": [
|
|
24
|
-
[
|
|
25
|
-
[ -108.45020149425852, 39.08453755983737 ],
|
|
26
|
-
[ -108.45020149425852, 39.07732332586494 ],
|
|
27
|
-
[ -108.44075574237374, 39.07732332586494 ],
|
|
28
|
-
[ -108.44075574237374, 39.08453755983737 ],
|
|
29
|
-
[ -108.45020149425852, 39.08453755983737 ]
|
|
30
|
-
]
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "123",
|
|
3
|
-
"type": "Feature",
|
|
4
|
-
"path": "/",
|
|
5
|
-
"properties": {
|
|
6
|
-
"type": "a-f-G",
|
|
7
|
-
"how": "m-g",
|
|
8
|
-
"callsign": "BasicTest",
|
|
9
|
-
"center": [ 1.1, 2.2, 0 ],
|
|
10
|
-
"time": "2023-08-04T15:17:43.649Z",
|
|
11
|
-
"start": "2023-08-04T15:17:43.649Z",
|
|
12
|
-
"stale": "2023-08-04T15:17:43.649Z",
|
|
13
|
-
"remarks": "test-remarks",
|
|
14
|
-
"course": 260,
|
|
15
|
-
"speed": 120,
|
|
16
|
-
"metadata": {}
|
|
17
|
-
},
|
|
18
|
-
"geometry": {
|
|
19
|
-
"type": "Point",
|
|
20
|
-
"coordinates": [1.1, 2.2, 0]
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "123",
|
|
3
|
-
"type": "Feature",
|
|
4
|
-
"path": "/",
|
|
5
|
-
"properties": {
|
|
6
|
-
"type": "a-f-G",
|
|
7
|
-
"how": "m-g",
|
|
8
|
-
"callsign": "BasicTest",
|
|
9
|
-
"center": [ 1.1, 2.2, 0 ],
|
|
10
|
-
"time": "2023-08-04T15:17:43.649Z",
|
|
11
|
-
"start": "2023-08-04T15:17:43.649Z",
|
|
12
|
-
"stale": "2023-08-04T15:17:43.649Z",
|
|
13
|
-
"sensor": {
|
|
14
|
-
"elevation": 0,
|
|
15
|
-
"vfov": 41.6,
|
|
16
|
-
"north": 320.8000030518,
|
|
17
|
-
"roll": 0,
|
|
18
|
-
"range": 300,
|
|
19
|
-
"azimuth": 140,
|
|
20
|
-
"model": "Mavic 2 Enterprise Dual-Visual",
|
|
21
|
-
"fov": 66.9,
|
|
22
|
-
"type": "r-e",
|
|
23
|
-
"version": "0.6"
|
|
24
|
-
},
|
|
25
|
-
"metadata": {}
|
|
26
|
-
},
|
|
27
|
-
"geometry": {
|
|
28
|
-
"type": "Point",
|
|
29
|
-
"coordinates": [1.1, 2.2, 0]
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "123",
|
|
3
|
-
"type": "Feature",
|
|
4
|
-
"path": "/",
|
|
5
|
-
"properties": {
|
|
6
|
-
"type": "a-f-G",
|
|
7
|
-
"how": "m-g",
|
|
8
|
-
"callsign": "BasicTest",
|
|
9
|
-
"center": [ 1.1, 2.2, 0 ],
|
|
10
|
-
"time": "2023-08-04T15:17:43.649Z",
|
|
11
|
-
"start": "2023-08-04T15:17:43.649Z",
|
|
12
|
-
"stale": "2023-08-04T15:17:43.649Z",
|
|
13
|
-
"video": {
|
|
14
|
-
"uid": "123",
|
|
15
|
-
"url": "rtsp://18.254.132.90:8554/money",
|
|
16
|
-
"connection": {
|
|
17
|
-
"uid": "123",
|
|
18
|
-
"address": "rtsp://18.254.132.90:8554/money"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"metadata": {}
|
|
22
|
-
},
|
|
23
|
-
"geometry": {
|
|
24
|
-
"type": "Point",
|
|
25
|
-
"coordinates": [1.1, 2.2, 0]
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "123",
|
|
3
|
-
"type": "Feature",
|
|
4
|
-
"path": "/",
|
|
5
|
-
"properties": {
|
|
6
|
-
"type": "a-f-G",
|
|
7
|
-
"how": "m-g",
|
|
8
|
-
"callsign": "BasicTest",
|
|
9
|
-
"center": [ 1.1, 2.2, 0 ],
|
|
10
|
-
"time": "2023-08-04T15:17:43.649Z",
|
|
11
|
-
"start": "2023-08-04T15:17:43.649Z",
|
|
12
|
-
"stale": "2023-08-04T15:17:43.649Z",
|
|
13
|
-
"video": {
|
|
14
|
-
"sensor": "UAS-CO DFPC Lawrence",
|
|
15
|
-
"spi": "UAS-CO DFPC Lawrence.SPI1",
|
|
16
|
-
"url": "rtsp://18.254.132.90:8554/money"
|
|
17
|
-
},
|
|
18
|
-
"metadata": {}
|
|
19
|
-
},
|
|
20
|
-
"geometry": {
|
|
21
|
-
"type": "Point",
|
|
22
|
-
"coordinates": [1.1, 2.2, 0]
|
|
23
|
-
}
|
|
24
|
-
}
|
package/test/flow-tags.test.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import test from 'tape';
|
|
2
|
-
import { DirectChat } from '../index.js';
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
|
|
5
|
-
test('FlowTags - Basic', (t) => {
|
|
6
|
-
const pkg = JSON.parse(String(fs.readFileSync(new URL('../package.json', import.meta.url))));
|
|
7
|
-
|
|
8
|
-
const cot = new DirectChat({
|
|
9
|
-
to: { uid: '123456', callsign: 'Alpha Operator' },
|
|
10
|
-
from: { uid: '654321', callsign: 'Bravo Operator' },
|
|
11
|
-
message: 'Direct Message Test'
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
if (!cot.raw.event.detail || !cot.raw.event.detail['_flow-tags_']) {
|
|
15
|
-
t.fail('No Detail Section')
|
|
16
|
-
} else {
|
|
17
|
-
t.equals(typeof cot.raw.event.detail['_flow-tags_'][`NodeCoT-${pkg.version}`], 'string');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
t.end();
|
|
21
|
-
});
|
package/test/force-delete.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import test from 'tape';
|
|
2
|
-
import CoT, { ForceDelete } from '../index.js';
|
|
3
|
-
|
|
4
|
-
test('ForceDelete - Basic', (t) => {
|
|
5
|
-
const cot = new CoT(new ForceDelete('delete-uid').to_xml());
|
|
6
|
-
|
|
7
|
-
if (!cot.raw.event.detail) {
|
|
8
|
-
t.fail('No Detail Section')
|
|
9
|
-
} else {
|
|
10
|
-
t.ok(cot.raw.event.detail['_flow-tags_']);
|
|
11
|
-
delete cot.raw.event.detail['_flow-tags_'];
|
|
12
|
-
|
|
13
|
-
t.equals(typeof cot.raw.event._attributes.time, 'string');
|
|
14
|
-
cot.raw.event._attributes.time = '2024-04-01'
|
|
15
|
-
t.equals(typeof cot.raw.event._attributes.start, 'string');
|
|
16
|
-
cot.raw.event._attributes.start = '2024-04-01'
|
|
17
|
-
t.equals(typeof cot.raw.event._attributes.stale, 'string');
|
|
18
|
-
cot.raw.event._attributes.stale = '2024-04-01'
|
|
19
|
-
|
|
20
|
-
t.deepEquals(cot.raw, {
|
|
21
|
-
event: {
|
|
22
|
-
_attributes: {
|
|
23
|
-
uid: 'delete-uid',
|
|
24
|
-
version: '2.0',
|
|
25
|
-
type: 't-x-d-d',
|
|
26
|
-
how: 'm-g',
|
|
27
|
-
|
|
28
|
-
time: '2024-04-01',
|
|
29
|
-
stale: '2024-04-01',
|
|
30
|
-
start: '2024-04-01'
|
|
31
|
-
},
|
|
32
|
-
point: {
|
|
33
|
-
_attributes: { lat: '0.000000', lon: '0.000000', hae: '0.0', ce: '9999999.0', le: '9999999.0' }
|
|
34
|
-
},
|
|
35
|
-
detail: {
|
|
36
|
-
__forcedelete: {},
|
|
37
|
-
link: {
|
|
38
|
-
_attributes: {
|
|
39
|
-
uid: 'delete-uid',
|
|
40
|
-
type: 'none',
|
|
41
|
-
relation: 'none'
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
t.end();
|
|
50
|
-
});
|
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import test from 'tape';
|
|
2
|
-
import CoT from '../index.js';
|
|
3
|
-
|
|
4
|
-
test('CoT.from_geojson - Point', (t) => {
|
|
5
|
-
const geo = CoT.from_geojson({
|
|
6
|
-
type: 'Feature',
|
|
7
|
-
properties: {},
|
|
8
|
-
geometry: {
|
|
9
|
-
type: 'Point',
|
|
10
|
-
coordinates: [1.1, 2.2]
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
t.equals(geo.raw.event._attributes.version, '2.0');
|
|
15
|
-
t.equals(geo.raw.event._attributes.type, 'a-f-G');
|
|
16
|
-
t.equals(geo.raw.event._attributes.how, 'm-g');
|
|
17
|
-
t.equals(geo.raw.event._attributes.uid.length, 36);
|
|
18
|
-
t.equals(geo.raw.event._attributes.time.length, 24);
|
|
19
|
-
t.equals(geo.raw.event._attributes.start.length, 24);
|
|
20
|
-
t.equals(geo.raw.event._attributes.stale.length, 24);
|
|
21
|
-
|
|
22
|
-
t.deepEquals(geo.raw.event.point, {
|
|
23
|
-
_attributes: { lat: '2.2', lon: '1.1', hae: '0.0', ce: '9999999.0', le: '9999999.0' }
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
if (!geo.raw.event.detail || !geo.raw.event.detail.remarks) {
|
|
27
|
-
t.fail('No Detail Section')
|
|
28
|
-
} else {
|
|
29
|
-
t.ok(geo.raw.event.detail['_flow-tags_']);
|
|
30
|
-
delete geo.raw.event.detail['_flow-tags_'];
|
|
31
|
-
|
|
32
|
-
t.deepEquals(geo.raw.event.detail, {
|
|
33
|
-
contact: { _attributes: { callsign: 'UNKNOWN' } },
|
|
34
|
-
remarks: { _attributes: {}, _text: '' }
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
t.end();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('CoT.from_geojson - Polygon', (t) => {
|
|
42
|
-
const geo = CoT.from_geojson({
|
|
43
|
-
type: 'Feature',
|
|
44
|
-
properties: {},
|
|
45
|
-
geometry: {
|
|
46
|
-
type: 'Polygon',
|
|
47
|
-
coordinates: [[
|
|
48
|
-
[-108.587, 39.098],
|
|
49
|
-
[-108.587, 39.032],
|
|
50
|
-
[-108.505, 39.032],
|
|
51
|
-
[-108.505, 39.098],
|
|
52
|
-
[-108.587, 39.098]
|
|
53
|
-
]]
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
t.equals(geo.raw.event._attributes.version, '2.0');
|
|
58
|
-
t.equals(geo.raw.event._attributes.type, 'u-d-f');
|
|
59
|
-
t.equals(geo.raw.event._attributes.how, 'm-g');
|
|
60
|
-
t.equals(geo.raw.event._attributes.uid.length, 36);
|
|
61
|
-
t.equals(geo.raw.event._attributes.time.length, 24);
|
|
62
|
-
t.equals(geo.raw.event._attributes.start.length, 24);
|
|
63
|
-
t.equals(geo.raw.event._attributes.stale.length, 24);
|
|
64
|
-
|
|
65
|
-
t.deepEquals(geo.raw.event.point, {
|
|
66
|
-
_attributes: { lat: '39.065', lon: '-108.54599999999999', hae: '0.0', ce: '9999999.0', le: '9999999.0' }
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
if (!geo.raw.event.detail || !geo.raw.event.detail.remarks) {
|
|
70
|
-
t.fail('No Detail Section')
|
|
71
|
-
} else {
|
|
72
|
-
t.ok(geo.raw.event.detail['_flow-tags_']);
|
|
73
|
-
delete geo.raw.event.detail['_flow-tags_'];
|
|
74
|
-
|
|
75
|
-
t.deepEquals(geo.raw.event.detail, {
|
|
76
|
-
contact: { _attributes: { callsign: 'UNKNOWN' } },
|
|
77
|
-
link: [
|
|
78
|
-
{ _attributes: { point: '39.098,-108.587' } },
|
|
79
|
-
{ _attributes: { point: '39.032,-108.587' } },
|
|
80
|
-
{ _attributes: { point: '39.032,-108.505' } },
|
|
81
|
-
{ _attributes: { point: '39.098,-108.505' } },
|
|
82
|
-
{ _attributes: { point: '39.098,-108.587' } },
|
|
83
|
-
],
|
|
84
|
-
labels_on: { _attributes: { value: 'false' } },
|
|
85
|
-
tog: { _attributes: { enabled: '0' } },
|
|
86
|
-
strokeColor: { _attributes: { value: '-2130706688' } },
|
|
87
|
-
strokeWeight: { _attributes: { value: '3' } },
|
|
88
|
-
strokeStyle: { _attributes: { value: 'solid' } },
|
|
89
|
-
fillColor: { _attributes: { value: '-2130706688' } },
|
|
90
|
-
remarks: { _attributes: {}, _text: '' }
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
t.end();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test('CoT.from_geojson - LineString', (t) => {
|
|
98
|
-
const geo = CoT.from_geojson({
|
|
99
|
-
type: 'Feature',
|
|
100
|
-
properties: {},
|
|
101
|
-
geometry: {
|
|
102
|
-
type: 'LineString',
|
|
103
|
-
coordinates: [
|
|
104
|
-
[-108.587, 39.098],
|
|
105
|
-
[-108.587, 39.032],
|
|
106
|
-
[-108.505, 39.032],
|
|
107
|
-
[-108.505, 39.098],
|
|
108
|
-
[-108.587, 39.098]
|
|
109
|
-
]
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
t.equals(geo.raw.event._attributes.version, '2.0');
|
|
114
|
-
t.equals(geo.raw.event._attributes.type, 'u-d-f');
|
|
115
|
-
t.equals(geo.raw.event._attributes.how, 'm-g');
|
|
116
|
-
t.equals(geo.raw.event._attributes.uid.length, 36);
|
|
117
|
-
t.equals(geo.raw.event._attributes.time.length, 24);
|
|
118
|
-
t.equals(geo.raw.event._attributes.start.length, 24);
|
|
119
|
-
t.equals(geo.raw.event._attributes.stale.length, 24);
|
|
120
|
-
|
|
121
|
-
t.deepEquals(geo.raw.event.point, {
|
|
122
|
-
_attributes: { lat: '39.098', lon: '-108.505', hae: '0.0', ce: '9999999.0', le: '9999999.0' }
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
if (!geo.raw.event.detail || !geo.raw.event.detail.remarks) {
|
|
126
|
-
t.fail('No Detail Section')
|
|
127
|
-
} else {
|
|
128
|
-
t.ok(geo.raw.event.detail['_flow-tags_']);
|
|
129
|
-
delete geo.raw.event.detail['_flow-tags_'];
|
|
130
|
-
|
|
131
|
-
t.deepEquals(geo.raw.event.detail, {
|
|
132
|
-
contact: { _attributes: { callsign: 'UNKNOWN' } },
|
|
133
|
-
link: [
|
|
134
|
-
{ _attributes: { point: '39.098,-108.587' } },
|
|
135
|
-
{ _attributes: { point: '39.032,-108.587' } },
|
|
136
|
-
{ _attributes: { point: '39.032,-108.505' } },
|
|
137
|
-
{ _attributes: { point: '39.098,-108.505' } },
|
|
138
|
-
{ _attributes: { point: '39.098,-108.587' } }
|
|
139
|
-
],
|
|
140
|
-
labels_on: { _attributes: { value: 'false' } },
|
|
141
|
-
tog: { _attributes: { enabled: '0' } },
|
|
142
|
-
strokeColor: { _attributes: { value: '-2130706688' } },
|
|
143
|
-
strokeWeight: { _attributes: { value: '3' } },
|
|
144
|
-
strokeStyle: { _attributes: { value: 'solid' } },
|
|
145
|
-
remarks: { _attributes: {}, _text: '' }
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
t.end();
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
test('CoT.from_geojson - Start', (t) => {
|
|
153
|
-
const geo = CoT.from_geojson({
|
|
154
|
-
type: 'Feature',
|
|
155
|
-
properties: {
|
|
156
|
-
// 1hr in the future
|
|
157
|
-
start: new Date(+new Date() + 60 * 60 * 1000).toISOString()
|
|
158
|
-
},
|
|
159
|
-
geometry: {
|
|
160
|
-
type: 'Point',
|
|
161
|
-
coordinates: [1.1, 2.2]
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// Approx +/- 100ms + 1hr ahead of Now
|
|
166
|
-
t.ok(+new Date(geo.raw.event._attributes.start) > +new Date() + 60 * 60 * 1000 - 100);
|
|
167
|
-
t.ok(+new Date(geo.raw.event._attributes.start) < +new Date() + 60 * 60 * 1000 + 100);
|
|
168
|
-
|
|
169
|
-
// Approx +/- 100ms ahead of Now
|
|
170
|
-
t.ok(+new Date(geo.raw.event._attributes.time) > +new Date() - 100);
|
|
171
|
-
t.ok(+new Date(geo.raw.event._attributes.time) < +new Date() + 100);
|
|
172
|
-
|
|
173
|
-
// Approx +/- 100ms +1hr20s ahead of now
|
|
174
|
-
t.ok(+new Date(geo.raw.event._attributes.stale) > +new Date(geo.raw.event._attributes.start) - 100 + 20 * 1000);
|
|
175
|
-
t.ok(+new Date(geo.raw.event._attributes.stale) < +new Date(geo.raw.event._attributes.start) + 100 + 20 * 1000);
|
|
176
|
-
|
|
177
|
-
t.end();
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
test('CoT.from_geojson - Start/Stale', (t) => {
|
|
181
|
-
const geo = CoT.from_geojson({
|
|
182
|
-
type: 'Feature',
|
|
183
|
-
properties: {
|
|
184
|
-
// 1hr in the future
|
|
185
|
-
start: new Date(+new Date() + 60 * 60 * 1000).toISOString(),
|
|
186
|
-
stale: 60 * 1000
|
|
187
|
-
},
|
|
188
|
-
geometry: {
|
|
189
|
-
type: 'Point',
|
|
190
|
-
coordinates: [1.1, 2.2]
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// Approx +/- 100ms + 1hr ahead of Now
|
|
195
|
-
t.ok(+new Date(geo.raw.event._attributes.start) > +new Date() + 60 * 60 * 1000 - 100);
|
|
196
|
-
t.ok(+new Date(geo.raw.event._attributes.start) < +new Date() + 60 * 60 * 1000 + 100);
|
|
197
|
-
|
|
198
|
-
// Approx +/- 100ms ahead of Now
|
|
199
|
-
t.ok(+new Date(geo.raw.event._attributes.time) > +new Date() - 100);
|
|
200
|
-
t.ok(+new Date(geo.raw.event._attributes.time) < +new Date() + 100);
|
|
201
|
-
|
|
202
|
-
// Approx +/- 100ms +1hr60s ahead of now
|
|
203
|
-
t.ok(+new Date(geo.raw.event._attributes.stale) > +new Date(geo.raw.event._attributes.start) - 100 + 60 * 1000);
|
|
204
|
-
t.ok(+new Date(geo.raw.event._attributes.stale) < +new Date(geo.raw.event._attributes.start) + 100 + 60 * 1000);
|
|
205
|
-
|
|
206
|
-
t.end();
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
test('CoT.from_geojson - Icon', (t) => {
|
|
210
|
-
const geo = CoT.from_geojson({
|
|
211
|
-
type: 'Feature',
|
|
212
|
-
properties: {
|
|
213
|
-
icon: '66f14976-4b62-4023-8edb-d8d2ebeaa336/Public Safety Air/EMS_ROTOR.png'
|
|
214
|
-
},
|
|
215
|
-
geometry: {
|
|
216
|
-
type: 'Point',
|
|
217
|
-
coordinates: [1.1, 2.2]
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
if (!geo.raw.event.detail || !geo.raw.event.detail.remarks) {
|
|
222
|
-
t.fail('No Detail Section')
|
|
223
|
-
} else {
|
|
224
|
-
t.ok(geo.raw.event.detail['_flow-tags_']);
|
|
225
|
-
delete geo.raw.event.detail['_flow-tags_'];
|
|
226
|
-
|
|
227
|
-
t.deepEquals(geo.raw.event.detail, {
|
|
228
|
-
contact: { _attributes: { callsign: 'UNKNOWN' } },
|
|
229
|
-
usericon: { _attributes: { iconsetpath: '66f14976-4b62-4023-8edb-d8d2ebeaa336/Public Safety Air/EMS_ROTOR.png' } }, remarks: { _attributes: {}, _text: '' }
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
t.end();
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
test('CoT.from_geojson - Height Above Earth', (t) => {
|
|
237
|
-
t.deepEquals(CoT.from_geojson({
|
|
238
|
-
type: 'Feature',
|
|
239
|
-
properties: {
|
|
240
|
-
},
|
|
241
|
-
geometry: {
|
|
242
|
-
type: 'Point',
|
|
243
|
-
coordinates: [1.1, 2.2]
|
|
244
|
-
}
|
|
245
|
-
}).raw.event.point._attributes, {
|
|
246
|
-
lat: '2.2',
|
|
247
|
-
lon: '1.1',
|
|
248
|
-
hae: '0.0',
|
|
249
|
-
ce: '9999999.0',
|
|
250
|
-
le: '9999999.0'
|
|
251
|
-
}, 'default hae');
|
|
252
|
-
|
|
253
|
-
t.deepEquals(CoT.from_geojson({
|
|
254
|
-
type: 'Feature',
|
|
255
|
-
properties: {
|
|
256
|
-
},
|
|
257
|
-
geometry: {
|
|
258
|
-
type: 'Point',
|
|
259
|
-
coordinates: [1.1, 2.2, 101]
|
|
260
|
-
}
|
|
261
|
-
}).raw.event.point._attributes, {
|
|
262
|
-
lat: '2.2',
|
|
263
|
-
lon: '1.1',
|
|
264
|
-
hae: '101',
|
|
265
|
-
ce: '9999999.0',
|
|
266
|
-
le: '9999999.0'
|
|
267
|
-
}, 'custom hae (meters)');
|
|
268
|
-
|
|
269
|
-
t.end();
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
test('CoT.from_geojson - Course & Speed', (t) => {
|
|
273
|
-
const cot = CoT.from_geojson({
|
|
274
|
-
type: 'Feature',
|
|
275
|
-
properties: {
|
|
276
|
-
course: 260,
|
|
277
|
-
speed: 120
|
|
278
|
-
},
|
|
279
|
-
geometry: {
|
|
280
|
-
type: 'Point',
|
|
281
|
-
coordinates: [1.1, 2.2]
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
if (!cot.raw.event.detail || !cot.raw.event.detail.remarks) {
|
|
286
|
-
t.fail('No Detail Section')
|
|
287
|
-
} else {
|
|
288
|
-
t.deepEquals(cot.raw.event.detail.track, {
|
|
289
|
-
_attributes: {
|
|
290
|
-
'course': '260',
|
|
291
|
-
'speed': '120'
|
|
292
|
-
}
|
|
293
|
-
}, 'track');
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
t.end();
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
test('CoT.from_geojson - Remarks', (t) => {
|
|
300
|
-
const cot = CoT.from_geojson({
|
|
301
|
-
type: 'Feature',
|
|
302
|
-
properties: {
|
|
303
|
-
course: 260,
|
|
304
|
-
speed: 120,
|
|
305
|
-
remarks: 'Test'
|
|
306
|
-
},
|
|
307
|
-
geometry: {
|
|
308
|
-
type: 'Point',
|
|
309
|
-
coordinates: [1.1, 2.2]
|
|
310
|
-
}
|
|
311
|
-
})
|
|
312
|
-
|
|
313
|
-
if (!cot.raw.event.detail || !cot.raw.event.detail.remarks) {
|
|
314
|
-
t.fail('No Detail Section')
|
|
315
|
-
} else {
|
|
316
|
-
t.deepEquals(cot.raw.event.detail.remarks, {
|
|
317
|
-
_attributes: {},
|
|
318
|
-
_text: 'Test'
|
|
319
|
-
}, 'track');
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
t.end();
|
|
323
|
-
});
|
package/test/newlines.test.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import test from 'tape';
|
|
2
|
-
import CoT from '../index.js';
|
|
3
|
-
|
|
4
|
-
test('Decode iTAK COT message', (t) => {
|
|
5
|
-
const packet = `<event version="2.0" uid="layer-35-4707" type="a-f-G" how="m-g" time="2024-06-07T15:28:48Z" start="2024-06-07T15:28:48.669Z" stale="2024-06-07T15:33:48.669Z"><point lat="39.1" lon="-105.1" hae="0.0" ce="9999999.0" le="9999999.0"/><detail><contact callsign="9T20"/><usericon iconsetpath="f7f71666-8b28-4b57-9fbb-e38e61d33b79/Google/police.png"/><remarks>Incident ID: 6841390
|
|
6
|
-
Master Incident Number: 05242024-0253042
|
|
7
|
-
Unit Name: 9F20
|
|
8
|
-
Unit ID: 3412
|
|
9
|
-
Status: Dispatched
|
|
10
|
-
Jurisdiction: Golden PD
|
|
11
|
-
Speed: 1</remarks><_flow-tags_ TAK-Server-e87a0e02420b44a08f6032bcf1877745="2024-06-07T15:28:48Z"><NodeCoT-8.1.0>2024-06-07T15:28:48.669Z</NodeCoT-8.1.0></_flow-tags_></detail></event>`
|
|
12
|
-
|
|
13
|
-
const cot = new CoT(packet);
|
|
14
|
-
|
|
15
|
-
if (!cot.raw.event.detail) {
|
|
16
|
-
t.fail('No Detail Section')
|
|
17
|
-
} else {
|
|
18
|
-
t.ok(cot.raw.event.detail['_flow-tags_']);
|
|
19
|
-
delete cot.raw.event.detail['_flow-tags_'];
|
|
20
|
-
|
|
21
|
-
t.deepEquals({
|
|
22
|
-
'event': {
|
|
23
|
-
'_attributes': {
|
|
24
|
-
'version': '2.0',
|
|
25
|
-
'uid': 'layer-35-4707',
|
|
26
|
-
'type': 'a-f-G',
|
|
27
|
-
'time': '2024-06-07T15:28:48Z',
|
|
28
|
-
'start': '2024-06-07T15:28:48.669Z',
|
|
29
|
-
'stale': '2024-06-07T15:33:48.669Z',
|
|
30
|
-
'how': 'm-g',
|
|
31
|
-
},
|
|
32
|
-
'point': {
|
|
33
|
-
'_attributes': {
|
|
34
|
-
'lat': '39.1',
|
|
35
|
-
'lon': '-105.1',
|
|
36
|
-
'hae': '0.0',
|
|
37
|
-
'ce': '9999999.0',
|
|
38
|
-
'le': '9999999.0'
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
detail: {
|
|
42
|
-
usericon: {
|
|
43
|
-
_attributes: {
|
|
44
|
-
"iconsetpath": "f7f71666-8b28-4b57-9fbb-e38e61d33b79/Google/police.png"
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
contact: {
|
|
48
|
-
_attributes: {
|
|
49
|
-
callsign: '9T20',
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
remarks: {
|
|
53
|
-
"_text": "Incident ID: 6841390\nMaster Incident Number: 05242024-0253042\nUnit Name: 9F20\nUnit ID: 3412\nStatus: Dispatched\nJurisdiction: Golden PD\nSpeed: 1"
|
|
54
|
-
},
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}, cot.raw);
|
|
58
|
-
|
|
59
|
-
t.deepEquals(cot.to_geojson(), {
|
|
60
|
-
id: 'layer-35-4707',
|
|
61
|
-
type: 'Feature',
|
|
62
|
-
path: '/',
|
|
63
|
-
properties: {
|
|
64
|
-
callsign: '9T20',
|
|
65
|
-
type: 'a-f-G',
|
|
66
|
-
how: 'm-g',
|
|
67
|
-
center: [ -105.1, 39.1, 0],
|
|
68
|
-
remarks: "Incident ID: 6841390\nMaster Incident Number: 05242024-0253042\nUnit Name: 9F20\nUnit ID: 3412\nStatus: Dispatched\nJurisdiction: Golden PD\nSpeed: 1",
|
|
69
|
-
time: '2024-06-07T15:28:48Z',
|
|
70
|
-
start: '2024-06-07T15:28:48.669Z',
|
|
71
|
-
stale: '2024-06-07T15:33:48.669Z',
|
|
72
|
-
icon: "f7f71666-8b28-4b57-9fbb-e38e61d33b79/Google/police.png",
|
|
73
|
-
metadata: {},
|
|
74
|
-
},
|
|
75
|
-
geometry: {
|
|
76
|
-
type: 'Point',
|
|
77
|
-
coordinates: [ -105.1, 39.1, 0 ]
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
t.end();
|
|
83
|
-
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|