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:
[email protected]


With regards,
Apache Git Services

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

Reply via email to