diff --git a/lib/xmet/geo.py b/lib/xmet/geo.py index e9bb732..1598fde 100644 --- a/lib/xmet/geo.py +++ b/lib/xmet/geo.py @@ -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: