Compare commits
3 commits
c12d250d3e
...
33ac8386b1
Author | SHA1 | Date | |
---|---|---|---|
|
33ac8386b1 | ||
|
d4c2585ec2 | ||
|
0dc2358a9b |
2 changed files with 25 additions and 18 deletions
|
@ -60,6 +60,11 @@ create table nexrad_afos_message (
|
||||||
forecaster TEXT NOT NULL
|
forecaster TEXT NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
create index nexrad_afos_message_timestamp_idx on nexrad_afos_message (timestamp_start, timestamp_end);
|
||||||
|
create index nexrad_afos_message_wfo_idx on nexrad_afos_message (wfo);
|
||||||
|
create index nexrad_afos_message_phenom_idx on nexrad_afos_message (phenom);
|
||||||
|
create index nexrad_afos_message_sig_idx on nexrad_afos_message (sig);
|
||||||
|
|
||||||
select
|
select
|
||||||
AddGeometryColumn('nexrad_afos_message', 'location', 4326, 'POINT'),
|
AddGeometryColumn('nexrad_afos_message', 'location', 4326, 'POINT'),
|
||||||
CreateSpatialIndex('nexrad_afos_message', 'location');
|
CreateSpatialIndex('nexrad_afos_message', 'location');
|
||||||
|
|
|
@ -70,7 +70,7 @@ class AFOSMessageParserState(enum.Enum):
|
||||||
FOOTER = enum.auto()
|
FOOTER = enum.auto()
|
||||||
|
|
||||||
class AFOSMessage(DatabaseTable):
|
class AFOSMessage(DatabaseTable):
|
||||||
__table__ = 'nexrad_afos_messsage'
|
__table__ = 'nexrad_afos_message'
|
||||||
__key__ = 'id'
|
__key__ = 'id'
|
||||||
|
|
||||||
__columns__ = (
|
__columns__ = (
|
||||||
|
@ -142,7 +142,9 @@ class AFOSMessage(DatabaseTable):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse(text: str) -> Self:
|
def parse(text: str) -> Self:
|
||||||
event = AFOSMessage()
|
message = AFOSMessage()
|
||||||
|
message.text = text
|
||||||
|
|
||||||
state = AFOSMessageParserState.SERIAL
|
state = AFOSMessageParserState.SERIAL
|
||||||
|
|
||||||
for line in text.split('\n'):
|
for line in text.split('\n'):
|
||||||
|
@ -152,7 +154,7 @@ class AFOSMessage(DatabaseTable):
|
||||||
match = RE_ID.match(line)
|
match = RE_ID.match(line)
|
||||||
|
|
||||||
if match is not None:
|
if match is not None:
|
||||||
event.serial = int(match[1])
|
message.serial = int(match[1])
|
||||||
state = AFOSMessageParserState.ISSUANCE
|
state = AFOSMessageParserState.ISSUANCE
|
||||||
elif state == AFOSMessageParserState.ISSUANCE:
|
elif state == AFOSMessageParserState.ISSUANCE:
|
||||||
match = RE_ISSUANCE.match(line)
|
match = RE_ISSUANCE.match(line)
|
||||||
|
@ -163,7 +165,7 @@ class AFOSMessage(DatabaseTable):
|
||||||
match = RE_PRODUCT.match(line)
|
match = RE_PRODUCT.match(line)
|
||||||
|
|
||||||
if match is not None:
|
if match is not None:
|
||||||
event.product = match['product']
|
message.product = match['product']
|
||||||
|
|
||||||
state = AFOSMessageParserState.BODY
|
state = AFOSMessageParserState.BODY
|
||||||
elif state == AFOSMessageParserState.BODY:
|
elif state == AFOSMessageParserState.BODY:
|
||||||
|
@ -173,15 +175,15 @@ class AFOSMessage(DatabaseTable):
|
||||||
vtec = VTECEvent.parse(line)
|
vtec = VTECEvent.parse(line)
|
||||||
|
|
||||||
if vtec is not None:
|
if vtec is not None:
|
||||||
event.timestamp_start = vtec.timestamp_start
|
message.timestamp_start = vtec.timestamp_start
|
||||||
event.timestamp_end = vtec.timestamp_end
|
message.timestamp_end = vtec.timestamp_end
|
||||||
|
|
||||||
event.vtec_type = vtec.typeof
|
message.vtec_type = vtec.typeof
|
||||||
event.actions = vtec.actions
|
message.actions = vtec.actions
|
||||||
event.wfo = vtec.wfo
|
message.wfo = vtec.wfo
|
||||||
event.phenom = vtec.phenom
|
message.phenom = vtec.phenom
|
||||||
event.sig = vtec.sig
|
message.sig = vtec.sig
|
||||||
event.etn = vtec.etn
|
message.etn = vtec.etn
|
||||||
elif line == '&&':
|
elif line == '&&':
|
||||||
state = AFOSMessageParserState.TAGS
|
state = AFOSMessageParserState.TAGS
|
||||||
elif state == AFOSMessageParserState.TAGS:
|
elif state == AFOSMessageParserState.TAGS:
|
||||||
|
@ -191,19 +193,19 @@ class AFOSMessage(DatabaseTable):
|
||||||
match = RE_POLY.match(line)
|
match = RE_POLY.match(line)
|
||||||
|
|
||||||
if match is not None:
|
if match is not None:
|
||||||
event.poly = parse_shape(match['coords'])
|
message.poly = parse_shape(match['coords'])
|
||||||
|
|
||||||
match = RE_MOTION.match(line)
|
match = RE_MOTION.match(line)
|
||||||
|
|
||||||
if match is not None:
|
if match is not None:
|
||||||
event.azimuth = int(match['azimuth'])
|
message.azimuth = int(match['azimuth'])
|
||||||
event.speed = int(match['speed'])
|
message.speed = int(match['speed'])
|
||||||
event.location = parse_location(match['lon'], match['lat'])
|
message.location = parse_location(match['lon'], match['lat'])
|
||||||
elif state == AFOSMessageParserState.FOOTER:
|
elif state == AFOSMessageParserState.FOOTER:
|
||||||
if line != '':
|
if line != '':
|
||||||
event.forecaster = line
|
message.forecaster = line
|
||||||
|
|
||||||
return event
|
return message
|
||||||
|
|
||||||
def is_watch(self):
|
def is_watch(self):
|
||||||
return self.sig is not None and self.sig == 'A'
|
return self.sig is not None and self.sig == 'A'
|
||||||
|
|
Loading…
Add table
Reference in a new issue