Skip to content

Commit 69da810

Browse files
authored
Version 1.0.7
1 parent 2bab970 commit 69da810

3 files changed

Lines changed: 40 additions & 39 deletions

File tree

README.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ if (config.testing) {
6161

6262
I would highly recommend checking out my code on [our GitHub location here](https://github.com/mwalden2004/National-Weather-Service-Open-Interface-Realtime-Parser), and helping make it better! If you have an issue, feel free to open an issue there.
6363

64-
## Most Recent Update Info: VERSION: 1.0.6
64+
## Most Recent Update Info: VERSION: 1.0.7
6565

6666
Added new information in returned events
6767
```json
68-
{ phenomena: 'Severe Thunderstorm',
69-
significance: 'Warning',
70-
action: 'New event',
71-
start: 2019-01-20T04:39:00.000Z,
72-
end: 2019-01-20T05:15:00.000Z,
73-
polygon:
68+
{ "phenomena": 'Severe Thunderstorm',
69+
"significance": 'Warning',
70+
"action": 'New event',
71+
"start": "2019-01-20T04:39:00.000Z",
72+
"end": "2019-01-20T05:15:00.000Z",
73+
"polygon":
7474
[ [ -85.44, '32.39' ],
7575
[ -85.44, '32.49' ],
7676
[ -85.45, '32.50' ],
@@ -86,33 +86,34 @@ Added new information in returned events
8686
[ -85.07, '32.58' ],
8787
[ -85.01, '32.52' ],
8888
[ -84.99, '32.49' ],
89-
[ -85, '32.46' ],
89+
[ -85, '32.46' ],
9090
[ -84.97, '32.44' ],
9191
[ -84.96, '32.42' ],
92-
[ -85.44, '32.39' ] ],
93-
PDS: false,
94-
Counties: [ 'Lee County', 'Northern Russell County' ],
95-
extras:
96-
{ HAZARD: '60 mph wind gust',
97-
SOURCE: 'Radar indicated',
98-
IMPACT: 'Expect damage to roofs, siding, and trees',
99-
ACTIONS:
100-
'For your protection move to an interior room on the lowest floor of a building.' },
101-
back_data:
102-
{ office_id: 'KBMX',
103-
productclass: 'O',
104-
event_tracking: '0001',
105-
raw_attrs:
106-
{ xmlns: 'nwws-oi',
107-
cccc: 'KJAN',
108-
ttaaii: 'WUUS54',
109-
issue: '2019-10-26T14:38:00Z',
110-
awipsid: 'SVRJAN',
111-
id: '13743.3632' },
112-
raw_msg:
92+
[ -85.44, '32.39' ]
93+
],
94+
"PDS": false,
95+
"Counties": [ 'Lee County', 'Northern Russell County' ],
96+
"extras":
97+
{ "HAZARD": '60 mph wind gust',
98+
"SOURCE": 'Radar indicated',
99+
"IMPACT": 'Expect damage to roofs, siding, and trees',
100+
"ACTIONS": 'For your protection move to an interior room on the lowest floor of a building.' },
101+
"back_data": {
102+
"office_id": 'KBMX',
103+
"productclass": 'O',
104+
"event_tracking": '0001',
105+
"raw_attrs":
106+
{ "xmlns": 'nwws-oi',
107+
"cccc": 'KJAN',
108+
"ttaaii": 'WUUS54',
109+
"issue": '2019-10-26T14:38:00Z',
110+
"awipsid": 'SVRJAN',
111+
"id": '13743.3632' },
112+
"raw_msg":
113113
'950\n WUUS54 KBMX 192239\n SVRBMX\n ALC081-113-192315-\n /O.NEW.KBMX.SV.W.0001.190119T2239Z-190119T2315Z/\n \n BULLETIN - IMMEDIATE BROADCAST REQUESTED\n Severe Thunderstorm Warning\n National Weather Service Birmingham AL\n 439 PM CST SAT JAN 19 2019\n \n The National Weather Service in Birmingham has issued a\n \n * Severe Thunderstorm Warning for...\n Lee County in east central Alabama...\n Northern Russell County in southeastern Alabama...\n \n * Until 515 PM CST.\n \n * At 439 PM CST, severe thunderstorms were located along a line\n extending from near Beans Mill to Society Hill, moving northeast at\n 45 mph.\n \n HAZARD...60 mph wind gusts.\n \n SOURCE...Radar indicated.\n \n IMPACT...Expect damage to roofs, siding, and trees.\n \n * Locations impacted include...\n Auburn, Phenix City, Opelika, Smiths, Smiths Station, Beulah, Beans\n Mill, Ladonia, Beauregard, Bleecker, Griffen Mill, Bibb City,\n Monterey Heights, Ladonia Sports Complex, Marvyn, Phenix Drag Strip\n and Mount Jefferson.\n \n PRECAUTIONARY/PREPAREDNESS ACTIONS...\n \n For your protection move to an interior room on the lowest floor of a\n building.\n \n &&\n \n A Tornado Watch remains in effect until 900 PM CST for southeastern\n and east central Alabama.\n \n LAT...LON 3239 8544 3249 8544 3250 8545 3273 8538\n 3273 8529 3275 8528 3274 8512 3269 8512\n 3266 8509 3265 8511 3263 8508 3262 8509\n 3258 8507 3252 8501 3249 8499 3246 8500\n 3244 8497 3242 8496\n TIME...MOT...LOC 2239Z 245DEG 40KT 3272 8530 3244 8543\n \n HAIL...<.75IN\n WIND...60MPH\n \n $$\n \n 89^GSatterwhite' } }
114114
```
115115
Specifically: Counties, Extras, PDS.
116+
Fixed some parsing issues too. Testing using https://mesonet.agron.iastate.edu/vtec/#2019-O-NEW-KBMX-SV-W-0001/USCOMP-N0Q-201901192235
116117

117118
Layed infunstrucutre to split parsing into seperate files. *as much as i'd love to have a 20k line file*
118119

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nwws-oi",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "Allows for realtime parsing of warnings, watches etc.",
55
"main": "index.js",
66
"dependencies": {

parse.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,28 +129,28 @@ module.exports = function (msg, attrs, cb) {
129129
if (Phenomenas[phenomena] && Significances[significance] && Actions[action]) {
130130

131131
let CountiesListed = [];//Array where counties will be stored
132-
let startCounties = msg.indexOf("* "+Phenomenas[phenomena]+" "+Significances[significance]+" for...");//Find the begging of the counties
133-
let endCounties = msg.indexOf("* Until ");//End of counties, find the next start
134-
let Counties = msg.substring(startCounties, endCounties).replace("* "+Phenomenas[phenomena]+" "+Significances[significance]+" for...", "").replace(/ /g, "").split("\n");//Substring for all counties
132+
let startCounties = msg.toLowerCase().indexOf("* "+Phenomenas[phenomena]+" "+Significances[significance]+" for...".toLowerCase());//Find the begging of the counties
133+
let endCounties = msg.toLowerCase().indexOf("* until ");//End of counties, find the next start
134+
let Counties = msg.substring(startCounties, endCounties).toLowerCase().replace("* "+Phenomenas[phenomena]+" "+Significances[significance]+" for...".toLowerCase(), "").replace(/ /g, "").split("\n");//Substring for all counties
135135
Counties.forEach(county => {//Put all counties into one string.
136-
let pushCounty = county.substring(0, county.search(" County"))+" County";//Get rid of everything but county name/part of county.
136+
let pushCounty = county.substring(0, county.toLowerCase().search(" county"))+" County";//Get rid of everything but county name/part of county.
137137
if (county !== '' && county !== ' County' && !county.match(/ /g)){//Regex for weird whitespace/tabs.
138-
CountiesListed.push(pushCounty);//Add counties to array
138+
CountiesListed.push(pushCounty.toLowerCase());//Add counties to array
139139
}
140140
});
141141

142142
let extra_info = {
143143

144144
};
145-
146-
if (msg.search("SOURCE...")){
145+
146+
if (msg.search("SOURCE...") !== -1){
147147
const startSub = msg.search("SOURCE...");//this is such a forking hack. i approve. [can someone do a good pull, really thinking about dividing warnings/watches into their own parsers.]
148148
const endSub = new Number(msg.substring(startSub, msg.length).replace("SOURCE..."," ").indexOf("."))+new Number(msg.substring(0, startSub).length)
149149
let actions = msg.substring(startSub, endSub).replace("SOURCE...", "");
150150
actions=actions.replace(/\n/g, " ").replace(/ /g, "")
151151
extra_info["SOURCE"] = actions;
152152
}
153-
if (msg.search("IMPACT...")){
153+
if (msg.search("IMPACT...") !== -1){
154154
const startSub = msg.search("IMPACT...");//this is such a forking hack. i approve. [can someone do a good pull, really thinking about dividing warnings/watches into their own parsers.]
155155
const endSub = new Number(msg.substring(startSub, msg.length).replace("IMPACT..."," ").indexOf("*"))+new Number(msg.substring(0, startSub).length)
156156
let actions = msg.substring(startSub, endSub).replace("IMPACT...", "");
@@ -159,7 +159,7 @@ module.exports = function (msg, attrs, cb) {
159159
}
160160
//SOURCE IMPACT
161161

162-
if (msg.search("PRECAUTIONARY/PREPAREDNESS ACTIONS...")){//Let's be safe?
162+
if (msg.search("PRECAUTIONARY/PREPAREDNESS ACTIONS...") !== -1){//Let's be safe?
163163
const startSub = msg.search("PRECAUTIONARY/PREPAREDNESS ACTIONS...");
164164
const endSub = msg.search("&&");
165165
let actions = msg.substring(startSub, endSub).replace("PRECAUTIONARY/PREPAREDNESS ACTIONS...", "");

0 commit comments

Comments
 (0)