You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2019/11/26 16:28:29 UTC

[GitHub] [lucene-solr] jpountz commented on a change in pull request #1040: LUCENE-9067: Polygon2D#contains is now thread safe

jpountz commented on a change in pull request #1040: LUCENE-9067: Polygon2D#contains is now thread safe
URL: https://github.com/apache/lucene-solr/pull/1040#discussion_r350848040
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/geo/EdgeTree.java
 ##########
 @@ -90,30 +102,34 @@
   // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
   // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   // IN THE SOFTWARE.
-  protected boolean contains(double x, double y, AtomicBoolean isOnEdge) {
-    boolean res = false;
-    if (isOnEdge.get() == false && y <= this.max) {
+  private byte containsPnPoly(double x, double y) {
+    byte res = FALSE;
+    if (y <= this.max) {
       if (y == this.y1 && y == this.y2 ||
           (y <= this.y1 && y >= this.y2) != (y >= this.y1 && y <= this.y2)) {
         if ((x == this.x1 && x == this.x2) ||
             ((x <= this.x1 && x >= this.x2) != (x >= this.x1 && x <= this.x2) &&
                 GeoUtils.orient(this.x1, this.y1, this.x2, this.y2, x, y) == 0)) {
-          // if its on the boundary return true
-          isOnEdge.set(true);
-          return true;
+          return ON_EDGE;
         } else if (this.y1 > y != this.y2 > y) {
-          res = x < (this.x2 - this.x1) * (y - this.y1) / (this.y2 - this.y1) + this.x1;
+          res = x < (this.x2 - this.x1) * (y - this.y1) / (this.y2 - this.y1) + this.x1 ? TRUE : FALSE;
         }
       }
       if (this.left != null) {
-        res ^= left.contains(x, y, isOnEdge);
+        res ^= left.containsPnPoly(x, y);
+        if (((res >> 1) & 1) == 1) {
 
 Review comment:
   
   ```suggestion
           if ((res & 0x02) == 0x02) {
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org