lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [13/41] lucene-solr:jira/solr-11285-sim: LUCENE-8057: getBounds() for exact circle did not include segment endpoints.
Date Tue, 28 Nov 2017 09:23:24 GMT
LUCENE-8057: getBounds() for exact circle did not include segment endpoints.


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

Branch: refs/heads/jira/solr-11285-sim
Commit: 9776e1f4a0a6dc085c47c2204f4032d3f9e947aa
Parents: d0d8a75
Author: Karl Wright <DaddyWri@gmail.com>
Authored: Wed Nov 22 11:07:52 2017 -0500
Committer: Karl Wright <DaddyWri@gmail.com>
Committed: Wed Nov 22 11:07:52 2017 -0500

----------------------------------------------------------------------
 .../lucene/spatial3d/geom/GeoExactCircle.java    |  7 ++++++-
 .../lucene/spatial3d/geom/GeoCircleTest.java     | 19 ++++++++++++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9776e1f4/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 bbd1ff0..8bba244 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
@@ -356,8 +356,13 @@ class GeoExactCircle extends GeoBaseCircle {
       return;
     }
     // Add bounds for all circle planes
-    for (final SidedPlane plane : circlePlanes) {
+    for (int edgeIndex = 0; edgeIndex < circlePlanes.size(); edgeIndex++) {
+      final SidedPlane plane = circlePlanes.get(edgeIndex);
       bounds.addPlane(planetModel, plane, eitherBounds.get(plane));
+      final GeoPoint[] points = notableEdgePoints.get(edgeIndex);
+      for (final GeoPoint point : points) {
+        bounds.addPoint(point);
+      }
       // We don't bother to compute the intersection bounds since, unless the planet model
is pathological, we expect planes to be intersecting at shallow
       // angles.
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9776e1f4/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 d203b09..3f35ef3 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
@@ -533,5 +533,22 @@ public class GeoCircleTest extends LuceneTestCase {
     assertTrue(bBox.getRelationship(circle) == GeoArea.OVERLAPS);
   }
 
-
+  @Test
+  public void testExactCircleBounds() {
+
+    GeoPoint center = new GeoPoint(PlanetModel.WGS84, 0, 0);
+    // Construct four cardinal points, and then we'll build the first two planes
+    final GeoPoint northPoint = PlanetModel.WGS84.surfacePointOnBearing(center, 1, 0.0);
+    final GeoPoint southPoint = PlanetModel.WGS84.surfacePointOnBearing(center, 1, Math.PI);
+    final GeoPoint eastPoint = PlanetModel.WGS84.surfacePointOnBearing(center, 1, Math.PI
* 0.5);
+    final GeoPoint westPoint = PlanetModel.WGS84.surfacePointOnBearing(center, 1, Math.PI
* 1.5);
+
+    GeoCircle circle = GeoCircleFactory.makeExactGeoCircle(PlanetModel.WGS84, 0, 0, 1, 1e-6);
+    LatLonBounds bounds = new LatLonBounds();
+    circle.getBounds(bounds);
+    assertEquals(northPoint.getLatitude(), bounds.getMaxLatitude(), 1e-2);
+    assertEquals(southPoint.getLatitude(), bounds.getMinLatitude(), 1e-2);
+    assertEquals(westPoint.getLongitude(), bounds.getLeftLongitude(), 1e-2);
+    assertEquals(eastPoint.getLongitude(), bounds.getRightLongitude(), 1e-2);
+  }
 }


Mime
View raw message