Compare commits

..

No commits in common. "33ac8386b10cf02dc251749e09975ccd84120a2c" and "c12d250d3e970d429fb448fae50869b6cc826288" have entirely different histories.

2 changed files with 18 additions and 25 deletions

View file

@ -60,11 +60,6 @@ create table nexrad_afos_message (
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
AddGeometryColumn('nexrad_afos_message', 'location', 4326, 'POINT'),
CreateSpatialIndex('nexrad_afos_message', 'location');

View file

@ -70,7 +70,7 @@ class AFOSMessageParserState(enum.Enum):
FOOTER = enum.auto()
class AFOSMessage(DatabaseTable):
__table__ = 'nexrad_afos_message'
__table__ = 'nexrad_afos_messsage'
__key__ = 'id'
__columns__ = (
@ -142,9 +142,7 @@ class AFOSMessage(DatabaseTable):
@staticmethod
def parse(text: str) -> Self:
message = AFOSMessage()
message.text = text
event = AFOSMessage()
state = AFOSMessageParserState.SERIAL
for line in text.split('\n'):
@ -154,7 +152,7 @@ class AFOSMessage(DatabaseTable):
match = RE_ID.match(line)
if match is not None:
message.serial = int(match[1])
event.serial = int(match[1])
state = AFOSMessageParserState.ISSUANCE
elif state == AFOSMessageParserState.ISSUANCE:
match = RE_ISSUANCE.match(line)
@ -165,7 +163,7 @@ class AFOSMessage(DatabaseTable):
match = RE_PRODUCT.match(line)
if match is not None:
message.product = match['product']
event.product = match['product']
state = AFOSMessageParserState.BODY
elif state == AFOSMessageParserState.BODY:
@ -175,15 +173,15 @@ class AFOSMessage(DatabaseTable):
vtec = VTECEvent.parse(line)
if vtec is not None:
message.timestamp_start = vtec.timestamp_start
message.timestamp_end = vtec.timestamp_end
event.timestamp_start = vtec.timestamp_start
event.timestamp_end = vtec.timestamp_end
message.vtec_type = vtec.typeof
message.actions = vtec.actions
message.wfo = vtec.wfo
message.phenom = vtec.phenom
message.sig = vtec.sig
message.etn = vtec.etn
event.vtec_type = vtec.typeof
event.actions = vtec.actions
event.wfo = vtec.wfo
event.phenom = vtec.phenom
event.sig = vtec.sig
event.etn = vtec.etn
elif line == '&&':
state = AFOSMessageParserState.TAGS
elif state == AFOSMessageParserState.TAGS:
@ -193,19 +191,19 @@ class AFOSMessage(DatabaseTable):
match = RE_POLY.match(line)
if match is not None:
message.poly = parse_shape(match['coords'])
event.poly = parse_shape(match['coords'])
match = RE_MOTION.match(line)
if match is not None:
message.azimuth = int(match['azimuth'])
message.speed = int(match['speed'])
message.location = parse_location(match['lon'], match['lat'])
event.azimuth = int(match['azimuth'])
event.speed = int(match['speed'])
event.location = parse_location(match['lon'], match['lat'])
elif state == AFOSMessageParserState.FOOTER:
if line != '':
message.forecaster = line
event.forecaster = line
return message
return event
def is_watch(self):
return self.sig is not None and self.sig == 'A'