[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-23 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r250101885
 
 

 ##
 File path: lucene/core/src/java/org/apache/lucene/geo/EdgeTree.java
 ##
 @@ -158,6 +212,61 @@ private Relation internalComponentRelateTriangle(double 
ax, double ay, double bx
 return Relation.CELL_OUTSIDE_QUERY;
   }
 
+  private WithinRelation internalWithinTriangle(double ax, double ay, boolean 
ab, double bx, double by, boolean bc, double cx, double cy, boolean ca) {
+// compute bounding box of triangle
+double minLat = StrictMath.min(StrictMath.min(ay, by), cy);
+double minLon = StrictMath.min(StrictMath.min(ax, bx), cx);
+double maxLat = StrictMath.max(StrictMath.max(ay, by), cy);
+double maxLon = StrictMath.max(StrictMath.max(ax, bx), cx);
+
+//disjoint then we return null
 
 Review comment:
   outdated?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-23 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r250136513
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/geo/Tessellator.java
 ##
 @@ -723,13 +735,23 @@ private static boolean pointInEar(final double x, final 
double y, final double a
 
   /** compute whether the given x, y point is in a triangle; uses the winding 
order method */
   public static boolean pointInTriangle (double x, double y, double ax, double 
ay, double bx, double by, double cx, double cy) {
-int a = orient(x, y, ax, ay, bx, by);
-int b = orient(x, y, bx, by, cx, cy);
-if (a == 0 || b == 0 || a < 0 == b < 0) {
-  int c = orient(x, y, cx, cy, ax, ay);
-  return c == 0 || (c < 0 == (b < 0 || a < 0));
+double minX = StrictMath.min(ax, StrictMath.min(bx, cx));
+double minY = StrictMath.min(ay, StrictMath.min(by, cy));
+double maxX = StrictMath.max(ax, StrictMath.max(bx, cx));
+double maxY = StrictMath.max(ay, StrictMath.max(by, cy));
+//check the bounding box because if the triangle is degenerated, e.g 
points and lines, we need to filter out
+//coplanar points that are not part of the triangle.
 
 Review comment:
   ++


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-23 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r250104177
 
 

 ##
 File path: lucene/core/src/java/org/apache/lucene/geo/EdgeTree.java
 ##
 @@ -101,6 +101,60 @@ public Relation relateTriangle(double ax, double ay, 
double bx, double by, doubl
 return Relation.CELL_OUTSIDE_QUERY;
   }
 
+  /** Used by withinTriangle to check the within relationship between a 
triangle and the query shape */
+  public enum WithinRelation {
+/** If the shape is a candidate for within. Typically this is return if 
the query shape is fully inside
+ * the triangle or if the query shape intersects only edges that do not 
belong to the original shape. */
+CANDIDATE,
+/** Return this if if the query shape intersects an edge that does belong 
to the original shape. */
+CROSSES,
+/** Return this if the query shape is disjoint with the triangle. Note 
that the query shape can still be
+ * within the indexed shape that correspond to the triangle */
+DISJOINT
+  }
+
+  /**
+   *  Checks if the shape is within the provided triangle.
+   *
+   * @param ax longitude of point a of the triangle
+   * @param ay latitude of point a of the triangle
+   * @param ab if edge ab belongs to the original shape
+   * @param bx longitude of point b of the triangle
+   * @param by latitude of point b of the triangle
+   * @param bc if edge bc belongs to the original shape
+   * @param cx longitude of point c of the triangle
+   * @param cy latitude of point c of the triangle
+   * @param ca if edge ca belongs to the original shape
+   * @return
 
 Review comment:
   let's either have it in the javadocs with a description or remove it?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-23 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r250130909
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/geo/Rectangle2D.java
 ##
 @@ -148,6 +148,90 @@ public boolean intersectsTriangle(int aX, int aY, int bX, 
int bY, int cX, int cY
 return false;
   }
 
+  /**
+   *  Checks if the shape is within the provided triangle.
+   *
+   * @param ax longitude of point a of the triangle
+   * @param ay latitude of point a of the triangle
+   * @param ab if edge ab belongs to the original shape
+   * @param bx longitude of point b of the triangle
+   * @param by latitude of point b of the triangle
+   * @param bc if edge bc belongs to the original shape
+   * @param cx longitude of point c of the triangle
+   * @param cy latitude of point c of the triangle
+   * @param ca if edge ca belongs to the original shape
+   * @return the {@link EdgeTree.WithinRelation}
+   */
+  public EdgeTree.WithinRelation withinTriangle(int ax, int ay, boolean ab, 
int bx, int by, boolean bc, int cx, int cy, boolean ca) {
+if (this.crossesDateline() == true) {
+  //Triangles cannot cross the date line so it is always false
+  return EdgeTree.WithinRelation.CROSSES;
+}
+// compute bounding box of triangle
+int tMinX = StrictMath.min(StrictMath.min(ax, bx), cx);
+int tMaxX = StrictMath.max(StrictMath.max(ax, bx), cx);
+int tMinY = StrictMath.min(StrictMath.min(ay, by), cy);
+int tMaxY = StrictMath.max(StrictMath.max(ay, by), cy);
+if (boxesAreDisjoint(tMinX, tMaxX, tMinY, tMaxY,  minX, maxX, minY, maxY)) 
{
+  return EdgeTree.WithinRelation.DISJOINT;
+}
+
+return bboxWithinTriangle(ax, ay, ab, bx, by, bc, cx, cy, ca, minX, maxX, 
minY, maxY);
 
 Review comment:
   we don't need to pass minX, ..., maxY, bboxWithinRectangle has access to 
those variables as well?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-23 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r250126904
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/geo/Rectangle2D.java
 ##
 @@ -148,6 +148,90 @@ public boolean intersectsTriangle(int aX, int aY, int bX, 
int bY, int cX, int cY
 return false;
   }
 
+  /**
+   *  Checks if the shape is within the provided triangle.
+   *
+   * @param ax longitude of point a of the triangle
+   * @param ay latitude of point a of the triangle
+   * @param ab if edge ab belongs to the original shape
+   * @param bx longitude of point b of the triangle
+   * @param by latitude of point b of the triangle
+   * @param bc if edge bc belongs to the original shape
+   * @param cx longitude of point c of the triangle
+   * @param cy latitude of point c of the triangle
+   * @param ca if edge ca belongs to the original shape
+   * @return the {@link EdgeTree.WithinRelation}
+   */
+  public EdgeTree.WithinRelation withinTriangle(int ax, int ay, boolean ab, 
int bx, int by, boolean bc, int cx, int cy, boolean ca) {
+if (this.crossesDateline() == true) {
+  //Triangles cannot cross the date line so it is always false
+  return EdgeTree.WithinRelation.CROSSES;
+}
+// compute bounding box of triangle
+int tMinX = StrictMath.min(StrictMath.min(ax, bx), cx);
+int tMaxX = StrictMath.max(StrictMath.max(ax, bx), cx);
+int tMinY = StrictMath.min(StrictMath.min(ay, by), cy);
+int tMaxY = StrictMath.max(StrictMath.max(ay, by), cy);
+if (boxesAreDisjoint(tMinX, tMaxX, tMinY, tMaxY,  minX, maxX, minY, maxY)) 
{
+  return EdgeTree.WithinRelation.DISJOINT;
+}
+
+return bboxWithinTriangle(ax, ay, ab, bx, by, bc, cx, cy, ca, minX, maxX, 
minY, maxY);
+  }
+  public EdgeTree.WithinRelation bboxWithinTriangle(int ax, int ay, boolean 
ab, int bx, int by, boolean bc, int cx, int cy, boolean ca, int minLon, int 
maxLon, int minLat, int maxLat) {
 
 Review comment:
   this can be made private?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-23 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r250142208
 
 

 ##
 File path: 
lucene/sandbox/src/java/org/apache/lucene/document/LatLonShapeQuery.java
 ##
 @@ -163,17 +186,24 @@ public Scorer get(long leadCost) throws IOException {
 };
   }
 
-  /** get a scorer supplier for all other queries (DISJOINT, WITHIN) */
+  /** get a scorer supplier for all other queries (DISJOINT, WITHIN, 
CONTAINS) */
   protected ScorerSupplier getScorerSupplier(LeafReader reader, 
PointValues values, Weight weight, ScoreMode scoreMode) throws IOException {
 if (queryRelation == QueryRelation.INTERSECTS) {
   return getIntersectScorerSupplier(reader, values, weight, scoreMode);
 }
-//For within and disjoint we need two passes to remove false positives 
in case of multi-shapes.
 FixedBitSet within = new FixedBitSet(reader.maxDoc());
 FixedBitSet disjoint = new FixedBitSet(reader.maxDoc());
-IntersectVisitor withinVisitor = getDenseIntersectVisitor(within, 
disjoint, QueryRelation.WITHIN);
-IntersectVisitor disjointVisitor = getDenseIntersectVisitor(within, 
disjoint, QueryRelation.DISJOINT);
-return new RelationScorerSupplier(values, withinVisitor, 
disjointVisitor, queryRelation) {
+IntersectVisitor visitor;
+IntersectVisitor disjointVisitor;
+if (queryRelation == QueryRelation.CONTAINS) {
+  visitor = getDenseIntersectVisitor(within, disjoint, queryRelation);
 
 Review comment:
   the `within`/`disjoint` naming of the bitsets feels a bit weird now (my 
fault, sorry!). Maybe `candidates`/`rejected` or something like that instead?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-23 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r250132342
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/geo/Rectangle2D.java
 ##
 @@ -148,6 +148,90 @@ public boolean intersectsTriangle(int aX, int aY, int bX, 
int bY, int cX, int cY
 return false;
   }
 
+  /**
+   *  Checks if the shape is within the provided triangle.
+   *
+   * @param ax longitude of point a of the triangle
+   * @param ay latitude of point a of the triangle
+   * @param ab if edge ab belongs to the original shape
+   * @param bx longitude of point b of the triangle
+   * @param by latitude of point b of the triangle
+   * @param bc if edge bc belongs to the original shape
+   * @param cx longitude of point c of the triangle
+   * @param cy latitude of point c of the triangle
+   * @param ca if edge ca belongs to the original shape
+   * @return the {@link EdgeTree.WithinRelation}
+   */
+  public EdgeTree.WithinRelation withinTriangle(int ax, int ay, boolean ab, 
int bx, int by, boolean bc, int cx, int cy, boolean ca) {
+if (this.crossesDateline() == true) {
+  //Triangles cannot cross the date line so it is always false
+  return EdgeTree.WithinRelation.CROSSES;
+}
+// compute bounding box of triangle
+int tMinX = StrictMath.min(StrictMath.min(ax, bx), cx);
+int tMaxX = StrictMath.max(StrictMath.max(ax, bx), cx);
+int tMinY = StrictMath.min(StrictMath.min(ay, by), cy);
+int tMaxY = StrictMath.max(StrictMath.max(ay, by), cy);
+if (boxesAreDisjoint(tMinX, tMaxX, tMinY, tMaxY,  minX, maxX, minY, maxY)) 
{
+  return EdgeTree.WithinRelation.DISJOINT;
+}
+
+return bboxWithinTriangle(ax, ay, ab, bx, by, bc, cx, cy, ca, minX, maxX, 
minY, maxY);
+  }
+  public EdgeTree.WithinRelation bboxWithinTriangle(int ax, int ay, boolean 
ab, int bx, int by, boolean bc, int cx, int cy, boolean ca, int minLon, int 
maxLon, int minLat, int maxLat) {
+//points belong to the shape so if points are inside the rectangle then it 
cannot be within. It is valid if the point
+//is on the edge.
+if (bboxContainsPoint(ax, ay, minLon, maxLon, minLat, maxLat) ||
+bboxContainsPoint(bx, by, minLon, maxLon, minLat, maxLat) ||
+bboxContainsPoint(cx, cy, minLon, maxLon, minLat, maxLat)) {
+  return EdgeTree.WithinRelation.CROSSES;
+}
+//if any of the edges crosses and edge belonging to the polygon then it 
cannot be within.
+//Note that crosses is different to crosses as it needs to have points at 
both sides.
+boolean inside = false;
+if  (edgeIntersectsBox(ax, ay, bx, by, minLon, maxLon, minLat, maxLat) == 
true) {
+  if (ab == true) {
+return EdgeTree.WithinRelation.CROSSES;
+  } else {
+inside = true;
+  }
+}
+if (edgeIntersectsBox(bx, by, cx, cy, minLon, maxLon, minLat, maxLat) == 
true) {
+  if (bc == true) {
+return EdgeTree.WithinRelation.CROSSES;
+  } else {
+inside = true;
+  }
+}
+if (edgeIntersectsBox(cx, cy, ax, ay, minLon, maxLon, minLat, maxLat) == 
true) {
+  if (ca == true) {
+return EdgeTree.WithinRelation.CROSSES;
+  } else {
+inside = true;
+  }
+}
+//if any of the edges crosses and edge that does not belong to the polygon
+// then it is a candidate for within
+if (inside == true) {
+  return EdgeTree.WithinRelation.CANDIDATE;
+}
+
+// Check if the rectangle is fully within the triangle, if not then the 
relationship is undefined.
+// compute bounding box of triangle
+int tMinX = StrictMath.min(StrictMath.min(ax, bx), cx);
+int tMaxX = StrictMath.max(StrictMath.max(ax, bx), cx);
+int tMinY = StrictMath.min(StrictMath.min(ay, by), cy);
+int tMaxY = StrictMath.max(StrictMath.max(ay, by), cy);
+if ((tMinX <= minLon && tMaxX >= maxLon && tMinY <= minLat && tMaxY >= 
maxLat) == false) {
+  return EdgeTree.WithinRelation.DISJOINT;
+}
+//We check the min and max points, if true it is inside
 
 Review comment:
   we only check the min point?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-23 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r250140096
 
 

 ##
 File path: 
lucene/sandbox/src/java/org/apache/lucene/document/LatLonShapeQuery.java
 ##
 @@ -43,7 +44,7 @@
  * Base LatLonShape Query class providing common query logic for
  * {@link LatLonShapeBoundingBoxQuery} and {@link LatLonShapePolygonQuery}
  *
- * Note: this class implements the majority of the INTERSECTS, WITHIN, 
DISJOINT relation logic
+ * Note: this class implements the majority of the CROSSES, WITHIN, DISJOINT 
relation logic
 
 Review comment:
   bad search/replace? also add CONTAINS to the list?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-23 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r250132578
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/geo/Rectangle2D.java
 ##
 @@ -148,6 +148,90 @@ public boolean intersectsTriangle(int aX, int aY, int bX, 
int bY, int cX, int cY
 return false;
   }
 
+  /**
+   *  Checks if the shape is within the provided triangle.
+   *
+   * @param ax longitude of point a of the triangle
+   * @param ay latitude of point a of the triangle
+   * @param ab if edge ab belongs to the original shape
+   * @param bx longitude of point b of the triangle
+   * @param by latitude of point b of the triangle
+   * @param bc if edge bc belongs to the original shape
+   * @param cx longitude of point c of the triangle
+   * @param cy latitude of point c of the triangle
+   * @param ca if edge ca belongs to the original shape
+   * @return the {@link EdgeTree.WithinRelation}
+   */
+  public EdgeTree.WithinRelation withinTriangle(int ax, int ay, boolean ab, 
int bx, int by, boolean bc, int cx, int cy, boolean ca) {
+if (this.crossesDateline() == true) {
+  //Triangles cannot cross the date line so it is always false
+  return EdgeTree.WithinRelation.CROSSES;
+}
+// compute bounding box of triangle
+int tMinX = StrictMath.min(StrictMath.min(ax, bx), cx);
+int tMaxX = StrictMath.max(StrictMath.max(ax, bx), cx);
+int tMinY = StrictMath.min(StrictMath.min(ay, by), cy);
+int tMaxY = StrictMath.max(StrictMath.max(ay, by), cy);
+if (boxesAreDisjoint(tMinX, tMaxX, tMinY, tMaxY,  minX, maxX, minY, maxY)) 
{
+  return EdgeTree.WithinRelation.DISJOINT;
+}
+
+return bboxWithinTriangle(ax, ay, ab, bx, by, bc, cx, cy, ca, minX, maxX, 
minY, maxY);
+  }
+  public EdgeTree.WithinRelation bboxWithinTriangle(int ax, int ay, boolean 
ab, int bx, int by, boolean bc, int cx, int cy, boolean ca, int minLon, int 
maxLon, int minLat, int maxLat) {
+//points belong to the shape so if points are inside the rectangle then it 
cannot be within. It is valid if the point
+//is on the edge.
+if (bboxContainsPoint(ax, ay, minLon, maxLon, minLat, maxLat) ||
+bboxContainsPoint(bx, by, minLon, maxLon, minLat, maxLat) ||
+bboxContainsPoint(cx, cy, minLon, maxLon, minLat, maxLat)) {
+  return EdgeTree.WithinRelation.CROSSES;
+}
+//if any of the edges crosses and edge belonging to the polygon then it 
cannot be within.
+//Note that crosses is different to crosses as it needs to have points at 
both sides.
+boolean inside = false;
+if  (edgeIntersectsBox(ax, ay, bx, by, minLon, maxLon, minLat, maxLat) == 
true) {
+  if (ab == true) {
+return EdgeTree.WithinRelation.CROSSES;
+  } else {
+inside = true;
+  }
+}
+if (edgeIntersectsBox(bx, by, cx, cy, minLon, maxLon, minLat, maxLat) == 
true) {
+  if (bc == true) {
+return EdgeTree.WithinRelation.CROSSES;
+  } else {
+inside = true;
+  }
+}
+if (edgeIntersectsBox(cx, cy, ax, ay, minLon, maxLon, minLat, maxLat) == 
true) {
+  if (ca == true) {
+return EdgeTree.WithinRelation.CROSSES;
+  } else {
+inside = true;
+  }
+}
+//if any of the edges crosses and edge that does not belong to the polygon
+// then it is a candidate for within
+if (inside == true) {
+  return EdgeTree.WithinRelation.CANDIDATE;
+}
+
+// Check if the rectangle is fully within the triangle, if not then the 
relationship is undefined.
+// compute bounding box of triangle
+int tMinX = StrictMath.min(StrictMath.min(ax, bx), cx);
+int tMaxX = StrictMath.max(StrictMath.max(ax, bx), cx);
+int tMinY = StrictMath.min(StrictMath.min(ay, by), cy);
+int tMaxY = StrictMath.max(StrictMath.max(ay, by), cy);
+if ((tMinX <= minLon && tMaxX >= maxLon && tMinY <= minLat && tMaxY >= 
maxLat) == false) {
+  return EdgeTree.WithinRelation.DISJOINT;
+}
 
 Review comment:
   we don't seem to need this as this is only called from withinTriangle which 
checks this for us?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-23 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r250108261
 
 

 ##
 File path: lucene/core/src/java/org/apache/lucene/geo/EdgeTree.java
 ##
 @@ -101,6 +101,60 @@ public Relation relateTriangle(double ax, double ay, 
double bx, double by, doubl
 return Relation.CELL_OUTSIDE_QUERY;
   }
 
+  /** Used by withinTriangle to check the within relationship between a 
triangle and the query shape */
+  public enum WithinRelation {
+/** If the shape is a candidate for within. Typically this is return if 
the query shape is fully inside
+ * the triangle or if the query shape intersects only edges that do not 
belong to the original shape. */
+CANDIDATE,
+/** Return this if if the query shape intersects an edge that does belong 
to the original shape. */
+CROSSES,
+/** Return this if the query shape is disjoint with the triangle. Note 
that the query shape can still be
+ * within the indexed shape that correspond to the triangle */
+DISJOINT
+  }
+
+  /**
+   *  Checks if the shape is within the provided triangle.
+   *
+   * @param ax longitude of point a of the triangle
+   * @param ay latitude of point a of the triangle
+   * @param ab if edge ab belongs to the original shape
+   * @param bx longitude of point b of the triangle
+   * @param by latitude of point b of the triangle
+   * @param bc if edge bc belongs to the original shape
+   * @param cx longitude of point c of the triangle
+   * @param cy latitude of point c of the triangle
+   * @param ca if edge ca belongs to the original shape
+   * @return
+   */
+  public WithinRelation withinTriangle(double ax, double ay, boolean ab, 
double bx, double by, boolean bc, double cx, double cy, boolean ca) {
+// compute bounding box of triangle
+double minLat = StrictMath.min(StrictMath.min(ay, by), cy);
+double minLon = StrictMath.min(StrictMath.min(ax, bx), cx);
+double maxLat = StrictMath.max(StrictMath.max(ay, by), cy);
+double maxLon = StrictMath.max(StrictMath.max(ax, bx), cx);
+
+if (minLat <= maxY && minLon <= maxX) {
+  WithinRelation relation = internalWithinTriangle(ax, ay, ab, bx, by, bc, 
cx, cy, ca);
+  if (relation != null) {
 
 Review comment:
   internalWithinTriangle never returns null?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-23 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r250101242
 
 

 ##
 File path: lucene/core/src/java/org/apache/lucene/geo/EdgeTree.java
 ##
 @@ -101,6 +101,60 @@ public Relation relateTriangle(double ax, double ay, 
double bx, double by, doubl
 return Relation.CELL_OUTSIDE_QUERY;
   }
 
+  /** Used by withinTriangle to check the within relationship between a 
triangle and the query shape */
+  public enum WithinRelation {
+/** If the shape is a candidate for within. Typically this is return if 
the query shape is fully inside
+ * the triangle or if the query shape intersects only edges that do not 
belong to the original shape. */
+CANDIDATE,
+/** Return this if if the query shape intersects an edge that does belong 
to the original shape. */
 
 Review comment:
   update javadocs to say "crosses" instead of intersects?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-23 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r250129373
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/geo/Rectangle2D.java
 ##
 @@ -216,6 +300,11 @@ private static boolean bboxContainsPoint(int x, int y, 
int minX, int maxX, int m
 return (x < minX || x > maxX || y < minY || y > maxY) == false;
   }
 
+  /** static utility method to check if a bounding box is disjoint with a 
point */
+  private static boolean bboxContainsPointNotInEdge(int x, int y, int minX, 
int maxX, int minY, int maxY) {
 
 Review comment:
   this doesn't seem to be called anywhere?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-22 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r249791047
 
 

 ##
 File path: lucene/core/src/java/org/apache/lucene/geo/EdgeTree.java
 ##
 @@ -101,6 +101,60 @@ public Relation relateTriangle(double ax, double ay, 
double bx, double by, doubl
 return Relation.CELL_OUTSIDE_QUERY;
   }
 
+  /** Used by {@link withinTriangle} to check the relationship between a 
triangle and the query shape */
+  public enum WithinRelation {
+/** If the shape is a candidate for within. Tipically this is return if 
the query shape is fully inside
 
 Review comment:
   s/Tipically/Typically/


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-22 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r249810176
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/geo/Rectangle2D.java
 ##
 @@ -191,7 +275,7 @@ private static void encode(final int minX, final int maxX, 
final int minY, final
 NumericUtils.intToSortableBytes(maxX, b, 3 * BYTES);
   }
 
-  /** returns true if the query intersects the provided triangle (in encoded 
space) */
+  /** returns true if the query crosses the provided triangle (in encoded 
space) */
 
 Review comment:
   docs don't match the method name


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-22 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r249812595
 
 

 ##
 File path: 
lucene/sandbox/src/test/org/apache/lucene/document/TestLatLonLineShapeQueries.java
 ##
 @@ -81,35 +81,52 @@ protected Validator getValidator(QueryRelation 
queryRelation) {
 public boolean testBBoxQuery(double minLat, double maxLat, double minLon, 
double maxLon, Object shape) {
   Line line = (Line)shape;
   Rectangle2D rectangle2D = Rectangle2D.create(new Rectangle(minLat, 
maxLat, minLon, maxLon));
+  EdgeTree.WithinRelation withinRelation = 
EdgeTree.WithinRelation.DISJOINT;
   for (int i = 0, j = 1; j < line.numPoints(); ++i, ++j) {
-int[] decoded = encodeDecodeTriangle(line.getLon(i), line.getLat(i), 
line.getLon(j), line.getLat(j), line.getLon(i), line.getLat(i));
+LatLonShape.Triangle decoded = encodeDecodeTriangle(line.getLon(i), 
line.getLat(i), true, line.getLon(j), line.getLat(j), true, line.getLon(i), 
line.getLat(i), true);
 if (queryRelation == QueryRelation.WITHIN) {
-  if (rectangle2D.containsTriangle(decoded[1], decoded[0], decoded[3], 
decoded[2], decoded[5], decoded[4]) == false) {
+  if (rectangle2D.containsTriangle(decoded.aX, decoded.aY, decoded.bX, 
decoded.bY, decoded.cX, decoded.cY) == false) {
 return false;
   }
+} else if(queryRelation == QueryRelation.CONTAINS) {
+  EdgeTree.WithinRelation relation = 
rectangle2D.withinTriangle(decoded.aX, decoded.aY, decoded.ab, decoded.bX, 
decoded.bY, decoded.bc, decoded.cX, decoded.cY, decoded.ca);
+  if  (relation == EdgeTree.WithinRelation.INTERSECTS) {
 
 Review comment:
   only one space between `if` and `(`? :)


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-22 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r249795317
 
 

 ##
 File path: lucene/core/src/java/org/apache/lucene/geo/EdgeTree.java
 ##
 @@ -101,6 +101,60 @@ public Relation relateTriangle(double ax, double ay, 
double bx, double by, doubl
 return Relation.CELL_OUTSIDE_QUERY;
   }
 
+  /** Used by {@link withinTriangle} to check the relationship between a 
triangle and the query shape */
+  public enum WithinRelation {
+/** If the shape is a candidate for within. Tipically this is return if 
the query shape is fully inside
+ * the triangle or if the query shape intersects only edges that do not 
belong to the original shape. */
+CANDIDATE,
+/** Return this if if the query shape intersects an edge that does belong 
to the original shape. */
+INTERSECTS,
 
 Review comment:
   is it what we call `CROSSES` elsewhere?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-22 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r249821415
 
 

 ##
 File path: 
lucene/sandbox/src/test/org/apache/lucene/document/TestLatLonMultiPolygonShapeQueries.java
 ##
 @@ -57,6 +67,25 @@ protected ShapeType getShapeType() {
 return polygons;
   }
 
+  private boolean isDisjoint(Polygon[] polygons, List 
triangles, int totalPolygons) {
+if (totalPolygons == 0) {
+  return true;
+}
+Polygon[] currentPolygons = new Polygon[totalPolygons];
+for (int i =0; i < totalPolygons; i++) {
 
 Review comment:
   add a space between `=` and `0`?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-22 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r249810439
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/geo/Rectangle2D.java
 ##
 @@ -224,7 +313,7 @@ private static boolean bboxContainsTriangle(int ax, int 
ay, int bx, int by, int
 && bboxContainsPoint(cx, cy, minX, maxX, minY, maxY);
   }
 
-  /** returns true if the edge (defined by (ax, ay) (bx, by)) intersects the 
query */
+  /** returns true if the edge (defined by (ax, ay) (bx, by)) crosses the 
query */
 
 Review comment:
   docs don't match the method name?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-22 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r249809786
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/geo/Rectangle2D.java
 ##
 @@ -107,7 +107,7 @@ public boolean queryContainsPoint(int x, int y) {
 return eastRelation;
   }
 
-  /** Checks if the rectangle intersects the provided triangle **/
+  /** Checks if the rectangle crosses the provided triangle **/
   public boolean intersectsTriangle(int aX, int aY, int bX, int bY, int cX, 
int cY) {
 
 Review comment:
   the method name should match teh docs


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-22 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r249810206
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/geo/Rectangle2D.java
 ##
 @@ -202,7 +286,7 @@ private boolean queryIntersects(int ax, int ay, int bx, 
int by, int cx, int cy)
 return false;
   }
 
-  /** returns true if the edge (defined by (ax, ay) (bx, by)) intersects the 
query */
+  /** returns true if the edge (defined by (ax, ay) (bx, by)) crosses the 
query */
 
 Review comment:
   docs don't match the method name


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-22 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r249809936
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/geo/Rectangle2D.java
 ##
 @@ -148,6 +148,90 @@ public boolean intersectsTriangle(int aX, int aY, int bX, 
int bY, int cX, int cY
 return false;
   }
 
+  /**
+   *  Checks if the shape is within the provided triangle.
+   *
+   * @param ax longitude of point a of the triangle
+   * @param ay latitude of point a of the triangle
+   * @param ab if edge ab belongs to the original shape
+   * @param bx longitude of point b of the triangle
+   * @param by latitude of point b of the triangle
+   * @param bc if edge bc belongs to the original shape
+   * @param cx longitude of point c of the triangle
+   * @param cy latitude of point c of the triangle
+   * @param ca if edge ca belongs to the original shape
+   * @return the {@link EdgeTree.WithinRelation}
+   */
+  public EdgeTree.WithinRelation withinTriangle(int ax, int ay, boolean ab, 
int bx, int by, boolean bc, int cx, int cy, boolean ca) {
+if (this.crossesDateline() == true) {
+  //Triangles cannot cross the date line so it is always false
+  return EdgeTree.WithinRelation.INTERSECTS;
 
 Review comment:
   how do we know it's not `DISJOINT`?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-22 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r249797707
 
 

 ##
 File path: lucene/core/src/java/org/apache/lucene/geo/EdgeTree.java
 ##
 @@ -150,9 +204,88 @@ private Relation internalComponentRelateTriangle(double 
ax, double ay, double bx
 if (tree.crossesTriangle(ax, ay, bx, by, cx, cy)) {
   return Relation.CELL_CROSSES_QUERY;
 }
+if (pointInTriangle(tree.lon1, tree.lat1, ax, ay, bx, by, cx, cy) == true) 
{
+  return Relation.CELL_CROSSES_QUERY;
+}
 
 Review comment:
   This looks like an unrelated bug, let's have a dedicated issue for it?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-22 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r249807883
 
 

 ##
 File path: 
lucene/sandbox/src/java/org/apache/lucene/document/LatLonShapeBoundingBoxQuery.java
 ##
 @@ -45,23 +46,38 @@ protected Relation relateRangeBBoxToQuery(int minXOffset, 
int minYOffset, byte[]
 
   /** returns true if the query matches the encoded triangle */
   @Override
-  protected boolean queryMatches(byte[] t, int[] scratchTriangle, 
LatLonShape.QueryRelation queryRelation) {
+  protected boolean queryMatches(byte[] t, LatLonShape.Triangle 
scratchTriangle, LatLonShape.QueryRelation queryRelation) {
 // decode indexed triangle
 LatLonShape.decodeTriangle(t, scratchTriangle);
 
-int aY = scratchTriangle[0];
-int aX = scratchTriangle[1];
-int bY = scratchTriangle[2];
-int bX = scratchTriangle[3];
-int cY = scratchTriangle[4];
-int cX = scratchTriangle[5];
+int aY = scratchTriangle.aY;
+int aX = scratchTriangle.aX;
+int bY = scratchTriangle.bY;
+int bX = scratchTriangle.bX;
+int cY = scratchTriangle.cY;
+int cX = scratchTriangle.cX;
 
 if (queryRelation == LatLonShape.QueryRelation.WITHIN) {
   return rectangle2D.containsTriangle(aX, aY, bX, bY, cX, cY);
 }
 return rectangle2D.intersectsTriangle(aX, aY, bX, bY, cX, cY);
   }
 
+  @Override
+  protected EdgeTree.WithinRelation queryWithin(byte[] t, LatLonShape.Triangle 
scratchTriangle) {
+// decode indexed triangle
+LatLonShape.decodeTriangle(t, scratchTriangle);
+
+int aY = scratchTriangle.aY;
+int aX = scratchTriangle.aX;
+int bY = scratchTriangle.bY;
+int bX = scratchTriangle.bX;
+int cY = scratchTriangle.cY;
+int cX = scratchTriangle.cX;
+
+return rectangle2D.withinTriangle(aX, aY, scratchTriangle.ab, bX, bY, 
scratchTriangle.bc, cX, cY, scratchTriangle.ca);
 
 Review comment:
   extracting variables doesn't seem helpful here?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-22 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r249799963
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/document/LatLonShape.java
 ##
 @@ -118,19 +118,21 @@ public static Query newPolygonQuery(String field, 
QueryRelation queryRelation, P
* these triangles are encoded and inserted as separate indexed POINT fields
*/
   private static class LatLonTriangle extends Field {
-
+//Constructor for points and lines
 
 Review comment:
   :+1:


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[GitHub] jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape contains

2019-01-22 Thread GitBox
jpountz commented on a change in pull request #546: LUCENE-8620: LatLonShape 
contains
URL: https://github.com/apache/lucene-solr/pull/546#discussion_r249811008
 
 

 ##
 File path: 
lucene/sandbox/src/test/org/apache/lucene/document/TestLatLonLineShapeQueries.java
 ##
 @@ -81,35 +81,52 @@ protected Validator getValidator(QueryRelation 
queryRelation) {
 public boolean testBBoxQuery(double minLat, double maxLat, double minLon, 
double maxLon, Object shape) {
   Line line = (Line)shape;
   Rectangle2D rectangle2D = Rectangle2D.create(new Rectangle(minLat, 
maxLat, minLon, maxLon));
+  EdgeTree.WithinRelation withinRelation = 
EdgeTree.WithinRelation.DISJOINT;
   for (int i = 0, j = 1; j < line.numPoints(); ++i, ++j) {
-int[] decoded = encodeDecodeTriangle(line.getLon(i), line.getLat(i), 
line.getLon(j), line.getLat(j), line.getLon(i), line.getLat(i));
+LatLonShape.Triangle decoded = encodeDecodeTriangle(line.getLon(i), 
line.getLat(i), true, line.getLon(j), line.getLat(j), true, line.getLon(i), 
line.getLat(i), true);
 if (queryRelation == QueryRelation.WITHIN) {
-  if (rectangle2D.containsTriangle(decoded[1], decoded[0], decoded[3], 
decoded[2], decoded[5], decoded[4]) == false) {
+  if (rectangle2D.containsTriangle(decoded.aX, decoded.aY, decoded.bX, 
decoded.bY, decoded.cX, decoded.cY) == false) {
 return false;
   }
+} else if(queryRelation == QueryRelation.CONTAINS) {
 
 Review comment:
   let's add one space between `if` and `(`?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org