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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]