From df1088f30f8b6f265ba0260f80b827f6e93d5c98 Mon Sep 17 00:00:00 2001
From: XANTRONIX Industrial <xan@xantronix.com>
Date: Sun, 23 Mar 2025 20:53:54 -0400
Subject: [PATCH] Better heuristic for when to find intermediates

---
 lib/xmet/geo.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/xmet/geo.py b/lib/xmet/geo.py
index 784ec90..3d55e03 100644
--- a/lib/xmet/geo.py
+++ b/lib/xmet/geo.py
@@ -191,10 +191,13 @@ class PolygonBuilder():
                 yield from self.yield_point(point)
 
             #
-            # If only two points have been yielded, then yield the intermediate
-            # between the end and the start (reversed).
+            # Yield all intermediate points if the first point is to the right
+            # of the last point.
             #
-            if self.total == 2:
+            dist, direction = self.bounds.index_distance(self.point_first,
+                                                         self.point_last)
+
+            if direction is PointDirection.RIGHT:
                 yield from self.each_intermediate_point(self.point_last,
                                                         self.point_first)