Roll back implementation

This commit is contained in:
XANTRONIX 2025-03-24 18:45:04 -04:00
parent dd9848e8a3
commit 4e75ebc714

View file

@ -119,75 +119,25 @@ class PolygonBuilder():
if direction is not PointDirection.LEFT: if direction is not PointDirection.LEFT:
return return
for i in range(i1+1, i2): for i in range(i1, i2):
yield from self.yield_point(self.bounds[i % count]) yield from self.yield_point(self.bounds[i % count])
def each_point_within(self): def each_point_within(self):
last = None
for point in self.sequence: for point in self.sequence:
if self.point_first is None: if self.point_first is None:
self.point_first = point self.point_first = point
self.point_last = point self.point_last = point
if last is None: self.total += 1
last = point
continue
last_within = self.bounds.polygon.contains(last) yield point
point_within = self.bounds.polygon.contains(point)
# #
# If the first point in the current line exists within the other # If the first point is to the left of the last point, fill in the
# geometry, then yield it.
#
if last_within:
yield from self.yield_point(last)
#
# Check for intersections with the line in the other geometry.
#
inter = self.bounds.linestring.intersection(shapely.LineString([last, point]))
if inter.geom_type == 'Point':
#
# If the intersection is a single point, then yield that
# point.
#
yield from self.yield_point(inter)
elif inter.geom_type == 'MultiPoint':
#
# If the intersection is multiple points, then yield those
# points, as well as all between on the other geometry, if and
# only if the intersection does not constitute the first and
# last point.
#
last_geom = None
for geom in inter.geoms:
if last_geom is None:
last_geom = geom
continue
yield from self.yield_point(last_geom)
yield from self.yield_point(geom)
last_geom = geom
#
# If the second point in the current line exists within the other
# geometry, then yield that.
#
if point_within:
yield from self.yield_point(point)
last = point
#
# If the first point is to the right of the last point, fill in the
# intermediates. # intermediates.
# #
if self.total == 2:
i1 = self.bounds.nearest_index(self.point_first) i1 = self.bounds.nearest_index(self.point_first)
i2 = self.bounds.nearest_index(self.point_last) i2 = self.bounds.nearest_index(self.point_last)