This is better for my current corner case
This commit is contained in:
parent
150ab35d04
commit
9b9a95b71a
1 changed files with 6 additions and 14 deletions
|
@ -100,12 +100,8 @@ class PolygonBuilder():
|
|||
def yield_point(self, point: shapely.Point):
|
||||
"""
|
||||
Yield the single point to the caller, while maintaining state of
|
||||
whether this point is the first or last point seen by the polygon
|
||||
builder.
|
||||
number of points yielded to the caller.
|
||||
"""
|
||||
if self.point_first is None:
|
||||
self.point_first = point
|
||||
|
||||
self.point_last = point
|
||||
|
||||
yield point
|
||||
|
@ -130,6 +126,11 @@ class PolygonBuilder():
|
|||
last = None
|
||||
|
||||
for point in self.sequence:
|
||||
if self.point_first is None:
|
||||
self.point_first = point
|
||||
|
||||
self.point_last = point
|
||||
|
||||
if last is None:
|
||||
last = point
|
||||
continue
|
||||
|
@ -170,7 +171,6 @@ class PolygonBuilder():
|
|||
continue
|
||||
|
||||
yield from self.yield_point(last_geom)
|
||||
yield from self.each_intermediate_point(last_geom, geom)
|
||||
yield from self.yield_point(geom)
|
||||
|
||||
last_geom = geom
|
||||
|
@ -182,14 +182,6 @@ class PolygonBuilder():
|
|||
if point_within:
|
||||
yield from self.yield_point(point)
|
||||
|
||||
#
|
||||
# Yield all intermediate points if the first point is to the right
|
||||
# of the last point.
|
||||
#
|
||||
if self.point_first is not None and self.point_last is not None:
|
||||
yield from self.each_intermediate_point(self.point_last,
|
||||
self.point_first)
|
||||
|
||||
last = point
|
||||
|
||||
def process(self) -> shapely.Polygon:
|
||||
|
|
Loading…
Add table
Reference in a new issue