@tak-ps/node-cot 3.5.4 → 4.0.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 +6 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/{xml.js → cot.js} +151 -11
- package/dist/lib/{xml.js.map → cot.js.map} +1 -1
- package/dist/test/cot.test.js +5 -5
- package/dist/test/cot.test.js.map +1 -1
- package/dist/test/cot_is.test.js +353 -0
- package/dist/test/cot_is.test.js.map +1 -0
- package/dist/test/from_geojson.test.js +20 -20
- package/dist/test/from_geojson.test.js.map +1 -1
- package/index.ts +2 -2
- package/lib/{xml.ts → cot.ts} +171 -13
- package/lib/util.ts +1 -1
- package/package.json +1 -1
- package/test/cot.test.ts +5 -5
- package/test/cot_is.test.ts +431 -0
- package/test/from_geojson.test.ts +20 -20
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
## Version History
|
|
12
12
|
|
|
13
|
+
### v4.0.0
|
|
14
|
+
|
|
15
|
+
- :rocket: Rename `XMLCoT` to `CoT` and make it the default export
|
|
16
|
+
- :tada: Add `.is_` fns for testing CoT type
|
|
17
|
+
- :white_check_mark: Add `cot.is_*` unit tests
|
|
18
|
+
|
|
13
19
|
### v3.5.4
|
|
14
20
|
|
|
15
21
|
- :bug: Ensure `to_geojson` FN returns proper coordinate order
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
1
|
+
import CoT from './lib/cot.js';
|
|
2
|
+
export default CoT;
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,cAAc,CAAC;AAE/B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,cAAc,CAAC;AAE/B,eAAe,GAAG,CAAC"}
|
|
@@ -14,7 +14,7 @@ const ajv = (new AJV({ allErrors: true }))
|
|
|
14
14
|
*
|
|
15
15
|
* @prop raw Raw XML-JS representation of CoT
|
|
16
16
|
*/
|
|
17
|
-
export default class
|
|
17
|
+
export default class CoT {
|
|
18
18
|
raw;
|
|
19
19
|
constructor(cot) {
|
|
20
20
|
if (typeof cot === 'string' || cot instanceof Buffer) {
|
|
@@ -33,11 +33,11 @@ export default class XMLCot {
|
|
|
33
33
|
throw new Error(`${ajv.errors[0].message} (${ajv.errors[0].instancePath})`);
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* Return an
|
|
36
|
+
* Return an CoT Message
|
|
37
37
|
*
|
|
38
38
|
* @param {Object} feature GeoJSON Point Feature
|
|
39
39
|
*
|
|
40
|
-
* @return {
|
|
40
|
+
* @return {CoT}
|
|
41
41
|
*/
|
|
42
42
|
static from_geojson(feature) {
|
|
43
43
|
if (feature.type !== 'Feature')
|
|
@@ -122,7 +122,7 @@ export default class XMLCot {
|
|
|
122
122
|
cot.event.point._attributes.lon = String(centre.geometry.coordinates[0]);
|
|
123
123
|
cot.event.point._attributes.lat = String(centre.geometry.coordinates[1]);
|
|
124
124
|
}
|
|
125
|
-
return new
|
|
125
|
+
return new CoT(cot);
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* Return a GeoJSON Feature from an XML CoT message
|
|
@@ -158,17 +158,13 @@ export default class XMLCot {
|
|
|
158
158
|
return geojson;
|
|
159
159
|
}
|
|
160
160
|
to_xml() {
|
|
161
|
-
return xmljs.js2xml(this.raw, {
|
|
162
|
-
compact: true
|
|
163
|
-
});
|
|
161
|
+
return xmljs.js2xml(this.raw, { compact: true });
|
|
164
162
|
}
|
|
165
163
|
/**
|
|
166
164
|
* Return a CoT Message
|
|
167
|
-
*
|
|
168
|
-
* @returns {XMLCot}
|
|
169
165
|
*/
|
|
170
166
|
static ping() {
|
|
171
|
-
return new
|
|
167
|
+
return new CoT({
|
|
172
168
|
event: {
|
|
173
169
|
_attributes: Util.cot_event_attr('t-x-c-t', 'h-g-i-g-o'),
|
|
174
170
|
detail: {},
|
|
@@ -176,5 +172,149 @@ export default class XMLCot {
|
|
|
176
172
|
}
|
|
177
173
|
});
|
|
178
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Determines if the CoT message represents a Friendly Element
|
|
177
|
+
*
|
|
178
|
+
* @return {boolean}
|
|
179
|
+
*/
|
|
180
|
+
is_friend() {
|
|
181
|
+
return !!this.raw.event._attributes.type.match(/^a-f-/);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Determines if the CoT message represents a Hostile Element
|
|
185
|
+
*
|
|
186
|
+
* @return {boolean}
|
|
187
|
+
*/
|
|
188
|
+
is_hostile() {
|
|
189
|
+
return !!this.raw.event._attributes.type.match(/^a-h-/);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Determines if the CoT message represents a Unknown Element
|
|
193
|
+
*
|
|
194
|
+
* @return {boolean}
|
|
195
|
+
*/
|
|
196
|
+
is_unknown() {
|
|
197
|
+
return !!this.raw.event._attributes.type.match(/^a-u-/);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Determines if the CoT message represents a Pending Element
|
|
201
|
+
*
|
|
202
|
+
* @return {boolean}
|
|
203
|
+
*/
|
|
204
|
+
is_pending() {
|
|
205
|
+
return !!this.raw.event._attributes.type.match(/^a-p-/);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Determines if the CoT message represents an Assumed Element
|
|
209
|
+
*
|
|
210
|
+
* @return {boolean}
|
|
211
|
+
*/
|
|
212
|
+
is_assumed() {
|
|
213
|
+
return !!this.raw.event._attributes.type.match(/^a-a-/);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Determines if the CoT message represents a Neutral Element
|
|
217
|
+
*
|
|
218
|
+
* @return {boolean}
|
|
219
|
+
*/
|
|
220
|
+
is_neutral() {
|
|
221
|
+
return !!this.raw.event._attributes.type.match(/^a-n-/);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Determines if the CoT message represents a Suspect Element
|
|
225
|
+
*
|
|
226
|
+
* @return {boolean}
|
|
227
|
+
*/
|
|
228
|
+
is_suspect() {
|
|
229
|
+
return !!this.raw.event._attributes.type.match(/^a-s-/);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Determines if the CoT message represents a Joker Element
|
|
233
|
+
*
|
|
234
|
+
* @return {boolean}
|
|
235
|
+
*/
|
|
236
|
+
is_joker() {
|
|
237
|
+
return !!this.raw.event._attributes.type.match(/^a-j-/);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Determines if the CoT message represents a Faker Element
|
|
241
|
+
*
|
|
242
|
+
* @return {boolean}
|
|
243
|
+
*/
|
|
244
|
+
is_faker() {
|
|
245
|
+
return !!this.raw.event._attributes.type.match(/^a-k-/);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Determines if the CoT message represents an Element
|
|
249
|
+
*
|
|
250
|
+
* @return {boolean}
|
|
251
|
+
*/
|
|
252
|
+
is_atom() {
|
|
253
|
+
return !!this.raw.event._attributes.type.match(/^a-/);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Determines if the CoT message represents an Airborne Element
|
|
257
|
+
*
|
|
258
|
+
* @return {boolean}
|
|
259
|
+
*/
|
|
260
|
+
is_airborne() {
|
|
261
|
+
return !!this.raw.event._attributes.type.match(/^a-.-A/);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Determines if the CoT message represents a Ground Element
|
|
265
|
+
*
|
|
266
|
+
* @return {boolean}
|
|
267
|
+
*/
|
|
268
|
+
is_ground() {
|
|
269
|
+
return !!this.raw.event._attributes.type.match(/^a-.-G/);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Determines if the CoT message represents an Installation
|
|
273
|
+
*
|
|
274
|
+
* @return {boolean}
|
|
275
|
+
*/
|
|
276
|
+
is_installation() {
|
|
277
|
+
return !!this.raw.event._attributes.type.match(/^a-.-G-I/);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Determines if the CoT message represents a Vehicle
|
|
281
|
+
*
|
|
282
|
+
* @return {boolean}
|
|
283
|
+
*/
|
|
284
|
+
is_vehicle() {
|
|
285
|
+
return !!this.raw.event._attributes.type.match(/^a-.-G-E-V/);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Determines if the CoT message represents Equipment
|
|
289
|
+
*
|
|
290
|
+
* @return {boolean}
|
|
291
|
+
*/
|
|
292
|
+
is_equipment() {
|
|
293
|
+
return !!this.raw.event._attributes.type.match(/^a-.-G-E/);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Determines if the CoT message represents a Surface Element
|
|
297
|
+
*
|
|
298
|
+
* @return {boolean}
|
|
299
|
+
*/
|
|
300
|
+
is_surface() {
|
|
301
|
+
return !!this.raw.event._attributes.type.match(/^a-.-S/);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Determines if the CoT message represents a Subsurface Element
|
|
305
|
+
*
|
|
306
|
+
* @return {boolean}
|
|
307
|
+
*/
|
|
308
|
+
is_subsurface() {
|
|
309
|
+
return !!this.raw.event._attributes.type.match(/^a-.-U/);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Determines if the CoT message represents a UAV Element
|
|
313
|
+
*
|
|
314
|
+
* @return {boolean}
|
|
315
|
+
*/
|
|
316
|
+
is_uav() {
|
|
317
|
+
return !!this.raw.event._attributes.type.match(/^a-f-A-M-F-Q-r/);
|
|
318
|
+
}
|
|
179
319
|
}
|
|
180
|
-
//# sourceMappingURL=
|
|
320
|
+
//# sourceMappingURL=cot.js.map
|
|
@@ -1 +1 @@
|
|
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AAC,QAAQ,CAAC,CAAA;IAC5D,CAAC;IAED;;;;OAIG;IACH,aAAa;QACT,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAC5D,CAAC;IAED;;;;OAIG;IACH,MAAM;QACF,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;IACpE,CAAC;CACJ"}
|
package/dist/test/cot.test.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import test from 'tape';
|
|
2
|
-
import
|
|
2
|
+
import CoT from '../index.js';
|
|
3
3
|
test('Decode COT message', (t) => {
|
|
4
4
|
const packet = '<event version="2.0" uid="ANDROID-deadbeef" type="a-f-G-U-C" how="m-g" time="2021-02-27T20:32:24.771Z" start="2021-02-27T20:32:24.771Z" stale="2021-02-27T20:38:39.771Z"><point lat="1.234567" lon="-3.141592" hae="-25.7" ce="9.9" le="9999999.0"/><detail><takv os="29" version="4.0.0.0 (deadbeef).1234567890-CIV" device="Some Android Device" platform="ATAK-CIV"/><contact xmppUsername="xmpp@host.com" endpoint="*:-1:stcp" callsign="JENNY"/><uid Droid="JENNY"/><precisionlocation altsrc="GPS" geopointsrc="GPS"/><__group role="Team Member" name="Cyan"/><status battery="78"/><track course="80.24833892285461" speed="0.0"/></detail></event>';
|
|
5
|
-
t.deepEquals((new
|
|
5
|
+
t.deepEquals((new CoT(packet)).raw, {
|
|
6
6
|
'event': {
|
|
7
7
|
'_attributes': {
|
|
8
8
|
'version': '2.0',
|
|
@@ -50,7 +50,7 @@ test('Decode COT message', (t) => {
|
|
|
50
50
|
});
|
|
51
51
|
test('Decode COT message', (t) => {
|
|
52
52
|
const packet = '<event version="2.0" uid="TEST-deadbeef" type="a" how="m-g" time="2021-03-12T15:49:07.138Z" start="2021-03-12T15:49:07.138Z" stale="2021-03-12T15:49:07.138Z"><point lat="0.000000" lon="0.000000" hae="0.0" ce="9999999.0" le="9999999.0"/><detail><takv os="Android" version="10" device="Some Device" platform="python unittest"/><status battery="83"/><uid Droid="JENNY"/><contact callsign="JENNY" endpoint="*:-1:stcp" phone="800-867-5309"/><__group role="Team Member" name="Cyan"/><track course="90.1" speed="10.3"/></detail></event>';
|
|
53
|
-
t.deepEquals((new
|
|
53
|
+
t.deepEquals((new CoT(packet)).raw, {
|
|
54
54
|
'event': {
|
|
55
55
|
'_attributes': {
|
|
56
56
|
'version': '2.0',
|
|
@@ -158,7 +158,7 @@ test('Encode COT message', (t) => {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
|
-
t.deepEquals((new
|
|
161
|
+
t.deepEquals((new CoT(packet)).to_xml(), '<event version="2.0" uid="ANDROID-deadbeef" type="a-f-G-U-C" how="m-g" time="2021-02-27T20:32:24.771Z" start="2021-02-27T20:32:24.771Z" stale="2021-02-27T20:38:39.771Z"><point lat="1.234567" lon="-3.141592" hae="-25.7" ce="9.9" le="9999999"/><detail><takv os="29" version="4.0.0.0 (deadbeef).1234567890-CIV" device="Some Android Device" platform="ATAK-CIV"/><contact xmppUsername="xmpp@host.com" endpoint="*:-1:stcp" callsign="JENNY"/><uid Droid="JENNY"/><precisionlocation altsrc="GPS" geopointsrc="GPS"/><__group role="Team Member" name="Cyan"/><status battery="78"/><track course="80.24833892285461" speed="0.0"/></detail></event>');
|
|
162
162
|
t.end();
|
|
163
163
|
});
|
|
164
164
|
test('Parse GeoChat message', (t) => {
|
|
@@ -176,7 +176,7 @@ test('Parse GeoChat message', (t) => {
|
|
|
176
176
|
' </marti>\n' +
|
|
177
177
|
' </detail>\n' +
|
|
178
178
|
'</event>';
|
|
179
|
-
t.deepEquals((new
|
|
179
|
+
t.deepEquals((new CoT(geochat)).raw, {
|
|
180
180
|
'event': {
|
|
181
181
|
'_attributes': {
|
|
182
182
|
'version': '2.0',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cot.test.js","sourceRoot":"","sources":["../../test/cot.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"cot.test.js","sourceRoot":"","sources":["../../test/cot.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,aAAa,CAAC;AAE9B,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC,EAAE,EAAE;IAC7B,MAAM,MAAM,GAAG,6nBAA6nB,CAAC;IAE7oB,CAAC,CAAC,UAAU,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE;QAChC,OAAO,EAAE;YACL,aAAa,EAAE;gBACX,SAAS,EAAE,KAAK;gBAChB,KAAK,EAAE,kBAAkB;gBACzB,MAAM,EAAE,WAAW;gBACnB,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,0BAA0B;gBAClC,OAAO,EAAE,0BAA0B;gBACnC,OAAO,EAAE,0BAA0B;aACtC;YACD,OAAO,EAAE;gBACL,aAAa,EAAE;oBACX,KAAK,EAAE,UAAU;oBACjB,KAAK,EAAE,WAAW;oBAClB,KAAK,EAAE,OAAO;oBACd,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,WAAW;iBACpB;aACJ;YACD,QAAQ,EAAE;gBACN,MAAM,EAAE;oBACJ,aAAa,EAAE;wBACX,IAAI,EAAE,IAAI;wBACV,SAAS,EAAE,mCAAmC;wBAC9C,QAAQ,EAAE,qBAAqB;wBAC/B,UAAU,EAAE,UAAU;qBACzB;iBACJ;gBACD,SAAS,EAAE;oBACP,aAAa,EAAE;wBACX,cAAc,EAAE,eAAe;wBAC/B,UAAU,EAAE,WAAW;wBACvB,UAAU,EAAE,OAAO;qBACtB;iBACJ;gBACD,KAAK,EAAE,EAAE,aAAa,EAAE,EAAE,OAAO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|
1
|
+
import test from 'tape';
|
|
2
|
+
import CoT from '../index.js';
|
|
3
|
+
test('CoT.is_friend', (t) => {
|
|
4
|
+
let cot = CoT.from_geojson({
|
|
5
|
+
type: 'Feature',
|
|
6
|
+
properties: {
|
|
7
|
+
type: 'a-f-B'
|
|
8
|
+
},
|
|
9
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
10
|
+
});
|
|
11
|
+
t.ok(cot.is_friend());
|
|
12
|
+
cot = CoT.from_geojson({
|
|
13
|
+
type: 'Feature',
|
|
14
|
+
properties: {
|
|
15
|
+
type: 'a-h-B'
|
|
16
|
+
},
|
|
17
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
18
|
+
});
|
|
19
|
+
t.notOk(cot.is_friend());
|
|
20
|
+
t.end();
|
|
21
|
+
});
|
|
22
|
+
test('CoT.is_hostile', (t) => {
|
|
23
|
+
let cot = CoT.from_geojson({
|
|
24
|
+
type: 'Feature',
|
|
25
|
+
properties: {
|
|
26
|
+
type: 'a-h-B'
|
|
27
|
+
},
|
|
28
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
29
|
+
});
|
|
30
|
+
t.ok(cot.is_hostile());
|
|
31
|
+
cot = CoT.from_geojson({
|
|
32
|
+
type: 'Feature',
|
|
33
|
+
properties: {
|
|
34
|
+
type: 'a-f-B'
|
|
35
|
+
},
|
|
36
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
37
|
+
});
|
|
38
|
+
t.notOk(cot.is_hostile());
|
|
39
|
+
t.end();
|
|
40
|
+
});
|
|
41
|
+
test('CoT.is_unknown', (t) => {
|
|
42
|
+
let cot = CoT.from_geojson({
|
|
43
|
+
type: 'Feature',
|
|
44
|
+
properties: {
|
|
45
|
+
type: 'a-u-B'
|
|
46
|
+
},
|
|
47
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
48
|
+
});
|
|
49
|
+
t.ok(cot.is_unknown());
|
|
50
|
+
cot = CoT.from_geojson({
|
|
51
|
+
type: 'Feature',
|
|
52
|
+
properties: {
|
|
53
|
+
type: 'a-f-B'
|
|
54
|
+
},
|
|
55
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
56
|
+
});
|
|
57
|
+
t.notOk(cot.is_unknown());
|
|
58
|
+
t.end();
|
|
59
|
+
});
|
|
60
|
+
test('CoT.is_pending', (t) => {
|
|
61
|
+
let cot = CoT.from_geojson({
|
|
62
|
+
type: 'Feature',
|
|
63
|
+
properties: {
|
|
64
|
+
type: 'a-p-B'
|
|
65
|
+
},
|
|
66
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
67
|
+
});
|
|
68
|
+
t.ok(cot.is_pending());
|
|
69
|
+
cot = CoT.from_geojson({
|
|
70
|
+
type: 'Feature',
|
|
71
|
+
properties: {
|
|
72
|
+
type: 'a-f-B'
|
|
73
|
+
},
|
|
74
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
75
|
+
});
|
|
76
|
+
t.notOk(cot.is_pending());
|
|
77
|
+
t.end();
|
|
78
|
+
});
|
|
79
|
+
test('CoT.is_assumed', (t) => {
|
|
80
|
+
let cot = CoT.from_geojson({
|
|
81
|
+
type: 'Feature',
|
|
82
|
+
properties: {
|
|
83
|
+
type: 'a-a-B'
|
|
84
|
+
},
|
|
85
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
86
|
+
});
|
|
87
|
+
t.ok(cot.is_assumed());
|
|
88
|
+
cot = CoT.from_geojson({
|
|
89
|
+
type: 'Feature',
|
|
90
|
+
properties: {
|
|
91
|
+
type: 'a-f-B'
|
|
92
|
+
},
|
|
93
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
94
|
+
});
|
|
95
|
+
t.notOk(cot.is_assumed());
|
|
96
|
+
t.end();
|
|
97
|
+
});
|
|
98
|
+
test('CoT.is_neutral', (t) => {
|
|
99
|
+
let cot = CoT.from_geojson({
|
|
100
|
+
type: 'Feature',
|
|
101
|
+
properties: {
|
|
102
|
+
type: 'a-n-B'
|
|
103
|
+
},
|
|
104
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
105
|
+
});
|
|
106
|
+
t.ok(cot.is_neutral());
|
|
107
|
+
cot = CoT.from_geojson({
|
|
108
|
+
type: 'Feature',
|
|
109
|
+
properties: {
|
|
110
|
+
type: 'a-f-B'
|
|
111
|
+
},
|
|
112
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
113
|
+
});
|
|
114
|
+
t.notOk(cot.is_neutral());
|
|
115
|
+
t.end();
|
|
116
|
+
});
|
|
117
|
+
test('CoT.is_suspect', (t) => {
|
|
118
|
+
let cot = CoT.from_geojson({
|
|
119
|
+
type: 'Feature',
|
|
120
|
+
properties: {
|
|
121
|
+
type: 'a-s-B'
|
|
122
|
+
},
|
|
123
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
124
|
+
});
|
|
125
|
+
t.ok(cot.is_suspect());
|
|
126
|
+
cot = CoT.from_geojson({
|
|
127
|
+
type: 'Feature',
|
|
128
|
+
properties: {
|
|
129
|
+
type: 'a-f-B'
|
|
130
|
+
},
|
|
131
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
132
|
+
});
|
|
133
|
+
t.notOk(cot.is_suspect());
|
|
134
|
+
t.end();
|
|
135
|
+
});
|
|
136
|
+
test('CoT.is_joker', (t) => {
|
|
137
|
+
let cot = CoT.from_geojson({
|
|
138
|
+
type: 'Feature',
|
|
139
|
+
properties: {
|
|
140
|
+
type: 'a-j-B'
|
|
141
|
+
},
|
|
142
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
143
|
+
});
|
|
144
|
+
t.ok(cot.is_joker());
|
|
145
|
+
cot = CoT.from_geojson({
|
|
146
|
+
type: 'Feature',
|
|
147
|
+
properties: {
|
|
148
|
+
type: 'a-f-B'
|
|
149
|
+
},
|
|
150
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
151
|
+
});
|
|
152
|
+
t.notOk(cot.is_joker());
|
|
153
|
+
t.end();
|
|
154
|
+
});
|
|
155
|
+
test('CoT.is_faker', (t) => {
|
|
156
|
+
let cot = CoT.from_geojson({
|
|
157
|
+
type: 'Feature',
|
|
158
|
+
properties: {
|
|
159
|
+
type: 'a-k-B'
|
|
160
|
+
},
|
|
161
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
162
|
+
});
|
|
163
|
+
t.ok(cot.is_faker());
|
|
164
|
+
cot = CoT.from_geojson({
|
|
165
|
+
type: 'Feature',
|
|
166
|
+
properties: {
|
|
167
|
+
type: 'a-f-B'
|
|
168
|
+
},
|
|
169
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
170
|
+
});
|
|
171
|
+
t.notOk(cot.is_faker());
|
|
172
|
+
t.end();
|
|
173
|
+
});
|
|
174
|
+
test('CoT.is_atom', (t) => {
|
|
175
|
+
let cot = CoT.from_geojson({
|
|
176
|
+
type: 'Feature',
|
|
177
|
+
properties: {
|
|
178
|
+
type: 'a-'
|
|
179
|
+
},
|
|
180
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
181
|
+
});
|
|
182
|
+
t.ok(cot.is_atom());
|
|
183
|
+
cot = CoT.from_geojson({
|
|
184
|
+
type: 'Feature',
|
|
185
|
+
properties: {
|
|
186
|
+
type: 'h'
|
|
187
|
+
},
|
|
188
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
189
|
+
});
|
|
190
|
+
t.notOk(cot.is_atom());
|
|
191
|
+
t.end();
|
|
192
|
+
});
|
|
193
|
+
test('CoT.is_airborne', (t) => {
|
|
194
|
+
let cot = CoT.from_geojson({
|
|
195
|
+
type: 'Feature',
|
|
196
|
+
properties: {
|
|
197
|
+
type: 'a-f-A'
|
|
198
|
+
},
|
|
199
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
200
|
+
});
|
|
201
|
+
t.ok(cot.is_airborne());
|
|
202
|
+
cot = CoT.from_geojson({
|
|
203
|
+
type: 'Feature',
|
|
204
|
+
properties: {
|
|
205
|
+
type: 'a-h-G'
|
|
206
|
+
},
|
|
207
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
208
|
+
});
|
|
209
|
+
t.notOk(cot.is_airborne());
|
|
210
|
+
t.end();
|
|
211
|
+
});
|
|
212
|
+
test('CoT.is_ground', (t) => {
|
|
213
|
+
let cot = CoT.from_geojson({
|
|
214
|
+
type: 'Feature',
|
|
215
|
+
properties: {
|
|
216
|
+
type: 'a-f-G'
|
|
217
|
+
},
|
|
218
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
219
|
+
});
|
|
220
|
+
t.ok(cot.is_ground());
|
|
221
|
+
cot = CoT.from_geojson({
|
|
222
|
+
type: 'Feature',
|
|
223
|
+
properties: {
|
|
224
|
+
type: 'a-h-A'
|
|
225
|
+
},
|
|
226
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
227
|
+
});
|
|
228
|
+
t.notOk(cot.is_ground());
|
|
229
|
+
t.end();
|
|
230
|
+
});
|
|
231
|
+
test('CoT.is_installation', (t) => {
|
|
232
|
+
let cot = CoT.from_geojson({
|
|
233
|
+
type: 'Feature',
|
|
234
|
+
properties: {
|
|
235
|
+
type: 'a-f-G-I'
|
|
236
|
+
},
|
|
237
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
238
|
+
});
|
|
239
|
+
t.ok(cot.is_installation());
|
|
240
|
+
cot = CoT.from_geojson({
|
|
241
|
+
type: 'Feature',
|
|
242
|
+
properties: {
|
|
243
|
+
type: 'a-f-G'
|
|
244
|
+
},
|
|
245
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
246
|
+
});
|
|
247
|
+
t.notOk(cot.is_installation());
|
|
248
|
+
cot = CoT.from_geojson({
|
|
249
|
+
type: 'Feature',
|
|
250
|
+
properties: {
|
|
251
|
+
type: 'a-h-A'
|
|
252
|
+
},
|
|
253
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
254
|
+
});
|
|
255
|
+
t.notOk(cot.is_installation());
|
|
256
|
+
t.end();
|
|
257
|
+
});
|
|
258
|
+
test('CoT.is_vehicle', (t) => {
|
|
259
|
+
let cot = CoT.from_geojson({
|
|
260
|
+
type: 'Feature',
|
|
261
|
+
properties: {
|
|
262
|
+
type: 'a-f-G-E-V'
|
|
263
|
+
},
|
|
264
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
265
|
+
});
|
|
266
|
+
t.ok(cot.is_vehicle());
|
|
267
|
+
cot = CoT.from_geojson({
|
|
268
|
+
type: 'Feature',
|
|
269
|
+
properties: {
|
|
270
|
+
type: 'a-h-G-E-V'
|
|
271
|
+
},
|
|
272
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
273
|
+
});
|
|
274
|
+
t.ok(cot.is_vehicle());
|
|
275
|
+
cot = CoT.from_geojson({
|
|
276
|
+
type: 'Feature',
|
|
277
|
+
properties: {
|
|
278
|
+
type: 'a-f-G-E'
|
|
279
|
+
},
|
|
280
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
281
|
+
});
|
|
282
|
+
t.notOk(cot.is_vehicle());
|
|
283
|
+
t.end();
|
|
284
|
+
});
|
|
285
|
+
test('CoT.is_equipment', (t) => {
|
|
286
|
+
let cot = CoT.from_geojson({
|
|
287
|
+
type: 'Feature',
|
|
288
|
+
properties: {
|
|
289
|
+
type: 'a-f-G-E'
|
|
290
|
+
},
|
|
291
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
292
|
+
});
|
|
293
|
+
t.ok(cot.is_equipment());
|
|
294
|
+
cot = CoT.from_geojson({
|
|
295
|
+
type: 'Feature',
|
|
296
|
+
properties: {
|
|
297
|
+
type: 'a-f-G'
|
|
298
|
+
},
|
|
299
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
300
|
+
});
|
|
301
|
+
t.notOk(cot.is_equipment());
|
|
302
|
+
t.end();
|
|
303
|
+
});
|
|
304
|
+
test('CoT.is_surface', (t) => {
|
|
305
|
+
let cot = CoT.from_geojson({
|
|
306
|
+
type: 'Feature',
|
|
307
|
+
properties: {
|
|
308
|
+
type: 'a-f-S'
|
|
309
|
+
},
|
|
310
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
311
|
+
});
|
|
312
|
+
t.ok(cot.is_surface());
|
|
313
|
+
cot = CoT.from_geojson({
|
|
314
|
+
type: 'Feature',
|
|
315
|
+
properties: {
|
|
316
|
+
type: 'a-f-G'
|
|
317
|
+
},
|
|
318
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
319
|
+
});
|
|
320
|
+
t.notOk(cot.is_surface());
|
|
321
|
+
t.end();
|
|
322
|
+
});
|
|
323
|
+
test('CoT.is_subsurface', (t) => {
|
|
324
|
+
let cot = CoT.from_geojson({
|
|
325
|
+
type: 'Feature',
|
|
326
|
+
properties: {
|
|
327
|
+
type: 'a-f-U'
|
|
328
|
+
},
|
|
329
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
330
|
+
});
|
|
331
|
+
t.ok(cot.is_subsurface());
|
|
332
|
+
cot = CoT.from_geojson({
|
|
333
|
+
type: 'Feature',
|
|
334
|
+
properties: {
|
|
335
|
+
type: 'a-f-G'
|
|
336
|
+
},
|
|
337
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
338
|
+
});
|
|
339
|
+
t.notOk(cot.is_subsurface());
|
|
340
|
+
t.end();
|
|
341
|
+
});
|
|
342
|
+
test('CoT.is_uav', (t) => {
|
|
343
|
+
let cot = CoT.from_geojson({
|
|
344
|
+
type: 'Feature',
|
|
345
|
+
properties: {
|
|
346
|
+
type: 'a-f-A-M-F-Q-r'
|
|
347
|
+
},
|
|
348
|
+
geometry: { type: 'Point', coordinates: [0, 0] }
|
|
349
|
+
});
|
|
350
|
+
t.ok(cot.is_uav());
|
|
351
|
+
t.end();
|
|
352
|
+
});
|
|
353
|
+
//# sourceMappingURL=cot_is.test.js.map
|