Roll back implementation
This commit is contained in:
parent
dd9848e8a3
commit
4e75ebc714
1 changed files with 11 additions and 61 deletions
|
@ -119,83 +119,33 @@ class PolygonBuilder():
|
|||
if direction is not PointDirection.LEFT:
|
||||
return
|
||||
|
||||
for i in range(i1+1, i2):
|
||||
for i in range(i1, i2):
|
||||
yield from self.yield_point(self.bounds[i % count])
|
||||
|
||||
def each_point_within(self):
|
||||
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
|
||||
self.total += 1
|
||||
|
||||
last_within = self.bounds.polygon.contains(last)
|
||||
point_within = self.bounds.polygon.contains(point)
|
||||
|
||||
#
|
||||
# If the first point in the current line exists within the other
|
||||
# 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
|
||||
yield point
|
||||
|
||||
#
|
||||
# If the first point is to the right of the last point, fill in the
|
||||
# If the first point is to the left of the last point, fill in the
|
||||
# intermediates.
|
||||
#
|
||||
i1 = self.bounds.nearest_index(self.point_first)
|
||||
i2 = self.bounds.nearest_index(self.point_last)
|
||||
if self.total == 2:
|
||||
i1 = self.bounds.nearest_index(self.point_first)
|
||||
i2 = self.bounds.nearest_index(self.point_last)
|
||||
|
||||
dist, direction = self.bounds.index_distance(i1, i2)
|
||||
dist, direction = self.bounds.index_distance(i1, i2)
|
||||
|
||||
if direction is PointDirection.RIGHT:
|
||||
yield from self.each_intermediate_point(self.point_last,
|
||||
self.point_first)
|
||||
if direction is PointDirection.RIGHT:
|
||||
yield from self.each_intermediate_point(self.point_last,
|
||||
self.point_first)
|
||||
|
||||
def process(self) -> shapely.Polygon:
|
||||
pass
|
||||
|
|
Loading…
Add table
Reference in a new issue