Split each_point_sequence() from each_poly()
This commit is contained in:
parent
8cdf97164c
commit
01ff03e7b4
1 changed files with 10 additions and 3 deletions
|
@ -5,6 +5,7 @@ import datetime
|
|||
|
||||
from xmet.db import DatabaseTable
|
||||
from xmet.coord import COORD_SYSTEM
|
||||
from xmet.geo import PointSequence
|
||||
from xmet.afos import MONTHS, TIMEZONES
|
||||
|
||||
RE_HEADER = re.compile(r'''
|
||||
|
@ -71,7 +72,7 @@ def parse_coord(coord: str) -> tuple[float, float]:
|
|||
return shapely.Point(0.01 * -lon,
|
||||
0.01 * int(coord[0:4]))
|
||||
|
||||
def each_poly(parts: list[str]):
|
||||
def each_point_sequence(parts: list[str]):
|
||||
points = list()
|
||||
|
||||
for part in parts:
|
||||
|
@ -80,8 +81,14 @@ def each_poly(parts: list[str]):
|
|||
else:
|
||||
points.append(parse_coord(part))
|
||||
|
||||
if len(points) >= 3:
|
||||
yield shapely.Polygon(points)
|
||||
if len(points) > 1:
|
||||
yield PointSequence(points)
|
||||
|
||||
def each_poly(parts: list[str]):
|
||||
for sequence in each_point_sequence(parts):
|
||||
sequence.close()
|
||||
|
||||
yield sequence.poly
|
||||
|
||||
class SPCOutlookArea(DatabaseTable):
|
||||
__slots__ = ('id', 'outlook_id', 'poly')
|
||||
|
|
Loading…
Add table
Reference in a new issue