Fix coordinates with more than 4 digits
This commit is contained in:
parent
a96c982991
commit
928fe6c71e
1 changed files with 6 additions and 5 deletions
|
@ -1,7 +1,6 @@
|
||||||
import re
|
import re
|
||||||
import enum
|
import enum
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
|
||||||
import shapely
|
import shapely
|
||||||
|
|
||||||
from nexrad.db import DatabaseTable
|
from nexrad.db import DatabaseTable
|
||||||
|
@ -55,7 +54,7 @@ RE_HYDRO = re.compile(r'''
|
||||||
/$
|
/$
|
||||||
''', re.X)
|
''', 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):
|
def parse_timestamp(text: str, post_2016_05_11: bool):
|
||||||
return datetime.datetime.strptime(
|
return datetime.datetime.strptime(
|
||||||
|
@ -63,10 +62,12 @@ def parse_timestamp(text: str, post_2016_05_11: bool):
|
||||||
).astimezone(datetime.UTC)
|
).astimezone(datetime.UTC)
|
||||||
|
|
||||||
def parse_lon(text: str):
|
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):
|
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):
|
def parse_shape(text: str):
|
||||||
points = list()
|
points = list()
|
||||||
|
@ -177,7 +178,7 @@ class VTECEvent(DatabaseTable):
|
||||||
|
|
||||||
if match is not None:
|
if match is not None:
|
||||||
event.timestamp_start = parse_timestamp(match['time_start'], post_2016_05_11)
|
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.typeof = match['typeof']
|
||||||
event.actions = match['actions']
|
event.actions = match['actions']
|
||||||
|
|
Loading…
Add table
Reference in a new issue