You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kw...@apache.org on 2016/04/15 13:15:25 UTC

lucene-solr:branch_6x: LUCENE-7221: Do not attempt to carve out holes from bounds.

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 22df9fc3b -> 6ec124446


LUCENE-7221: Do not attempt to carve out holes from bounds.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6ec12444
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6ec12444
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6ec12444

Branch: refs/heads/branch_6x
Commit: 6ec124446790d81f79bf76f0f589a9bf81de08e0
Parents: 22df9fc
Author: Karl Wright <Da...@gmail.com>
Authored: Fri Apr 15 07:11:15 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Fri Apr 15 07:13:19 2016 -0400

----------------------------------------------------------------------
 .../spatial3d/geom/GeoConcavePolygon.java       | 50 ++++++++++++++++----
 .../lucene/spatial3d/geom/GeoConvexPolygon.java | 40 ++++++++++++++--
 2 files changed, 76 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6ec12444/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
index b28ebd2..124b46b 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
@@ -258,15 +258,7 @@ class GeoConcavePolygon extends GeoBasePolygon {
 
   @Override
   public boolean isWithin(final double x, final double y, final double z) {
-    // If present within *any* plane, then it is a member, except where there are holes.
-    boolean isMember = false;
-    for (final SidedPlane edge : edges) {
-      if (edge.isWithin(x, y, z)) {
-        isMember = true;
-        break;
-      }
-    }
-    if (isMember == false) {
+    if (!localIsWithin(x, y, z)) {
       return false;
     }
     if (holes != null) {
@@ -279,6 +271,22 @@ class GeoConcavePolygon extends GeoBasePolygon {
     return true;
   }
 
+  protected boolean localIsWithin(final Vector v) {
+    return localIsWithin(v.x, v.y, v.z);
+  }
+
+  protected boolean localIsWithin(final double x, final double y, final double z) {
+    // If present within *any* plane, then it is a member, except where there are holes.
+    boolean isMember = false;
+    for (final SidedPlane edge : edges) {
+      if (edge.isWithin(x, y, z)) {
+        isMember = true;
+        break;
+      }
+    }
+    return isMember;
+  }
+
   @Override
   public GeoPoint[] getEdgePoints() {
     return edgePoints;
@@ -341,7 +349,28 @@ class GeoConcavePolygon extends GeoBasePolygon {
 
   @Override
   public void getBounds(Bounds bounds) {
-    super.getBounds(bounds);
+    // Because of holes, we don't want to use superclass method
+    if (localIsWithin(planetModel.NORTH_POLE)) {
+      bounds.noTopLatitudeBound().noLongitudeBound()
+        .addPoint(planetModel.NORTH_POLE);
+    }
+    if (localIsWithin(planetModel.SOUTH_POLE)) {
+      bounds.noBottomLatitudeBound().noLongitudeBound()
+        .addPoint(planetModel.SOUTH_POLE);
+    }
+    if (localIsWithin(planetModel.MIN_X_POLE)) {
+      bounds.addPoint(planetModel.MIN_X_POLE);
+    }
+    if (localIsWithin(planetModel.MAX_X_POLE)) {
+      bounds.addPoint(planetModel.MAX_X_POLE);
+    }
+    if (localIsWithin(planetModel.MIN_Y_POLE)) {
+      bounds.addPoint(planetModel.MIN_Y_POLE);
+    }
+    if (localIsWithin(planetModel.MAX_Y_POLE)) {
+      bounds.addPoint(planetModel.MAX_Y_POLE);
+    }
+
     bounds.isWide();
 
     // Add all the points
@@ -353,6 +382,7 @@ class GeoConcavePolygon extends GeoBasePolygon {
     for (final SidedPlane edge : edges) {
       bounds.addPlane(planetModel, edge, eitherBounds.get(edge));
     }
+    
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6ec12444/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
index 890df30..c51ae82 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
@@ -253,9 +253,8 @@ class GeoConvexPolygon extends GeoBasePolygon {
 
   @Override
   public boolean isWithin(final double x, final double y, final double z) {
-    for (final SidedPlane edge : edges) {
-      if (!edge.isWithin(x, y, z))
-        return false;
+    if (!localIsWithin(x, y, z)) {
+      return false;
     }
     if (holes != null) {
       for (final GeoPolygon polygon : holes) {
@@ -266,7 +265,19 @@ class GeoConvexPolygon extends GeoBasePolygon {
     }
     return true;
   }
+  
+  protected boolean localIsWithin(final Vector v) {
+    return localIsWithin(v.x, v.y, v.z);
+  }
 
+  protected boolean localIsWithin(final double x, final double y, final double z) {
+    for (final SidedPlane edge : edges) {
+      if (!edge.isWithin(x, y, z))
+        return false;
+    }
+    return true;
+  }
+  
   @Override
   public GeoPoint[] getEdgePoints() {
     return edgePoints;
@@ -328,7 +339,27 @@ class GeoConvexPolygon extends GeoBasePolygon {
 
   @Override
   public void getBounds(Bounds bounds) {
-    super.getBounds(bounds);
+    // Because of holes, we don't want to use superclass method
+    if (localIsWithin(planetModel.NORTH_POLE)) {
+      bounds.noTopLatitudeBound().noLongitudeBound()
+        .addPoint(planetModel.NORTH_POLE);
+    }
+    if (localIsWithin(planetModel.SOUTH_POLE)) {
+      bounds.noBottomLatitudeBound().noLongitudeBound()
+        .addPoint(planetModel.SOUTH_POLE);
+    }
+    if (localIsWithin(planetModel.MIN_X_POLE)) {
+      bounds.addPoint(planetModel.MIN_X_POLE);
+    }
+    if (localIsWithin(planetModel.MAX_X_POLE)) {
+      bounds.addPoint(planetModel.MAX_X_POLE);
+    }
+    if (localIsWithin(planetModel.MIN_Y_POLE)) {
+      bounds.addPoint(planetModel.MIN_Y_POLE);
+    }
+    if (localIsWithin(planetModel.MAX_Y_POLE)) {
+      bounds.addPoint(planetModel.MAX_Y_POLE);
+    }
 
     // Add all the points
     for (final GeoPoint point : points) {
@@ -339,6 +370,7 @@ class GeoConvexPolygon extends GeoBasePolygon {
     for (final SidedPlane edge : edges) {
       bounds.addPlane(planetModel, edge, eitherBounds.get(edge));
     }
+    
   }
 
   @Override