Fix coordinates with more than 4 digits

This commit is contained in:
XANTRONIX Industrial 2025-02-19 16:24:17 -05:00
parent a96c982991
commit 928fe6c71e

View file

@ -1,7 +1,6 @@
import re
import enum
import datetime
import json
import shapely
from nexrad.db import DatabaseTable
@ -55,7 +54,7 @@ RE_HYDRO = re.compile(r'''
/$
''', re.X)
RE_POLY = re.compile(r'^LAT\.\.\.LON (?P<coords>\d{4}(?: \d{4})+)')
RE_POLY = re.compile(r'^LAT\.\.\.LON (?P<coords>\d+(?: \d+)+)')
def parse_timestamp(text: str, post_2016_05_11: bool):
return datetime.datetime.strptime(
@ -63,10 +62,12 @@ def parse_timestamp(text: str, post_2016_05_11: bool):
).astimezone(datetime.UTC)
def parse_lon(text: str):
return 0 - float(text[0:2]) + (float(text[3:4]) / 100)
size = len(text)
return 0 - float(text[0:size-2]) + (float(text[size-2:size]) / 100)
def parse_lat(text: str):
return float(text[0:2]) + (float(text[3:4]) / 100)
size = len(text)
return float(text[0:size-2]) + (float(text[size-2:size]) / 100)
def parse_shape(text: str):
points = list()
@ -177,7 +178,7 @@ class VTECEvent(DatabaseTable):
if match is not None:
event.timestamp_start = parse_timestamp(match['time_start'], post_2016_05_11)
event.timestamp_end = parse_timestamp(match['time_end'], post_2016_05_11)
event.timestamp_end = parse_timestamp(match['time_end'], post_2016_05_11)
event.typeof = match['typeof']
event.actions = match['actions']