@packet-net/pdn-aprs 0.0.1
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 +13 -0
- package/LICENSE +661 -0
- package/README.md +192 -0
- package/THIRD-PARTY-NOTICES.md +5 -0
- package/dist/builder.d.ts +232 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +508 -0
- package/dist/builder.js.map +1 -0
- package/dist/bytes.d.ts +19 -0
- package/dist/bytes.d.ts.map +1 -0
- package/dist/bytes.js +120 -0
- package/dist/bytes.js.map +1 -0
- package/dist/codes.d.ts +13 -0
- package/dist/codes.d.ts.map +1 -0
- package/dist/codes.js +112 -0
- package/dist/codes.js.map +1 -0
- package/dist/decode/context.d.ts +33 -0
- package/dist/decode/context.d.ts.map +1 -0
- package/dist/decode/context.js +65 -0
- package/dist/decode/context.js.map +1 -0
- package/dist/decode/index.d.ts +10 -0
- package/dist/decode/index.d.ts.map +1 -0
- package/dist/decode/index.js +121 -0
- package/dist/decode/index.js.map +1 -0
- package/dist/decode/message.d.ts +5 -0
- package/dist/decode/message.d.ts.map +1 -0
- package/dist/decode/message.js +190 -0
- package/dist/decode/message.js.map +1 -0
- package/dist/decode/other.d.ts +25 -0
- package/dist/decode/other.d.ts.map +1 -0
- package/dist/decode/other.js +326 -0
- package/dist/decode/other.js.map +1 -0
- package/dist/decode/positioned.d.ts +132 -0
- package/dist/decode/positioned.d.ts.map +1 -0
- package/dist/decode/positioned.js +1063 -0
- package/dist/decode/positioned.js.map +1 -0
- package/dist/decode/reports.d.ts +13 -0
- package/dist/decode/reports.d.ts.map +1 -0
- package/dist/decode/reports.js +375 -0
- package/dist/decode/reports.js.map +1 -0
- package/dist/decoder.d.ts +23 -0
- package/dist/decoder.d.ts.map +1 -0
- package/dist/decoder.js +75 -0
- package/dist/decoder.js.map +1 -0
- package/dist/deviceid-data.d.ts +33 -0
- package/dist/deviceid-data.d.ts.map +1 -0
- package/dist/deviceid-data.js +2941 -0
- package/dist/deviceid-data.js.map +1 -0
- package/dist/deviceid.d.ts +12 -0
- package/dist/deviceid.d.ts.map +1 -0
- package/dist/deviceid.js +86 -0
- package/dist/deviceid.js.map +1 -0
- package/dist/diagnostics.d.ts +48 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +65 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/encode/common.d.ts +19 -0
- package/dist/encode/common.d.ts.map +1 -0
- package/dist/encode/common.js +84 -0
- package/dist/encode/common.js.map +1 -0
- package/dist/encode/index.d.ts +35 -0
- package/dist/encode/index.d.ts.map +1 -0
- package/dist/encode/index.js +248 -0
- package/dist/encode/index.js.map +1 -0
- package/dist/encode/other.d.ts +21 -0
- package/dist/encode/other.d.ts.map +1 -0
- package/dist/encode/other.js +253 -0
- package/dist/encode/other.js.map +1 -0
- package/dist/encode/position.d.ts +31 -0
- package/dist/encode/position.d.ts.map +1 -0
- package/dist/encode/position.js +729 -0
- package/dist/encode/position.js.map +1 -0
- package/dist/header.d.ts +42 -0
- package/dist/header.d.ts.map +1 -0
- package/dist/header.js +206 -0
- package/dist/header.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/neutral.d.ts +22 -0
- package/dist/neutral.d.ts.map +1 -0
- package/dist/neutral.js +593 -0
- package/dist/neutral.js.map +1 -0
- package/dist/symbols-data.d.ts +832 -0
- package/dist/symbols-data.d.ts.map +1 -0
- package/dist/symbols-data.js +173 -0
- package/dist/symbols-data.js.map +1 -0
- package/dist/symbols.d.ts +35 -0
- package/dist/symbols.d.ts.map +1 -0
- package/dist/symbols.js +71 -0
- package/dist/symbols.js.map +1 -0
- package/dist/types.d.ts +458 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/package.json +68 -0
- package/src/builder.ts +617 -0
- package/src/bytes.ts +118 -0
- package/src/codes.ts +218 -0
- package/src/decode/context.ts +63 -0
- package/src/decode/index.ts +135 -0
- package/src/decode/message.ts +194 -0
- package/src/decode/other.ts +307 -0
- package/src/decode/positioned.ts +1161 -0
- package/src/decode/reports.ts +378 -0
- package/src/decoder.ts +76 -0
- package/src/deviceid-data.ts +2954 -0
- package/src/deviceid.ts +83 -0
- package/src/diagnostics.ts +86 -0
- package/src/encode/common.ts +87 -0
- package/src/encode/index.ts +280 -0
- package/src/encode/other.ts +247 -0
- package/src/encode/position.ts +656 -0
- package/src/header.ts +221 -0
- package/src/index.ts +57 -0
- package/src/neutral.ts +595 -0
- package/src/symbols-data.ts +181 -0
- package/src/symbols.ts +85 -0
- package/src/types.ts +571 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// Generated by scripts/generate-symbols.mjs; do not edit by hand. Every symbol the APRS symbol
|
|
2
|
+
// tables define (APRS12c ch. 21, APRS-Symbols), named as packet.net's AprsSymbol.Named.cs names
|
|
3
|
+
// them, with the description from the table.
|
|
4
|
+
|
|
5
|
+
/** A named symbol: its table, code and description. */
|
|
6
|
+
export interface NamedSymbolEntry {
|
|
7
|
+
readonly table: string;
|
|
8
|
+
readonly code: string;
|
|
9
|
+
readonly description: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Every named symbol. */
|
|
13
|
+
export const NAMED_SYMBOLS = {
|
|
14
|
+
policeSheriff: { table: "/", code: "!", description: "Police, Sheriff" },
|
|
15
|
+
digipeater: { table: "/", code: "#", description: "Digi (green star with white center)" },
|
|
16
|
+
phone: { table: "/", code: "$", description: "Phone" },
|
|
17
|
+
dxCluster: { table: "/", code: "%", description: "DX Cluster" },
|
|
18
|
+
hfGateway: { table: "/", code: "&", description: "HF Gateway" },
|
|
19
|
+
smallAircraft: { table: "/", code: "'", description: "Small Aircraft" },
|
|
20
|
+
mobileSatelliteGroundStation: { table: "/", code: "(", description: "Mobile Satellite Ground Station" },
|
|
21
|
+
wheelchair: { table: "/", code: ")", description: "Wheelchair (handicapped)" },
|
|
22
|
+
snowmobile: { table: "/", code: "*", description: "Snowmobile" },
|
|
23
|
+
redCross: { table: "/", code: "+", description: "Red Cross" },
|
|
24
|
+
boyScouts: { table: "/", code: ",", description: "Boy Scouts" },
|
|
25
|
+
house: { table: "/", code: "-", description: "House QTH (VHF)" },
|
|
26
|
+
xMark: { table: "/", code: ".", description: "X" },
|
|
27
|
+
redDot: { table: "/", code: "/", description: "Red Dot" },
|
|
28
|
+
circle0: { table: "/", code: "0", description: "0 Circle" },
|
|
29
|
+
circle1: { table: "/", code: "1", description: "1 Circle" },
|
|
30
|
+
circle2: { table: "/", code: "2", description: "2 Circle" },
|
|
31
|
+
circle3: { table: "/", code: "3", description: "3 Circle" },
|
|
32
|
+
circle4: { table: "/", code: "4", description: "4 Circle" },
|
|
33
|
+
circle5: { table: "/", code: "5", description: "5 Circle" },
|
|
34
|
+
circle6: { table: "/", code: "6", description: "6 Circle" },
|
|
35
|
+
circle7: { table: "/", code: "7", description: "7 Circle" },
|
|
36
|
+
circle8: { table: "/", code: "8", description: "8 Circle" },
|
|
37
|
+
circle9: { table: "/", code: "9", description: "9 Circle" },
|
|
38
|
+
fire: { table: "/", code: ":", description: "Fire" },
|
|
39
|
+
campground: { table: "/", code: ";", description: "Campground (Portable ops)" },
|
|
40
|
+
motorcycle: { table: "/", code: "<", description: "Motorcycle" },
|
|
41
|
+
railroadEngine: { table: "/", code: "=", description: "Railroad Engine" },
|
|
42
|
+
car: { table: "/", code: ">", description: "Car" },
|
|
43
|
+
fileServer: { table: "/", code: "?", description: "File Server" },
|
|
44
|
+
hurricaneFuturePrediction: { table: "/", code: "@", description: "Hurricane Future Prediction" },
|
|
45
|
+
aidStation: { table: "/", code: "A", description: "Aid Station" },
|
|
46
|
+
bbs: { table: "/", code: "B", description: "BBS or PBBS" },
|
|
47
|
+
canoe: { table: "/", code: "C", description: "Canoe" },
|
|
48
|
+
eyeball: { table: "/", code: "E", description: "Eyeball (events, etc.)" },
|
|
49
|
+
farmVehicle: { table: "/", code: "F", description: "Farm Vehicle (Tractor)" },
|
|
50
|
+
gridSquare: { table: "/", code: "G", description: "Grid Square (6-character)" },
|
|
51
|
+
hotel: { table: "/", code: "H", description: "Hotel (blue bed icon)" },
|
|
52
|
+
tcpIpNetworkStation: { table: "/", code: "I", description: "TCP/IP on air network station" },
|
|
53
|
+
school: { table: "/", code: "K", description: "School" },
|
|
54
|
+
pcUser: { table: "/", code: "L", description: "PC user" },
|
|
55
|
+
macAprs: { table: "/", code: "M", description: "MacAPRS" },
|
|
56
|
+
ntsStation: { table: "/", code: "N", description: "NTS Station" },
|
|
57
|
+
balloon: { table: "/", code: "O", description: "Balloon" },
|
|
58
|
+
police: { table: "/", code: "P", description: "Police" },
|
|
59
|
+
recreationalVehicle: { table: "/", code: "R", description: "Recreational Vehicle" },
|
|
60
|
+
spaceShuttle: { table: "/", code: "S", description: "Space Shuttle" },
|
|
61
|
+
sstv: { table: "/", code: "T", description: "SSTV" },
|
|
62
|
+
bus: { table: "/", code: "U", description: "Bus" },
|
|
63
|
+
amateurTv: { table: "/", code: "V", description: "Amateur TV" },
|
|
64
|
+
nationalWeatherServiceSite: { table: "/", code: "W", description: "National Weather Service Site" },
|
|
65
|
+
helicopter: { table: "/", code: "X", description: "Helicopter" },
|
|
66
|
+
yacht: { table: "/", code: "Y", description: "Yacht (sail boat)" },
|
|
67
|
+
winAprs: { table: "/", code: "Z", description: "WinAPRS" },
|
|
68
|
+
jogger: { table: "/", code: "[", description: "Jogger, Human/person" },
|
|
69
|
+
directionFinding: { table: "/", code: "\\", description: "Triangle (DF)" },
|
|
70
|
+
postOffice: { table: "/", code: "]", description: "Mail/Post Office" },
|
|
71
|
+
largeAircraft: { table: "/", code: "^", description: "Large Aircraft" },
|
|
72
|
+
weatherStation: { table: "/", code: "_", description: "Weather Station (blue)" },
|
|
73
|
+
dishAntenna: { table: "/", code: "`", description: "Dish Antenna" },
|
|
74
|
+
ambulance: { table: "/", code: "a", description: "Ambulance" },
|
|
75
|
+
bicycle: { table: "/", code: "b", description: "Bicycle" },
|
|
76
|
+
incidentCommandPost: { table: "/", code: "c", description: "Incident Command Post" },
|
|
77
|
+
fireDepartment: { table: "/", code: "d", description: "Fire Department" },
|
|
78
|
+
horse: { table: "/", code: "e", description: "Horse (equestrian)" },
|
|
79
|
+
fireTruck: { table: "/", code: "f", description: "Fire Truck" },
|
|
80
|
+
glider: { table: "/", code: "g", description: "Glider" },
|
|
81
|
+
hospital: { table: "/", code: "h", description: "Hospital" },
|
|
82
|
+
iota: { table: "/", code: "i", description: "IOTA (Islands on the Air)" },
|
|
83
|
+
jeep: { table: "/", code: "j", description: "Jeep" },
|
|
84
|
+
truck: { table: "/", code: "k", description: "Truck" },
|
|
85
|
+
laptop: { table: "/", code: "l", description: "Laptop" },
|
|
86
|
+
micERepeater: { table: "/", code: "m", description: "Mic-E Repeater" },
|
|
87
|
+
node: { table: "/", code: "n", description: "Node (black bulls-eye)" },
|
|
88
|
+
emergencyOperationsCenter: { table: "/", code: "o", description: "Emergency Operations Center" },
|
|
89
|
+
rover: { table: "/", code: "p", description: "Rover (puppy dog)" },
|
|
90
|
+
gridSquareAbove128m: { table: "/", code: "q", description: "Grid Square shown above 128m" },
|
|
91
|
+
repeater: { table: "/", code: "r", description: "Repeater" },
|
|
92
|
+
ship: { table: "/", code: "s", description: "Ship (power boat)" },
|
|
93
|
+
truckStop: { table: "/", code: "t", description: "Truck Stop" },
|
|
94
|
+
eighteenWheeler: { table: "/", code: "u", description: "Truck (18-wheeler)" },
|
|
95
|
+
van: { table: "/", code: "v", description: "Van" },
|
|
96
|
+
waterStation: { table: "/", code: "w", description: "Water Station" },
|
|
97
|
+
xAprs: { table: "/", code: "x", description: "X-APRS (Unix)" },
|
|
98
|
+
yagiAtQth: { table: "/", code: "y", description: "Yagi at QTH" },
|
|
99
|
+
emergency: { table: "\\", code: "!", description: "Emergency" },
|
|
100
|
+
overlayDigipeater: { table: "\\", code: "#", description: "Digi (green star)" },
|
|
101
|
+
bank: { table: "\\", code: "$", description: "Bank or ATM (green box)" },
|
|
102
|
+
powerPlant: { table: "\\", code: "%", description: "Power Plant" },
|
|
103
|
+
gateway: { table: "\\", code: "&", description: "I=IGate R=RX T=1hopTX 2=2hopTX" },
|
|
104
|
+
crash: { table: "\\", code: "'", description: "Crash (& incident sites)" },
|
|
105
|
+
cloudy: { table: "\\", code: "(", description: "Cloudy" },
|
|
106
|
+
firenet: { table: "\\", code: ")", description: "Firenet MEO, MODIS Earth Obs." },
|
|
107
|
+
snow: { table: "\\", code: "*", description: "Snow" },
|
|
108
|
+
church: { table: "\\", code: "+", description: "Church" },
|
|
109
|
+
girlScouts: { table: "\\", code: ",", description: "Girl Scouts" },
|
|
110
|
+
overlayHouse: { table: "\\", code: "-", description: "House (H=HF) (O = Op Present)" },
|
|
111
|
+
ambiguous: { table: "\\", code: ".", description: "Ambiguous (Big Question Mark)" },
|
|
112
|
+
waypoint: { table: "\\", code: "/", description: "Waypoint Destination (Note 1)" },
|
|
113
|
+
overlayCircle: { table: "\\", code: "0", description: "Circle (E/I/W= IRLP/EchoLink/WIRES)" },
|
|
114
|
+
networkNode: { table: "\\", code: "8", description: "802.11 or other network node" },
|
|
115
|
+
gasStation: { table: "\\", code: "9", description: "Gas Station (blue pump)" },
|
|
116
|
+
hail: { table: "\\", code: ":", description: "Hail" },
|
|
117
|
+
park: { table: "\\", code: ";", description: "Park/Picnic Area" },
|
|
118
|
+
advisory: { table: "\\", code: "<", description: "Advisory (one WX flag)" },
|
|
119
|
+
aprstt: { table: "\\", code: "=", description: "APRStt Touchtone (DTMF Users)" },
|
|
120
|
+
overlayVehicle: { table: "\\", code: ">", description: "Cars & Vehicles" },
|
|
121
|
+
informationKiosk: { table: "\\", code: "?", description: "Information Kiosk (blue box with ?)" },
|
|
122
|
+
hurricaneTropicalStorm: { table: "\\", code: "@", description: "Hurricane/Tropical Storm" },
|
|
123
|
+
overlayBox: { table: "\\", code: "A", description: "Box: DTMF, RFID, XO" },
|
|
124
|
+
blowingSnow: { table: "\\", code: "B", description: "Blowing Snow" },
|
|
125
|
+
coastGuard: { table: "\\", code: "C", description: "Coast Guard" },
|
|
126
|
+
drizzle: { table: "\\", code: "D", description: "Drizzle" },
|
|
127
|
+
smoke: { table: "\\", code: "E", description: "Smoke (& other vis codes)" },
|
|
128
|
+
freezingRain: { table: "\\", code: "F", description: "Freezing Rain" },
|
|
129
|
+
snowShower: { table: "\\", code: "G", description: "Snow Shower" },
|
|
130
|
+
haze: { table: "\\", code: "H", description: "Haze" },
|
|
131
|
+
rainShower: { table: "\\", code: "I", description: "Rain Shower" },
|
|
132
|
+
lightning: { table: "\\", code: "J", description: "Lightning" },
|
|
133
|
+
kenwoodHt: { table: "\\", code: "K", description: "Kenwood HT (w)" },
|
|
134
|
+
lighthouse: { table: "\\", code: "L", description: "Lighthouse" },
|
|
135
|
+
mars: { table: "\\", code: "M", description: "MARS (A=Army, N=Navy, F=AF)" },
|
|
136
|
+
navigationBuoy: { table: "\\", code: "N", description: "Navigation Buoy" },
|
|
137
|
+
rocket: { table: "\\", code: "O", description: "Rocket" },
|
|
138
|
+
parking: { table: "\\", code: "P", description: "Parking" },
|
|
139
|
+
earthquake: { table: "\\", code: "Q", description: "Earthquake" },
|
|
140
|
+
restaurant: { table: "\\", code: "R", description: "Restaurant" },
|
|
141
|
+
satellite: { table: "\\", code: "S", description: "Satellite" },
|
|
142
|
+
thunderstorm: { table: "\\", code: "T", description: "Thunderstorm" },
|
|
143
|
+
sunny: { table: "\\", code: "U", description: "Sunny" },
|
|
144
|
+
vortac: { table: "\\", code: "V", description: "VORTAC Nav Aid" },
|
|
145
|
+
overlayNwsSite: { table: "\\", code: "W", description: "NWS Site" },
|
|
146
|
+
pharmacy: { table: "\\", code: "X", description: "Pharmacy Rx" },
|
|
147
|
+
overlayRadio: { table: "\\", code: "Y", description: "Radios and devices" },
|
|
148
|
+
wallCloud: { table: "\\", code: "[", description: "Wall Cloud" },
|
|
149
|
+
aircraftWithHeading: { table: "\\", code: "^", description: "Aircraft (Shows Heading)" },
|
|
150
|
+
weatherStationWithDigipeater: { table: "\\", code: "_", description: "WX Station with Digi (green)" },
|
|
151
|
+
rain: { table: "\\", code: "`", description: "Rain" },
|
|
152
|
+
overlayDiamond: { table: "\\", code: "a", description: "ARRL, ARES, WinLINK, Dstar, LoRa, etc" },
|
|
153
|
+
blowingDust: { table: "\\", code: "b", description: "Blowing Dust/Sand" },
|
|
154
|
+
overlayCivilDefense: { table: "\\", code: "c", description: "CD triangle RACES/SATERN/etc" },
|
|
155
|
+
dxSpot: { table: "\\", code: "d", description: "DX Spot (from callsign prefix)" },
|
|
156
|
+
sleet: { table: "\\", code: "e", description: "Sleet" },
|
|
157
|
+
funnelCloud: { table: "\\", code: "f", description: "Funnel Cloud" },
|
|
158
|
+
galeFlags: { table: "\\", code: "g", description: "Gale Flags" },
|
|
159
|
+
store: { table: "\\", code: "h", description: "Store or Hamfest" },
|
|
160
|
+
pointOfInterest: { table: "\\", code: "i", description: "BOX or points of Interest" },
|
|
161
|
+
workZone: { table: "\\", code: "j", description: "Work Zone (steam shovel)" },
|
|
162
|
+
specialVehicle: { table: "\\", code: "k", description: "Special Vehicle SUV, ATV, 4x4" },
|
|
163
|
+
area: { table: "\\", code: "l", description: "Area Symbols (box, circle, etc)" },
|
|
164
|
+
valueSign: { table: "\\", code: "m", description: "Value Sign (3 digit display)" },
|
|
165
|
+
triangle: { table: "\\", code: "n", description: "Triangle" },
|
|
166
|
+
smallCircle: { table: "\\", code: "o", description: "Small Circle" },
|
|
167
|
+
partlyCloudy: { table: "\\", code: "p", description: "Partly Cloudy" },
|
|
168
|
+
restrooms: { table: "\\", code: "r", description: "Restrooms" },
|
|
169
|
+
overlayShip: { table: "\\", code: "s", description: "Ship/Boat (top view)" },
|
|
170
|
+
tornado: { table: "\\", code: "t", description: "Tornado" },
|
|
171
|
+
overlayTruck: { table: "\\", code: "u", description: "Truck" },
|
|
172
|
+
overlayVan: { table: "\\", code: "v", description: "Van" },
|
|
173
|
+
flooding: { table: "\\", code: "w", description: "Flooding (Avalanches/Slides)" },
|
|
174
|
+
wreck: { table: "\\", code: "x", description: "Wreck or Obstruction" },
|
|
175
|
+
skywarn: { table: "\\", code: "y", description: "Skywarn" },
|
|
176
|
+
shelter: { table: "\\", code: "z", description: "Overlayed Shelter" },
|
|
177
|
+
fog: { table: "\\", code: "{", description: "Fog" },
|
|
178
|
+
} as const satisfies Record<string, NamedSymbolEntry>;
|
|
179
|
+
|
|
180
|
+
/** Alternate-table symbol codes that take an overlay character (marked # in APRS-Symbols). */
|
|
181
|
+
export const OVERLAY_CODES = "!#$%&'(-08;<=>ADHMRWY[\\^_achiknsuvwz";
|
package/src/symbols.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Symbols by name, and overlays. `Symbols.car` is `/>`; `withOverlay(Symbols.gateway, 'I')` is an
|
|
2
|
+
// IGate (`I&`).
|
|
3
|
+
|
|
4
|
+
import { NAMED_SYMBOLS, OVERLAY_CODES } from './symbols-data.js';
|
|
5
|
+
import type { AprsSymbol } from './types.js';
|
|
6
|
+
|
|
7
|
+
/** The name of every symbol the APRS symbol tables define. */
|
|
8
|
+
export type SymbolName = keyof typeof NAMED_SYMBOLS;
|
|
9
|
+
|
|
10
|
+
function freeze(table: string, code: string): AprsSymbol {
|
|
11
|
+
return Object.freeze({ table, code });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Every symbol the APRS symbol tables define (APRS12c ch. 21), by name: `Symbols.car`,
|
|
16
|
+
* `Symbols.house`, `Symbols.weatherStation`, `Symbols.digipeater`, ...
|
|
17
|
+
*/
|
|
18
|
+
export const Symbols: { readonly [K in SymbolName]: AprsSymbol } = Object.freeze(
|
|
19
|
+
Object.fromEntries(Object.entries(NAMED_SYMBOLS).map(([name, s]) => [name, freeze(s.table, s.code)])),
|
|
20
|
+
) as { readonly [K in SymbolName]: AprsSymbol };
|
|
21
|
+
|
|
22
|
+
const byText = new Map<string, SymbolName>();
|
|
23
|
+
for (const [name, s] of Object.entries(NAMED_SYMBOLS)) byText.set(s.table + s.code, name as SymbolName);
|
|
24
|
+
|
|
25
|
+
function isOverlayChar(c: string): boolean {
|
|
26
|
+
return c.length === 1 && ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z'));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A symbol from its two characters, table then code: `symbolOf('/>')`. */
|
|
30
|
+
export function symbolOf(text: string): AprsSymbol {
|
|
31
|
+
if (text.length !== 2) throw new RangeError('a symbol is two characters: the table (or overlay), then the code');
|
|
32
|
+
return freeze(text[0]!, text[1]!);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** A symbol's two characters, table then code. */
|
|
36
|
+
export function symbolText(symbol: AprsSymbol): string {
|
|
37
|
+
return symbol.table + symbol.code;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The overlay character on a symbol, if it has one (a table of `0`-`9` or `A`-`Z`). */
|
|
41
|
+
export function overlayOf(symbol: AprsSymbol): string | undefined {
|
|
42
|
+
return isOverlayChar(symbol.table) ? symbol.table : undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A symbol without its overlay: an overlaid symbol is an alternate-table (`\`) symbol. */
|
|
46
|
+
export function withoutOverlay(symbol: AprsSymbol): AprsSymbol {
|
|
47
|
+
return isOverlayChar(symbol.table) ? freeze('\\', symbol.code) : symbol;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Whether the symbol tables mark this alternate-table symbol as taking an overlay. */
|
|
51
|
+
export function acceptsOverlay(symbol: AprsSymbol): boolean {
|
|
52
|
+
const base = withoutOverlay(symbol);
|
|
53
|
+
return base.table === '\\' && OVERLAY_CODES.includes(base.code);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* An alternate-table symbol with an overlay character (`0`-`9` or `A`-`Z`):
|
|
58
|
+
* `withOverlay(Symbols.gateway, 'I')` is `I&`. Throws for a primary-table symbol, an overlay
|
|
59
|
+
* character that is not a digit or capital letter, or a symbol the tables do not mark as taking
|
|
60
|
+
* an overlay.
|
|
61
|
+
*/
|
|
62
|
+
export function withOverlay(symbol: AprsSymbol, overlay: string): AprsSymbol {
|
|
63
|
+
if (!isOverlayChar(overlay)) throw new RangeError('an overlay is one digit or capital letter');
|
|
64
|
+
const base = withoutOverlay(symbol);
|
|
65
|
+
if (base.table !== '\\') throw new RangeError('only alternate-table (\\) symbols take an overlay');
|
|
66
|
+
if (!OVERLAY_CODES.includes(base.code)) throw new RangeError(`the symbol tables do not mark \\${base.code} as taking an overlay`);
|
|
67
|
+
return freeze(overlay, base.code);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** A symbol's name, e.g. `car`; an overlaid symbol has its alternate-table symbol's name. */
|
|
71
|
+
export function symbolName(symbol: AprsSymbol): SymbolName | undefined {
|
|
72
|
+
const base = withoutOverlay(symbol);
|
|
73
|
+
return byText.get(base.table + base.code);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** What a symbol shows, from the symbol table, e.g. `Car`. */
|
|
77
|
+
export function describeSymbol(symbol: AprsSymbol): string | undefined {
|
|
78
|
+
const name = symbolName(symbol);
|
|
79
|
+
return name === undefined ? undefined : NAMED_SYMBOLS[name].description;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Whether two symbols are the same. */
|
|
83
|
+
export function sameSymbol(a: AprsSymbol, b: AprsSymbol): boolean {
|
|
84
|
+
return a.table === b.table && a.code === b.code;
|
|
85
|
+
}
|