@zaes/sidc 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +24 -3
- package/THIRD-PARTY-NOTICES +217 -0
- package/dist/cjs/2525c/data2525c.js +1965 -0
- package/dist/cjs/2525c/index.js +178 -0
- package/dist/cjs/catalog/data2525e.js +2704 -0
- package/dist/cjs/catalog/index.js +103 -0
- package/dist/cjs/catalog/types.js +2 -0
- package/dist/cjs/genc.js +298 -0
- package/dist/cjs/index.js +49 -0
- package/dist/cjs/letter.js +116 -0
- package/dist/cjs/numeric.js +117 -0
- package/dist/cjs/tables.js +146 -0
- package/dist/esm/2525c/data2525c.js +1962 -0
- package/dist/esm/2525c/index.js +174 -0
- package/dist/esm/catalog/data2525e.js +2701 -0
- package/dist/esm/catalog/index.js +96 -0
- package/dist/esm/catalog/types.js +1 -0
- package/dist/esm/genc.js +294 -0
- package/dist/esm/index.js +20 -0
- package/dist/esm/letter.js +112 -0
- package/dist/esm/numeric.js +113 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/tables.js +142 -0
- package/dist/types/2525c/data2525c.d.ts +10 -0
- package/dist/types/2525c/index.d.ts +22 -0
- package/dist/types/catalog/data2525e.d.ts +12 -0
- package/dist/types/catalog/index.d.ts +27 -0
- package/dist/types/catalog/types.d.ts +41 -0
- package/dist/types/genc.d.ts +12 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/letter.d.ts +51 -0
- package/dist/types/numeric.d.ts +63 -0
- package/dist/types/tables.d.ts +51 -0
- package/package.json +65 -6
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEntity = getEntity;
|
|
4
|
+
exports.listEntities = listEntities;
|
|
5
|
+
exports.getSectorModifier = getSectorModifier;
|
|
6
|
+
exports.listSectorModifiers = listSectorModifiers;
|
|
7
|
+
exports.describeSidc = describeSidc;
|
|
8
|
+
/**
|
|
9
|
+
* @zaes/sidc/catalog — what every 2525E Change 1 code means: entity names and hierarchy, what kind of
|
|
10
|
+
* drawing each is, its draw rule or icon type, and every sector modifier.
|
|
11
|
+
*
|
|
12
|
+
* A separate entry so that reading a code does not cost the ~175 KB of tables.
|
|
13
|
+
*
|
|
14
|
+
* @module @zaes/sidc/catalog
|
|
15
|
+
*/
|
|
16
|
+
const index_js_1 = require("../index.js");
|
|
17
|
+
const data2525e_js_1 = require("./data2525e.js");
|
|
18
|
+
let entities;
|
|
19
|
+
let modifiers;
|
|
20
|
+
const entityKey = (symbolSet, code) => `${symbolSet}:${code}`;
|
|
21
|
+
const modifierKey = (symbolSet, sector, code) => `${symbolSet}:${sector}:${code}`;
|
|
22
|
+
function entityIndex() {
|
|
23
|
+
if (entities)
|
|
24
|
+
return entities;
|
|
25
|
+
const rows = new Map(data2525e_js_1.ENTITIES_2525E.map((r) => [entityKey(r[0], r[1]), r]));
|
|
26
|
+
entities = new Map();
|
|
27
|
+
for (const [key, [symbolSet, code, name, kind, geometry, drawRule, iconType]] of rows) {
|
|
28
|
+
const path = [];
|
|
29
|
+
const entity = rows.get(entityKey(symbolSet, code.slice(0, 2) + '0000'));
|
|
30
|
+
const type = rows.get(entityKey(symbolSet, code.slice(0, 4) + '00'));
|
|
31
|
+
if (code !== '000000') {
|
|
32
|
+
if (entity && entity[1] !== code)
|
|
33
|
+
path.push(entity[2]);
|
|
34
|
+
if (type && type[1] !== code && type[1] !== (entity === null || entity === void 0 ? void 0 : entity[1]))
|
|
35
|
+
path.push(type[2]);
|
|
36
|
+
}
|
|
37
|
+
path.push(name);
|
|
38
|
+
entities.set(key, {
|
|
39
|
+
symbolSet,
|
|
40
|
+
code,
|
|
41
|
+
name,
|
|
42
|
+
path,
|
|
43
|
+
kind,
|
|
44
|
+
...(geometry ? { tableGeometry: geometry } : {}),
|
|
45
|
+
...(drawRule ? { drawRule, drawRuleAppendix: symbolSet === '45' || symbolSet === '46' ? 'M' : 'L' } : {}),
|
|
46
|
+
...(iconType ? { iconType } : {}),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return entities;
|
|
50
|
+
}
|
|
51
|
+
function modifierIndex() {
|
|
52
|
+
if (modifiers)
|
|
53
|
+
return modifiers;
|
|
54
|
+
modifiers = new Map(data2525e_js_1.MODIFIERS_2525E.map(([symbolSet, sector, code, name, category]) => [
|
|
55
|
+
modifierKey(symbolSet, sector, code),
|
|
56
|
+
{ symbolSet, sector: sector, code, name, category },
|
|
57
|
+
]));
|
|
58
|
+
return modifiers;
|
|
59
|
+
}
|
|
60
|
+
/** The entity a symbol set and positions 11–16 name, or undefined if 2525E Change 1 has none. */
|
|
61
|
+
function getEntity(symbolSet, code) {
|
|
62
|
+
return entityIndex().get(entityKey(symbolSet, code));
|
|
63
|
+
}
|
|
64
|
+
/** Every entity, in the standard's order, optionally of one symbol set or kind. */
|
|
65
|
+
function listEntities(filter = {}) {
|
|
66
|
+
return [...entityIndex().values()].filter((e) => (!filter.symbolSet || e.symbolSet === filter.symbolSet) && (!filter.kind || e.kind === filter.kind));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The sector modifier a code names. `identifier` is SIDC position 21 (sector 1) or 22 (sector 2):
|
|
70
|
+
* '0' looks in the symbol set's own table, anything else in the common table (A-IX, A-X), whose
|
|
71
|
+
* codes are the identifier followed by the two modifier positions.
|
|
72
|
+
*/
|
|
73
|
+
function getSectorModifier(symbolSet, sector, code, identifier = '0') {
|
|
74
|
+
return identifier === '0' ? modifierIndex().get(modifierKey(symbolSet, sector, code)) : modifierIndex().get(modifierKey('common', sector, identifier + code));
|
|
75
|
+
}
|
|
76
|
+
/** The sector modifiers of one symbol set (or `common`), in the standard's order. */
|
|
77
|
+
function listSectorModifiers(symbolSet, sector) {
|
|
78
|
+
return [...modifierIndex().values()].filter((m) => m.symbolSet === symbolSet && m.sector === sector);
|
|
79
|
+
}
|
|
80
|
+
/** What positions 11–20 of a 2525D/E code mean, by the 2525E Change 1 tables. */
|
|
81
|
+
function describeSidc(sidc) {
|
|
82
|
+
const parsed = typeof sidc === 'string' ? (0, index_js_1.parseSidc)(sidc) : { ok: true, sidc, problems: [] };
|
|
83
|
+
if (!parsed.ok)
|
|
84
|
+
return { problems: parsed.problems.map((p) => p.message) };
|
|
85
|
+
if (parsed.sidc.kind !== 'numeric')
|
|
86
|
+
return { problems: ['a 2525C letter code; convert it before describing it'] };
|
|
87
|
+
const s = parsed.sidc;
|
|
88
|
+
const problems = [];
|
|
89
|
+
const entity = getEntity(s.symbolSet, s.entityCode);
|
|
90
|
+
if (!entity)
|
|
91
|
+
problems.push(`entity ${s.entityCode} is not in symbol set ${s.symbolSet}`);
|
|
92
|
+
const modifier = (sector, code, identifier) => {
|
|
93
|
+
if (code === '00')
|
|
94
|
+
return undefined;
|
|
95
|
+
const m = getSectorModifier(s.symbolSet, sector, code, identifier);
|
|
96
|
+
if (!m)
|
|
97
|
+
problems.push(`sector ${sector} modifier ${identifier === '0' ? '' : identifier}${code} is not defined for symbol set ${s.symbolSet}`);
|
|
98
|
+
return m;
|
|
99
|
+
};
|
|
100
|
+
const sector1 = modifier(1, s.sector1, s.sector1Identifier);
|
|
101
|
+
const sector2 = modifier(2, s.sector2, s.sector2Identifier);
|
|
102
|
+
return { ...(entity ? { entity } : {}), ...(sector1 ? { sector1 } : {}), ...(sector2 ? { sector2 } : {}), problems };
|
|
103
|
+
}
|
package/dist/cjs/genc.js
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GENC (Geopolitical Entities, Names, and Codes) countries and entities by numeric code: SIDC
|
|
4
|
+
* positions 28–30 (MIL-STD-2525E A.5.5.4). Generated; do not edit.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.GENC_COUNTRIES = void 0;
|
|
8
|
+
exports.gencCountry = gencCountry;
|
|
9
|
+
/** [numeric, trigraph, digraph ('' where none is assigned), name]. 280 entries. */
|
|
10
|
+
exports.GENC_COUNTRIES = [
|
|
11
|
+
["004", "AFG", "AF", "AFGHANISTAN"],
|
|
12
|
+
["008", "ALB", "AL", "ALBANIA"],
|
|
13
|
+
["010", "ATA", "AQ", "ANTARCTICA"],
|
|
14
|
+
["012", "DZA", "DZ", "ALGERIA"],
|
|
15
|
+
["016", "ASM", "AS", "AMERICAN SAMOA"],
|
|
16
|
+
["020", "AND", "AD", "ANDORRA"],
|
|
17
|
+
["024", "AGO", "AO", "ANGOLA"],
|
|
18
|
+
["028", "ATG", "AG", "ANTIGUA AND BARBUDA"],
|
|
19
|
+
["031", "AZE", "AZ", "AZERBAIJAN"],
|
|
20
|
+
["032", "ARG", "AR", "ARGENTINA"],
|
|
21
|
+
["036", "AUS", "AU", "AUSTRALIA"],
|
|
22
|
+
["040", "AUT", "AT", "AUSTRIA"],
|
|
23
|
+
["044", "BHS", "BS", "BAHAMAS, THE"],
|
|
24
|
+
["048", "BHR", "BH", "BAHRAIN"],
|
|
25
|
+
["050", "BGD", "BD", "BANGLADESH"],
|
|
26
|
+
["051", "ARM", "AM", "ARMENIA"],
|
|
27
|
+
["052", "BRB", "BB", "BARBADOS"],
|
|
28
|
+
["056", "BEL", "BE", "BELGIUM"],
|
|
29
|
+
["060", "BMU", "BM", "BERMUDA"],
|
|
30
|
+
["064", "BTN", "BT", "BHUTAN"],
|
|
31
|
+
["068", "BOL", "BO", "BOLIVIA"],
|
|
32
|
+
["070", "BIH", "BA", "BOSNIA AND HERZEGOVINA"],
|
|
33
|
+
["072", "BWA", "BW", "BOTSWANA"],
|
|
34
|
+
["074", "BVT", "BV", "BOUVET ISLAND"],
|
|
35
|
+
["076", "BRA", "BR", "BRAZIL"],
|
|
36
|
+
["084", "BLZ", "BZ", "BELIZE"],
|
|
37
|
+
["086", "IOT", "IO", "BRITISH INDIAN OCEAN TERRITORY"],
|
|
38
|
+
["090", "SLB", "SB", "SOLOMON ISLANDS"],
|
|
39
|
+
["092", "VGB", "VG", "VIRGIN ISLANDS, BRITISH"],
|
|
40
|
+
["096", "BRN", "BN", "BRUNEI"],
|
|
41
|
+
["100", "BGR", "BG", "BULGARIA"],
|
|
42
|
+
["104", "MMR", "MM", "BURMA"],
|
|
43
|
+
["108", "BDI", "BI", "BURUNDI"],
|
|
44
|
+
["112", "BLR", "BY", "BELARUS"],
|
|
45
|
+
["116", "KHM", "KH", "CAMBODIA"],
|
|
46
|
+
["120", "CMR", "CM", "CAMEROON"],
|
|
47
|
+
["124", "CAN", "CA", "CANADA"],
|
|
48
|
+
["132", "CPV", "CV", "CABO VERDE"],
|
|
49
|
+
["136", "CYM", "KY", "CAYMAN ISLANDS"],
|
|
50
|
+
["140", "CAF", "CF", "CENTRAL AFRICAN REPUBLIC"],
|
|
51
|
+
["144", "LKA", "LK", "SRI LANKA"],
|
|
52
|
+
["148", "TCD", "TD", "CHAD"],
|
|
53
|
+
["152", "CHL", "CL", "CHILE"],
|
|
54
|
+
["156", "CHN", "CN", "CHINA"],
|
|
55
|
+
["158", "TWN", "TW", "TAIWAN"],
|
|
56
|
+
["162", "CXR", "CX", "CHRISTMAS ISLAND"],
|
|
57
|
+
["166", "CCK", "CC", "COCOS (KEELING) ISLANDS"],
|
|
58
|
+
["170", "COL", "CO", "COLOMBIA"],
|
|
59
|
+
["174", "COM", "KM", "COMOROS"],
|
|
60
|
+
["175", "MYT", "YT", "MAYOTTE"],
|
|
61
|
+
["178", "COG", "CG", "CONGO (BRAZZAVILLE)"],
|
|
62
|
+
["180", "COD", "CD", "CONGO (KINSHASA)"],
|
|
63
|
+
["184", "COK", "CK", "COOK ISLANDS"],
|
|
64
|
+
["188", "CRI", "CR", "COSTA RICA"],
|
|
65
|
+
["191", "HRV", "HR", "CROATIA"],
|
|
66
|
+
["192", "CUB", "CU", "CUBA"],
|
|
67
|
+
["196", "CYP", "CY", "CYPRUS"],
|
|
68
|
+
["203", "CZE", "CZ", "CZECHIA"],
|
|
69
|
+
["204", "BEN", "BJ", "BENIN"],
|
|
70
|
+
["208", "DNK", "DK", "DENMARK"],
|
|
71
|
+
["212", "DMA", "DM", "DOMINICA"],
|
|
72
|
+
["214", "DOM", "DO", "DOMINICAN REPUBLIC"],
|
|
73
|
+
["218", "ECU", "EC", "ECUADOR"],
|
|
74
|
+
["222", "SLV", "SV", "EL SALVADOR"],
|
|
75
|
+
["226", "GNQ", "GQ", "EQUATORIAL GUINEA"],
|
|
76
|
+
["231", "ETH", "ET", "ETHIOPIA"],
|
|
77
|
+
["232", "ERI", "ER", "ERITREA"],
|
|
78
|
+
["233", "EST", "EE", "ESTONIA"],
|
|
79
|
+
["234", "FRO", "FO", "FAROE ISLANDS"],
|
|
80
|
+
["238", "FLK", "FK", "FALKLAND ISLANDS (ISLAS MALVINAS)"],
|
|
81
|
+
["239", "SGS", "GS", "SOUTH GEORGIA AND SOUTH SANDWICH ISLANDS"],
|
|
82
|
+
["242", "FJI", "FJ", "FIJI"],
|
|
83
|
+
["246", "FIN", "FI", "FINLAND"],
|
|
84
|
+
["250", "FRA", "FR", "FRANCE"],
|
|
85
|
+
["254", "GUF", "GF", "FRENCH GUIANA"],
|
|
86
|
+
["258", "PYF", "PF", "FRENCH POLYNESIA"],
|
|
87
|
+
["260", "ATF", "TF", "FRENCH SOUTHERN AND ANTARCTIC LANDS"],
|
|
88
|
+
["262", "DJI", "DJ", "DJIBOUTI"],
|
|
89
|
+
["266", "GAB", "GA", "GABON"],
|
|
90
|
+
["268", "GEO", "GE", "GEORGIA"],
|
|
91
|
+
["270", "GMB", "GM", "GAMBIA, THE"],
|
|
92
|
+
["276", "DEU", "DE", "GERMANY"],
|
|
93
|
+
["288", "GHA", "GH", "GHANA"],
|
|
94
|
+
["292", "GIB", "GI", "GIBRALTAR"],
|
|
95
|
+
["296", "KIR", "KI", "KIRIBATI"],
|
|
96
|
+
["300", "GRC", "GR", "GREECE"],
|
|
97
|
+
["304", "GRL", "GL", "GREENLAND"],
|
|
98
|
+
["308", "GRD", "GD", "GRENADA"],
|
|
99
|
+
["312", "GLP", "GP", "GUADELOUPE"],
|
|
100
|
+
["316", "GUM", "GU", "GUAM"],
|
|
101
|
+
["320", "GTM", "GT", "GUATEMALA"],
|
|
102
|
+
["324", "GIN", "GN", "GUINEA"],
|
|
103
|
+
["328", "GUY", "GY", "GUYANA"],
|
|
104
|
+
["332", "HTI", "HT", "HAITI"],
|
|
105
|
+
["334", "HMD", "HM", "HEARD ISLAND AND MCDONALD ISLANDS"],
|
|
106
|
+
["336", "VAT", "VA", "VATICAN CITY"],
|
|
107
|
+
["340", "HND", "HN", "HONDURAS"],
|
|
108
|
+
["344", "HKG", "HK", "HONG KONG"],
|
|
109
|
+
["348", "HUN", "HU", "HUNGARY"],
|
|
110
|
+
["352", "ISL", "IS", "ICELAND"],
|
|
111
|
+
["356", "IND", "IN", "INDIA"],
|
|
112
|
+
["360", "IDN", "ID", "INDONESIA"],
|
|
113
|
+
["364", "IRN", "IR", "IRAN"],
|
|
114
|
+
["368", "IRQ", "IQ", "IRAQ"],
|
|
115
|
+
["372", "IRL", "IE", "IRELAND"],
|
|
116
|
+
["376", "ISR", "IL", "ISRAEL"],
|
|
117
|
+
["380", "ITA", "IT", "ITALY"],
|
|
118
|
+
["384", "CIV", "CI", "CÔTE D’IVOIRE"],
|
|
119
|
+
["388", "JAM", "JM", "JAMAICA"],
|
|
120
|
+
["392", "JPN", "JP", "JAPAN"],
|
|
121
|
+
["398", "KAZ", "KZ", "KAZAKHSTAN"],
|
|
122
|
+
["400", "JOR", "JO", "JORDAN"],
|
|
123
|
+
["404", "KEN", "KE", "KENYA"],
|
|
124
|
+
["408", "PRK", "KP", "KOREA, NORTH"],
|
|
125
|
+
["410", "KOR", "KR", "KOREA, SOUTH"],
|
|
126
|
+
["414", "KWT", "KW", "KUWAIT"],
|
|
127
|
+
["417", "KGZ", "KG", "KYRGYZSTAN"],
|
|
128
|
+
["418", "LAO", "LA", "LAOS"],
|
|
129
|
+
["422", "LBN", "LB", "LEBANON"],
|
|
130
|
+
["426", "LSO", "LS", "LESOTHO"],
|
|
131
|
+
["428", "LVA", "LV", "LATVIA"],
|
|
132
|
+
["430", "LBR", "LR", "LIBERIA"],
|
|
133
|
+
["434", "LBY", "LY", "LIBYA"],
|
|
134
|
+
["438", "LIE", "LI", "LIECHTENSTEIN"],
|
|
135
|
+
["440", "LTU", "LT", "LITHUANIA"],
|
|
136
|
+
["442", "LUX", "LU", "LUXEMBOURG"],
|
|
137
|
+
["446", "MAC", "MO", "MACAU"],
|
|
138
|
+
["450", "MDG", "MG", "MADAGASCAR"],
|
|
139
|
+
["454", "MWI", "MW", "MALAWI"],
|
|
140
|
+
["458", "MYS", "MY", "MALAYSIA"],
|
|
141
|
+
["462", "MDV", "MV", "MALDIVES"],
|
|
142
|
+
["466", "MLI", "ML", "MALI"],
|
|
143
|
+
["470", "MLT", "MT", "MALTA"],
|
|
144
|
+
["474", "MTQ", "MQ", "MARTINIQUE"],
|
|
145
|
+
["478", "MRT", "MR", "MAURITANIA"],
|
|
146
|
+
["480", "MUS", "MU", "MAURITIUS"],
|
|
147
|
+
["484", "MEX", "MX", "MEXICO"],
|
|
148
|
+
["492", "MCO", "MC", "MONACO"],
|
|
149
|
+
["496", "MNG", "MN", "MONGOLIA"],
|
|
150
|
+
["498", "MDA", "MD", "MOLDOVA"],
|
|
151
|
+
["499", "MNE", "ME", "MONTENEGRO"],
|
|
152
|
+
["500", "MSR", "MS", "MONTSERRAT"],
|
|
153
|
+
["504", "MAR", "MA", "MOROCCO"],
|
|
154
|
+
["508", "MOZ", "MZ", "MOZAMBIQUE"],
|
|
155
|
+
["512", "OMN", "OM", "OMAN"],
|
|
156
|
+
["516", "NAM", "NA", "NAMIBIA"],
|
|
157
|
+
["520", "NRU", "NR", "NAURU"],
|
|
158
|
+
["524", "NPL", "NP", "NEPAL"],
|
|
159
|
+
["528", "NLD", "NL", "NETHERLANDS"],
|
|
160
|
+
["531", "CUW", "CW", "CURAÇAO"],
|
|
161
|
+
["533", "ABW", "AW", "ARUBA"],
|
|
162
|
+
["534", "SXM", "SX", "SINT MAARTEN"],
|
|
163
|
+
["535", "BES", "BQ", "BONAIRE, SINT EUSTATIUS, AND SABA"],
|
|
164
|
+
["540", "NCL", "NC", "NEW CALEDONIA"],
|
|
165
|
+
["548", "VUT", "VU", "VANUATU"],
|
|
166
|
+
["554", "NZL", "NZ", "NEW ZEALAND"],
|
|
167
|
+
["558", "NIC", "NI", "NICARAGUA"],
|
|
168
|
+
["562", "NER", "NE", "NIGER"],
|
|
169
|
+
["566", "NGA", "NG", "NIGERIA"],
|
|
170
|
+
["570", "NIU", "NU", "NIUE"],
|
|
171
|
+
["574", "NFK", "NF", "NORFOLK ISLAND"],
|
|
172
|
+
["578", "NOR", "NO", "NORWAY"],
|
|
173
|
+
["580", "MNP", "MP", "NORTHERN MARIANA ISLANDS"],
|
|
174
|
+
["583", "FSM", "FM", "MICRONESIA, FEDERATED STATES OF"],
|
|
175
|
+
["584", "MHL", "MH", "MARSHALL ISLANDS"],
|
|
176
|
+
["585", "PLW", "PW", "PALAU"],
|
|
177
|
+
["586", "PAK", "PK", "PAKISTAN"],
|
|
178
|
+
["591", "PAN", "PA", "PANAMA"],
|
|
179
|
+
["598", "PNG", "PG", "PAPUA NEW GUINEA"],
|
|
180
|
+
["600", "PRY", "PY", "PARAGUAY"],
|
|
181
|
+
["604", "PER", "PE", "PERU"],
|
|
182
|
+
["608", "PHL", "PH", "PHILIPPINES"],
|
|
183
|
+
["612", "PCN", "PN", "PITCAIRN ISLANDS"],
|
|
184
|
+
["616", "POL", "PL", "POLAND"],
|
|
185
|
+
["620", "PRT", "PT", "PORTUGAL"],
|
|
186
|
+
["624", "GNB", "GW", "GUINEA-BISSAU"],
|
|
187
|
+
["626", "TLS", "TL", "TIMOR-LESTE"],
|
|
188
|
+
["630", "PRI", "PR", "PUERTO RICO"],
|
|
189
|
+
["634", "QAT", "QA", "QATAR"],
|
|
190
|
+
["638", "REU", "RE", "REUNION"],
|
|
191
|
+
["642", "ROU", "RO", "ROMANIA"],
|
|
192
|
+
["643", "RUS", "RU", "RUSSIA"],
|
|
193
|
+
["646", "RWA", "RW", "RWANDA"],
|
|
194
|
+
["652", "BLM", "BL", "SAINT BARTHELEMY"],
|
|
195
|
+
["654", "SHN", "SH", "SAINT HELENA, ASCENSION, AND TRISTAN DA CUNHA"],
|
|
196
|
+
["659", "KNA", "KN", "SAINT KITTS AND NEVIS"],
|
|
197
|
+
["660", "AIA", "AI", "ANGUILLA"],
|
|
198
|
+
["662", "LCA", "LC", "SAINT LUCIA"],
|
|
199
|
+
["663", "MAF", "MF", "SAINT MARTIN"],
|
|
200
|
+
["666", "SPM", "PM", "SAINT PIERRE AND MIQUELON"],
|
|
201
|
+
["670", "VCT", "VC", "SAINT VINCENT AND THE GRENADINES"],
|
|
202
|
+
["674", "SMR", "SM", "SAN MARINO"],
|
|
203
|
+
["678", "STP", "ST", "SAO TOME AND PRINCIPE"],
|
|
204
|
+
["682", "SAU", "SA", "SAUDI ARABIA"],
|
|
205
|
+
["686", "SEN", "SN", "SENEGAL"],
|
|
206
|
+
["688", "SRB", "RS", "SERBIA"],
|
|
207
|
+
["690", "SYC", "SC", "SEYCHELLES"],
|
|
208
|
+
["694", "SLE", "SL", "SIERRA LEONE"],
|
|
209
|
+
["702", "SGP", "SG", "SINGAPORE"],
|
|
210
|
+
["703", "SVK", "SK", "SLOVAKIA"],
|
|
211
|
+
["704", "VNM", "VN", "VIETNAM"],
|
|
212
|
+
["705", "SVN", "SI", "SLOVENIA"],
|
|
213
|
+
["706", "SOM", "SO", "SOMALIA"],
|
|
214
|
+
["710", "ZAF", "ZA", "SOUTH AFRICA"],
|
|
215
|
+
["716", "ZWE", "ZW", "ZIMBABWE"],
|
|
216
|
+
["724", "ESP", "ES", "SPAIN"],
|
|
217
|
+
["728", "SSD", "SS", "SOUTH SUDAN"],
|
|
218
|
+
["729", "SDN", "SD", "SUDAN"],
|
|
219
|
+
["732", "ESH", "EH", "WESTERN SAHARA"],
|
|
220
|
+
["740", "SUR", "SR", "SURINAME"],
|
|
221
|
+
["748", "SWZ", "SZ", "ESWATINI"],
|
|
222
|
+
["752", "SWE", "SE", "SWEDEN"],
|
|
223
|
+
["756", "CHE", "CH", "SWITZERLAND"],
|
|
224
|
+
["760", "SYR", "SY", "SYRIA"],
|
|
225
|
+
["762", "TJK", "TJ", "TAJIKISTAN"],
|
|
226
|
+
["764", "THA", "TH", "THAILAND"],
|
|
227
|
+
["768", "TGO", "TG", "TOGO"],
|
|
228
|
+
["772", "TKL", "TK", "TOKELAU"],
|
|
229
|
+
["776", "TON", "TO", "TONGA"],
|
|
230
|
+
["780", "TTO", "TT", "TRINIDAD AND TOBAGO"],
|
|
231
|
+
["784", "ARE", "AE", "UNITED ARAB EMIRATES"],
|
|
232
|
+
["788", "TUN", "TN", "TUNISIA"],
|
|
233
|
+
["792", "TUR", "TR", "TURKEY"],
|
|
234
|
+
["795", "TKM", "TM", "TURKMENISTAN"],
|
|
235
|
+
["796", "TCA", "TC", "TURKS AND CAICOS ISLANDS"],
|
|
236
|
+
["798", "TUV", "TV", "TUVALU"],
|
|
237
|
+
["800", "UGA", "UG", "UGANDA"],
|
|
238
|
+
["804", "UKR", "UA", "UKRAINE"],
|
|
239
|
+
["807", "MKD", "MK", "NORTH MACEDONIA"],
|
|
240
|
+
["818", "EGY", "EG", "EGYPT"],
|
|
241
|
+
["826", "GBR", "GB", "UNITED KINGDOM"],
|
|
242
|
+
["831", "GGY", "GG", "GUERNSEY"],
|
|
243
|
+
["832", "JEY", "JE", "JERSEY"],
|
|
244
|
+
["833", "IMN", "IM", "ISLE OF MAN"],
|
|
245
|
+
["834", "TZA", "TZ", "TANZANIA"],
|
|
246
|
+
["840", "USA", "US", "UNITED STATES"],
|
|
247
|
+
["850", "VIR", "VI", "VIRGIN ISLANDS, U.S."],
|
|
248
|
+
["854", "BFA", "BF", "BURKINA FASO"],
|
|
249
|
+
["858", "URY", "UY", "URUGUAY"],
|
|
250
|
+
["860", "UZB", "UZ", "UZBEKISTAN"],
|
|
251
|
+
["862", "VEN", "VE", "VENEZUELA"],
|
|
252
|
+
["876", "WLF", "WF", "WALLIS AND FUTUNA"],
|
|
253
|
+
["882", "WSM", "WS", "SAMOA"],
|
|
254
|
+
["887", "YEM", "YE", "YEMEN"],
|
|
255
|
+
["894", "ZMB", "ZM", "ZAMBIA"],
|
|
256
|
+
["900", "XQZ", "QZ", "AKROTIRI"],
|
|
257
|
+
["901", "XKS", "XK", "KOSOVO"],
|
|
258
|
+
["902", "XAC", "XA", "ASHMORE AND CARTIER ISLANDS"],
|
|
259
|
+
["903", "XBK", "XB", "BAKER ISLAND"],
|
|
260
|
+
["904", "XBI", "QS", "BASSAS DA INDIA"],
|
|
261
|
+
["905", "CPT", "CP", "CLIPPERTON ISLAND"],
|
|
262
|
+
["906", "XCS", "XC", "CORAL SEA ISLANDS"],
|
|
263
|
+
["907", "XXD", "XD", "DHEKELIA"],
|
|
264
|
+
["908", "DGA", "DG", "DIEGO GARCIA"],
|
|
265
|
+
["909", "XAZ", "", "ENTITY 1"],
|
|
266
|
+
["910", "XCR", "", "ENTITY 2"],
|
|
267
|
+
["911", "XCY", "", "ENTITY 3"],
|
|
268
|
+
["912", "XKM", "", "ENTITY 4"],
|
|
269
|
+
["913", "XKN", "", "ENTITY 5"],
|
|
270
|
+
["914", "AX3", "A3", "ENTITY 6"],
|
|
271
|
+
["915", "XEU", "XE", "EUROPA ISLAND"],
|
|
272
|
+
["916", "XGZ", "XG", "GAZA STRIP"],
|
|
273
|
+
["917", "XGL", "QX", "GLORIOSO ISLANDS"],
|
|
274
|
+
["918", "AX2", "A2", "GUANTANAMO BAY NAVAL BASE"],
|
|
275
|
+
["919", "XHO", "XH", "HOWLAND ISLAND"],
|
|
276
|
+
["920", "XJM", "XJ", "JAN MAYEN"],
|
|
277
|
+
["921", "XJV", "XQ", "JARVIS ISLAND"],
|
|
278
|
+
["922", "XJA", "XU", "JOHNSTON ATOLL"],
|
|
279
|
+
["923", "XJN", "QU", "JUAN DE NOVA ISLAND"],
|
|
280
|
+
["924", "XKR", "XM", "KINGMAN REEF"],
|
|
281
|
+
["925", "XMW", "QM", "MIDWAY ISLANDS"],
|
|
282
|
+
["926", "XNV", "XV", "NAVASSA ISLAND"],
|
|
283
|
+
["927", "XPL", "XL", "PALMYRA ATOLL"],
|
|
284
|
+
["928", "XPR", "XP", "PARACEL ISLANDS"],
|
|
285
|
+
["929", "XSP", "XS", "SPRATLY ISLANDS"],
|
|
286
|
+
["930", "XSV", "XR", "SVALBARD"],
|
|
287
|
+
["931", "XTR", "XT", "TROMELIN ISLAND"],
|
|
288
|
+
["932", "AX1", "A1", "UNKNOWN"],
|
|
289
|
+
["933", "XWK", "QW", "WAKE ISLAND"],
|
|
290
|
+
["934", "XWB", "XW", "WEST BANK"],
|
|
291
|
+
];
|
|
292
|
+
let byNumeric;
|
|
293
|
+
/** The country a three-digit GENC numeric code names, or undefined for '000' and unknown codes. */
|
|
294
|
+
function gencCountry(numeric) {
|
|
295
|
+
byNumeric !== null && byNumeric !== void 0 ? byNumeric : (byNumeric = new Map(exports.GENC_COUNTRIES.map((r) => [r[0], r])));
|
|
296
|
+
const r = byNumeric.get(numeric.padStart(3, '0'));
|
|
297
|
+
return r ? { trigraph: r[1], digraph: r[2], name: r[3] } : undefined;
|
|
298
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.gencCountry = exports.GENC_COUNTRIES = exports.GRAPHIC_ORDERS_OF_BATTLE = exports.ORDERS_OF_BATTLE = exports.LETTER_STATUSES = exports.BATTLE_DIMENSIONS = exports.LETTER_IDENTITIES = exports.CODING_SCHEMES = exports.parseLetterSidc = exports.formatNumericSidc = exports.parseNumericSidc = void 0;
|
|
18
|
+
exports.parseSidc = parseSidc;
|
|
19
|
+
/**
|
|
20
|
+
* @zaes/sidc — symbol identification codes of MIL-STD-2525C, 2525D and 2525E (and APP-6 D/E):
|
|
21
|
+
* read, validate and write them. No dependencies, no DOM, no drawing.
|
|
22
|
+
*
|
|
23
|
+
* @module @zaes/sidc
|
|
24
|
+
*/
|
|
25
|
+
const letter_js_1 = require("./letter.js");
|
|
26
|
+
const numeric_js_1 = require("./numeric.js");
|
|
27
|
+
__exportStar(require("./tables.js"), exports);
|
|
28
|
+
var numeric_js_2 = require("./numeric.js");
|
|
29
|
+
Object.defineProperty(exports, "parseNumericSidc", { enumerable: true, get: function () { return numeric_js_2.parseNumericSidc; } });
|
|
30
|
+
Object.defineProperty(exports, "formatNumericSidc", { enumerable: true, get: function () { return numeric_js_2.formatNumericSidc; } });
|
|
31
|
+
var letter_js_2 = require("./letter.js");
|
|
32
|
+
Object.defineProperty(exports, "parseLetterSidc", { enumerable: true, get: function () { return letter_js_2.parseLetterSidc; } });
|
|
33
|
+
Object.defineProperty(exports, "CODING_SCHEMES", { enumerable: true, get: function () { return letter_js_2.CODING_SCHEMES; } });
|
|
34
|
+
Object.defineProperty(exports, "LETTER_IDENTITIES", { enumerable: true, get: function () { return letter_js_2.LETTER_IDENTITIES; } });
|
|
35
|
+
Object.defineProperty(exports, "BATTLE_DIMENSIONS", { enumerable: true, get: function () { return letter_js_2.BATTLE_DIMENSIONS; } });
|
|
36
|
+
Object.defineProperty(exports, "LETTER_STATUSES", { enumerable: true, get: function () { return letter_js_2.LETTER_STATUSES; } });
|
|
37
|
+
Object.defineProperty(exports, "ORDERS_OF_BATTLE", { enumerable: true, get: function () { return letter_js_2.ORDERS_OF_BATTLE; } });
|
|
38
|
+
Object.defineProperty(exports, "GRAPHIC_ORDERS_OF_BATTLE", { enumerable: true, get: function () { return letter_js_2.GRAPHIC_ORDERS_OF_BATTLE; } });
|
|
39
|
+
/** Reads any SIDC: starting with a letter is 2525C (15 characters); 20 or 30 digits is numeric. */
|
|
40
|
+
function parseSidc(input) {
|
|
41
|
+
const code = input.trim();
|
|
42
|
+
// A numeric code starts with a digit; a letter code with its coding scheme's letter.
|
|
43
|
+
if (/^[A-Za-z]/.test(code))
|
|
44
|
+
return (0, letter_js_1.parseLetterSidc)(code);
|
|
45
|
+
return (0, numeric_js_1.parseNumericSidc)(code);
|
|
46
|
+
}
|
|
47
|
+
var genc_js_1 = require("./genc.js");
|
|
48
|
+
Object.defineProperty(exports, "GENC_COUNTRIES", { enumerable: true, get: function () { return genc_js_1.GENC_COUNTRIES; } });
|
|
49
|
+
Object.defineProperty(exports, "gencCountry", { enumerable: true, get: function () { return genc_js_1.gencCountry; } });
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GRAPHIC_ORDERS_OF_BATTLE = exports.ORDERS_OF_BATTLE = exports.LETTER_STATUSES = exports.BATTLE_DIMENSIONS = exports.LETTER_IDENTITIES = exports.CODING_SCHEMES = void 0;
|
|
4
|
+
exports.parseLetterSidc = parseLetterSidc;
|
|
5
|
+
/** 2525C Table A-I, position 1, with the appendix each scheme is defined in. */
|
|
6
|
+
exports.CODING_SCHEMES = [
|
|
7
|
+
{ value: 'S', name: 'Warfighting', appendix: 'A' },
|
|
8
|
+
{ value: 'G', name: 'Tactical Graphics', appendix: 'B' },
|
|
9
|
+
{ value: 'W', name: 'Meteorological and Oceanographic', appendix: 'C' },
|
|
10
|
+
{ value: 'I', name: 'Signals Intelligence', appendix: 'D' },
|
|
11
|
+
{ value: 'O', name: 'Stability Operations', appendix: 'E' },
|
|
12
|
+
{ value: 'E', name: 'Emergency Management', appendix: 'G' },
|
|
13
|
+
];
|
|
14
|
+
/** 2525C Table A-I, position 2, with whether it is the exercise form and its frame family. */
|
|
15
|
+
exports.LETTER_IDENTITIES = [
|
|
16
|
+
{ value: 'P', name: 'Pending', exercise: false, group: 'Unknown' },
|
|
17
|
+
{ value: 'U', name: 'Unknown', exercise: false, group: 'Unknown' },
|
|
18
|
+
{ value: 'A', name: 'Assumed Friend', exercise: false, group: 'Friend' },
|
|
19
|
+
{ value: 'F', name: 'Friend', exercise: false, group: 'Friend' },
|
|
20
|
+
{ value: 'N', name: 'Neutral', exercise: false, group: 'Neutral' },
|
|
21
|
+
{ value: 'S', name: 'Suspect', exercise: false, group: 'Hostile' },
|
|
22
|
+
{ value: 'H', name: 'Hostile', exercise: false, group: 'Hostile' },
|
|
23
|
+
{ value: 'G', name: 'Exercise Pending', exercise: true, group: 'Unknown' },
|
|
24
|
+
{ value: 'W', name: 'Exercise Unknown', exercise: true, group: 'Unknown' },
|
|
25
|
+
{ value: 'M', name: 'Exercise Assumed Friend', exercise: true, group: 'Friend' },
|
|
26
|
+
{ value: 'D', name: 'Exercise Friend', exercise: true, group: 'Friend' },
|
|
27
|
+
{ value: 'L', name: 'Exercise Neutral', exercise: true, group: 'Neutral' },
|
|
28
|
+
{ value: 'J', name: 'Joker', exercise: true, group: 'Hostile' },
|
|
29
|
+
{ value: 'K', name: 'Faker', exercise: true, group: 'Hostile' },
|
|
30
|
+
];
|
|
31
|
+
/** 2525C Table A-I, position 3, for the warfighting scheme. */
|
|
32
|
+
exports.BATTLE_DIMENSIONS = [
|
|
33
|
+
{ value: 'P', name: 'Space' },
|
|
34
|
+
{ value: 'A', name: 'Air' },
|
|
35
|
+
{ value: 'G', name: 'Ground' },
|
|
36
|
+
{ value: 'S', name: 'Sea Surface' },
|
|
37
|
+
{ value: 'U', name: 'Sea Subsurface' },
|
|
38
|
+
{ value: 'F', name: 'SOF' },
|
|
39
|
+
{ value: 'X', name: 'Other (no frame)' },
|
|
40
|
+
{ value: 'Z', name: 'Unknown' },
|
|
41
|
+
];
|
|
42
|
+
/** 2525C Table A-I, position 4. */
|
|
43
|
+
exports.LETTER_STATUSES = [
|
|
44
|
+
{ value: 'A', name: 'Anticipated/Planned' },
|
|
45
|
+
{ value: 'P', name: 'Present' },
|
|
46
|
+
{ value: 'C', name: 'Present/Fully capable' },
|
|
47
|
+
{ value: 'D', name: 'Present/Damaged' },
|
|
48
|
+
{ value: 'X', name: 'Present/Destroyed' },
|
|
49
|
+
{ value: 'F', name: 'Present/Full to capacity' },
|
|
50
|
+
];
|
|
51
|
+
/** 2525C Table A-I, position 15. */
|
|
52
|
+
exports.ORDERS_OF_BATTLE = [
|
|
53
|
+
{ value: 'A', name: 'Air OB' },
|
|
54
|
+
{ value: 'E', name: 'Electronic OB' },
|
|
55
|
+
{ value: 'C', name: 'Civilian OB' },
|
|
56
|
+
{ value: 'G', name: 'Ground OB' },
|
|
57
|
+
{ value: 'N', name: 'Maritime OB' },
|
|
58
|
+
{ value: 'S', name: 'Strategic Force Related' },
|
|
59
|
+
];
|
|
60
|
+
/** 2525C Table B-I, position 15 of a tactical graphic (coding scheme G). */
|
|
61
|
+
exports.GRAPHIC_ORDERS_OF_BATTLE = [{ value: 'X', name: 'Control Markings' }];
|
|
62
|
+
const LETTERS = /^[A-Z0-9*-]{15}$/;
|
|
63
|
+
const unused = (c) => c === '-' || c === '*';
|
|
64
|
+
/**
|
|
65
|
+
* Reads a 2525C letter SIDC. Values the tables don't define are listed in `problems`. A code given
|
|
66
|
+
* without its trailing unused positions (`SFGPUCI` for `SFGPUCI--------`, as some systems store
|
|
67
|
+
* them) is read with dashes filling them, and `problems` says so; at least scheme, identity, dimension
|
|
68
|
+
* and status (4 characters) are needed.
|
|
69
|
+
*/
|
|
70
|
+
function parseLetterSidc(input) {
|
|
71
|
+
var _a;
|
|
72
|
+
let code = input.trim().toUpperCase();
|
|
73
|
+
const problems = [];
|
|
74
|
+
if (code.length >= 4 && code.length < 15 && /^[A-Z0-9*-]+$/.test(code)) {
|
|
75
|
+
problems.push({ position: code.length + 1, message: `${code.length} characters: positions ${code.length + 1}-15 read as unused (-)` });
|
|
76
|
+
code = code.padEnd(15, '-');
|
|
77
|
+
}
|
|
78
|
+
if (!LETTERS.test(code)) {
|
|
79
|
+
const why = code.length === 15 ? 'has 15 characters of A-Z, 0-9, - and *' : `has 15 characters, not ${code.length}`;
|
|
80
|
+
return { ok: false, problems: [{ position: 1, message: `a 2525C SIDC ${why}` }] };
|
|
81
|
+
}
|
|
82
|
+
const check = (position, value, table, what) => {
|
|
83
|
+
if (!unused(value) && !table.some((e) => e.value === value))
|
|
84
|
+
problems.push({ position, message: `${what} ${value} is not defined` });
|
|
85
|
+
};
|
|
86
|
+
const scheme = code[0];
|
|
87
|
+
check(1, scheme, exports.CODING_SCHEMES, 'coding scheme');
|
|
88
|
+
const metoc = scheme === 'W';
|
|
89
|
+
const identity = metoc ? undefined : exports.LETTER_IDENTITIES.find((e) => e.value === code[1]);
|
|
90
|
+
if (!metoc) {
|
|
91
|
+
check(2, code[1], exports.LETTER_IDENTITIES, 'standard identity');
|
|
92
|
+
if (scheme === 'S')
|
|
93
|
+
check(3, code[2], exports.BATTLE_DIMENSIONS, 'battle dimension');
|
|
94
|
+
check(4, code[3], exports.LETTER_STATUSES, 'status');
|
|
95
|
+
check(15, code[14], scheme === 'G' ? exports.GRAPHIC_ORDERS_OF_BATTLE : exports.ORDERS_OF_BATTLE, 'order of battle');
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
ok: true,
|
|
99
|
+
problems,
|
|
100
|
+
sidc: {
|
|
101
|
+
kind: 'letter',
|
|
102
|
+
standard: '2525C',
|
|
103
|
+
code,
|
|
104
|
+
scheme,
|
|
105
|
+
standardIdentity: code[1],
|
|
106
|
+
standardIdentityGroup: identity === null || identity === void 0 ? void 0 : identity.group,
|
|
107
|
+
exercise: (_a = identity === null || identity === void 0 ? void 0 : identity.exercise) !== null && _a !== void 0 ? _a : false,
|
|
108
|
+
dimension: code[2],
|
|
109
|
+
status: code[3],
|
|
110
|
+
functionId: code.slice(4, 10),
|
|
111
|
+
modifier: code.slice(10, 12),
|
|
112
|
+
country: code.slice(12, 14),
|
|
113
|
+
orderOfBattle: code[14],
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|