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 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');

View file

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