craigtaverner commented on code in PR #15657:
URL: https://github.com/apache/lucene/pull/15657#discussion_r2754373338


##########
lucene/core/src/java/org/apache/lucene/geo/Tessellator.java:
##########
@@ -408,25 +408,47 @@ private static boolean maybeMergeHoleWithSharedVertices(
     // Attempt to find a common point between the HoleNode and OuterNode.
     Node sharedVertex = null;
     Node sharedVertexConnection = null;
+    // Track the leftmost vertex match (holeNode is the leftmost vertex of the 
hole)
+    Node leftmostSharedVertex = null;
+    Node leftmostSharedVertexConnection = null;
     Node next = outerNode;
     do {
       if (Rectangle.containsPoint(
           next.getY(), next.getX(), holeMinY, holeMaxY, holeMinX, holeMaxX)) {
         Node newSharedVertex = getSharedVertex(holeNode, next);
         if (newSharedVertex != null) {
+          // Check if this shared vertex is the leftmost point of the hole 
(holeNode)
+          if (isVertexEquals(newSharedVertex, holeNode)) {
+            if (leftmostSharedVertex == null) {
+              leftmostSharedVertex = newSharedVertex;
+              leftmostSharedVertexConnection = next;
+            } else if (newSharedVertex.equals(leftmostSharedVertex)) {
+              // Same vertex found again via different connection
+              leftmostSharedVertexConnection =
+                  getSharedInsideVertex(leftmostSharedVertex, 
leftmostSharedVertexConnection, next);
+            }
+          }
           if (sharedVertex == null) {
             sharedVertex = newSharedVertex;
             sharedVertexConnection = next;
           } else if (newSharedVertex.equals(sharedVertex)) {
-            // This can only happen if this vertex has been already used for a 
bridge. We need to
-            // choose the right one.
+            // Same vertex found again via different connection.
             sharedVertexConnection =
                 getSharedInsideVertex(sharedVertex, sharedVertexConnection, 
next);
           }
         }
       }
       next = next.next;
     } while (next != outerNode);
+
+    // The leftmost vertex of the hole is a shared vertex. Prefer this 
onnection point if it is

Review Comment:
   ```suggestion
       // The leftmost vertex of the hole is a shared vertex. Prefer this 
connection point if it is
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to