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.db import DatabaseTable
|
||||||
from xmet.coord import COORD_SYSTEM
|
from xmet.coord import COORD_SYSTEM
|
||||||
|
from xmet.geo import PointSequence
|
||||||
from xmet.afos import MONTHS, TIMEZONES
|
from xmet.afos import MONTHS, TIMEZONES
|
||||||
|
|
||||||
RE_HEADER = re.compile(r'''
|
RE_HEADER = re.compile(r'''
|
||||||
|
@ -71,7 +72,7 @@ def parse_coord(coord: str) -> tuple[float, float]:
|
||||||
return shapely.Point(0.01 * -lon,
|
return shapely.Point(0.01 * -lon,
|
||||||
0.01 * int(coord[0:4]))
|
0.01 * int(coord[0:4]))
|
||||||
|
|
||||||
def each_poly(parts: list[str]):
|
def each_point_sequence(parts: list[str]):
|
||||||
points = list()
|
points = list()
|
||||||
|
|
||||||
for part in parts:
|
for part in parts:
|
||||||
|
@ -80,8 +81,14 @@ def each_poly(parts: list[str]):
|
||||||
else:
|
else:
|
||||||
points.append(parse_coord(part))
|
points.append(parse_coord(part))
|
||||||
|
|
||||||
if len(points) >= 3:
|
if len(points) > 1:
|
||||||
yield shapely.Polygon(points)
|
yield PointSequence(points)
|
||||||
|
|
||||||
|
def each_poly(parts: list[str]):
|
||||||
|
for sequence in each_point_sequence(parts):
|
||||||
|
sequence.close()
|
||||||
|
|
||||||
|
yield sequence.poly
|
||||||
|
|
||||||
class SPCOutlookArea(DatabaseTable):
|
class SPCOutlookArea(DatabaseTable):
|
||||||
__slots__ = ('id', 'outlook_id', 'poly')
|
__slots__ = ('id', 'outlook_id', 'poly')
|
||||||
|
|
Loading…
Add table
Reference in a new issue