lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject lucene-solr:branch_7x: LUCENE-8056: Use perpendicular bounding planes for segments of exact circles.
Date Wed, 22 Nov 2017 11:52:32 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 82455bfce -> 183d6d67b


LUCENE-8056: Use perpendicular bounding planes for segments of exact circles.


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

Branch: refs/heads/branch_7x
Commit: 183d6d67bce4d34f7b3851f8e26f6ba6af19280a
Parents: 82455bf
Author: Karl Wright <DaddyWri@gmail.com>
Authored: Wed Nov 22 06:51:19 2017 -0500
Committer: Karl Wright <DaddyWri@gmail.com>
Committed: Wed Nov 22 06:52:20 2017 -0500

----------------------------------------------------------------------
 lucene/CHANGES.txt                              |  3 +++
 .../lucene/spatial3d/geom/GeoExactCircle.java   | 24 ++++++++------------
 .../lucene/spatial3d/geom/GeoCircleTest.java    | 15 +++++++++++-
 3 files changed, 27 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/183d6d67/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index fc41d27..60125ad 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -38,6 +38,9 @@ New Features
 
 Bug Fixes
 
+* LUCENE-8056: Exact circle segment bounding suffered from precision errors.
+  (Karl Wright)
+
 * LUCENE-8054: Fix the exact circle case where relationships fail when the
   planet model has c <= ab, because the planes are constructed incorrectly.
   (Ignacio Vera)

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/183d6d67/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoExactCircle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoExactCircle.java
b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoExactCircle.java
index cedcab5..bbd1ff0 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoExactCircle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoExactCircle.java
@@ -145,7 +145,9 @@ class GeoExactCircle extends GeoBaseCircle {
     // If it turns out that there's only one circle plane, this array will be populated but
unused
     final List<GeoPoint[]> notableEdgePoints = new ArrayList<>(activeSlices.size());
     // Back planes
-    final List<Membership> backPlanes = new ArrayList<>(activeSlices.size());
+    final Map<Membership, Membership> backPlanes = new HashMap<>(activeSlices.size());
+    // Bounds
+    final Map<Membership, Membership> bounds = new HashMap<>(activeSlices.size());
     
     // Compute bounding planes and actual circle planes
     for (int i = 0; i < activeSlices.size(); i++) {
@@ -198,13 +200,15 @@ class GeoExactCircle extends GeoBaseCircle {
       }
       
       circlePlanes.add(pd.plane);
-      backPlanes.add(backPlane);
+      if (backPlane != null) {
+        backPlanes.put(pd.plane, backPlane);
+      }
       notableEdgePoints.add(new GeoPoint[]{pd.endPoint1, pd.endPoint2});
+      bounds.put(pd.plane, new EitherBound(new SidedPlane(pd.onSidePoint, pd.endPoint1, center),
new SidedPlane(pd.onSidePoint, pd.endPoint2, center)));
     }
 
     //System.out.println("Number of planes needed: "+circlePlanes.size());
       
-    this.edgePoints = new GeoPoint[]{edgePoint};      
     this.circlePlanes = circlePlanes;
     // Compute bounds
     if (circlePlanes.size() == 1) {
@@ -213,19 +217,11 @@ class GeoExactCircle extends GeoBaseCircle {
       this.notableEdgePoints = null;
     } else {
       this.notableEdgePoints = notableEdgePoints;
-      this.backBounds = new HashMap<>(circlePlanes.size());
-      this.eitherBounds = new HashMap<>(circlePlanes.size());
-      for (int i = 0; i < circlePlanes.size(); i++) {
-        final SidedPlane thisPlane = circlePlanes.get(i);
-        final SidedPlane previousPlane = (i == 0)?circlePlanes.get(circlePlanes.size()-1):circlePlanes.get(i-1);
-        final SidedPlane nextPlane = (i == circlePlanes.size()-1)?circlePlanes.get(0):circlePlanes.get(i+1);
-        if (backPlanes.get(i) != null) {
-          backBounds.put(thisPlane, backPlanes.get(i));
-        }
-        eitherBounds.put(thisPlane, new EitherBound(previousPlane, nextPlane));
-      }
+      this.eitherBounds = bounds;
+      this.backBounds = backPlanes;
     }
     
+    this.edgePoints = new GeoPoint[]{edgePoint};      
     //System.out.println("Is edgepoint within? "+isWithin(edgePoint));
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/183d6d67/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoCircleTest.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoCircleTest.java
b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoCircleTest.java
index 9206e4f..d203b09 100755
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoCircleTest.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoCircleTest.java
@@ -520,5 +520,18 @@ public class GeoCircleTest extends LuceneTestCase {
     int rel = circle1.getRelationship(circle2);
     assertTrue(rel != GeoArea.DISJOINT);
   }
-  
+
+  @Test
+  public void testLUCENE8056(){
+    GeoCircle circle = GeoCircleFactory.makeExactGeoCircle(PlanetModel.WGS84, 0.647941905154693,
0.8542472362428436, 0.8917883700569315, 1.2173787103955335E-8);
+    GeoBBox bBox = GeoBBoxFactory.makeGeoBBox(PlanetModel.WGS84, 0.5890486225480862, 0.4908738521234052,
1.9634954084936207, 2.159844949342983);
+    //Center iis out of the shape
+    assertFalse(circle.isWithin(bBox.getCenter()));
+    //Edge point is in the shape
+    assertTrue(circle.isWithin(bBox.getEdgePoints()[0]));
+    //Shape should intersect!!!
+    assertTrue(bBox.getRelationship(circle) == GeoArea.OVERLAPS);
+  }
+
+
 }


Mime
View raw message