Almost there. What a slog

This commit is contained in:
XANTRONIX 2025-03-23 23:19:03 -04:00
parent df1088f30f
commit 150ab35d04

View file

@ -3,17 +3,7 @@ import enum
import math
import shapely
from typing import Self, Union
def each_intermediate_point(p1: shapely.Point,
p2: shapely.Point,
intersection: Union[shapely.LineString, shapely.MultiLineString]):
typeof = type(intersection)
if typeof is shapely.LineString:
pass
elif typeof is shapely.MultiLineString:
pass
from typing import Self
class PointDirection(enum.Enum):
EQUAL = 0
@ -125,10 +115,12 @@ class PolygonBuilder():
def each_intermediate_point(self, p1: shapely.Point, p2: shapely.Point):
count = len(self.bounds)
i1 = self.bounds.nearest_index(p1) + count
i2 = self.bounds.nearest_index(p2) + count
i1 = self.bounds.nearest_index(p1)
i2 = self.bounds.nearest_index(p2)
if i1 > i2:
dist, direction = self.bounds.index_distance(i1, i2)
if direction is not PointDirection.LEFT:
return
for i in range(i1, i2+1):
@ -194,10 +186,7 @@ class PolygonBuilder():
# Yield all intermediate points if the first point is to the right
# of the last point.
#
dist, direction = self.bounds.index_distance(self.point_first,
self.point_last)
if direction is PointDirection.RIGHT:
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)