From 08bbfac7ebfb0f2368fc37a581c124a8fbaa5d97 Mon Sep 17 00:00:00 2001 From: Nicholas Knize Date: Mon, 24 Nov 2014 07:36:20 -0600 Subject: [PATCH] Updating comments in BasePolygonBuilder to explain "pairwise" intersection --- .../common/geo/builders/BasePolygonBuilder.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/elasticsearch/common/geo/builders/BasePolygonBuilder.java b/src/main/java/org/elasticsearch/common/geo/builders/BasePolygonBuilder.java index 8d606188eae..147678319a7 100644 --- a/src/main/java/org/elasticsearch/common/geo/builders/BasePolygonBuilder.java +++ b/src/main/java/org/elasticsearch/common/geo/builders/BasePolygonBuilder.java @@ -395,7 +395,15 @@ public abstract class BasePolygonBuilder> extend holes[e2.component-1] = holes[numHoles]; holes[numHoles] = null; } - // only connect edges if intersections are pairwise (per comment above) + // only connect edges if intersections are pairwise + // per the comment above, the edge array is sorted by y-value of the intersection + // with the dateline. Two edges have the same y intercept when they cross the + // dateline thus they appear sequentially (pairwise) in the edge array. Two edges + // do not have the same y intercept when we're forming a multi-poly from a poly + // that wraps the dateline (but there are 2 ordered intercepts). + // The connect method creates a new edge for these paired edges in the linked list. + // For boundary conditions (e.g., intersect but not crossing) there is no sibling edge + // to connect. Thus the following enforces the pairwise rule if (e1.intersect != Edge.MAX_COORDINATE && e2.intersect != Edge.MAX_COORDINATE) { connect(e1, e2); }