Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 539C4200D5C for ; Fri, 1 Dec 2017 02:53:19 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 52095160C04; Fri, 1 Dec 2017 01:53:19 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 721A7160C01 for ; Fri, 1 Dec 2017 02:53:18 +0100 (CET) Received: (qmail 48784 invoked by uid 500); 1 Dec 2017 01:53:17 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 48775 invoked by uid 99); 1 Dec 2017 01:53:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Dec 2017 01:53:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7BD4DF17E4; Fri, 1 Dec 2017 01:53:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kwright@apache.org To: commits@lucene.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: lucene-solr:branch_6x: LUCENE-8070: Put in a check that prevents a bogus exact circle from being created. Date: Fri, 1 Dec 2017 01:53:17 +0000 (UTC) archived-at: Fri, 01 Dec 2017 01:53:19 -0000 Repository: lucene-solr Updated Branches: refs/heads/branch_6x aa9123913 -> 8a385a07e LUCENE-8070: Put in a check that prevents a bogus exact circle from being created. Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/8a385a07 Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/8a385a07 Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/8a385a07 Branch: refs/heads/branch_6x Commit: 8a385a07e4bfb5c6600f6cf45052785351ff790d Parents: aa91239 Author: Karl Wright Authored: Thu Nov 30 20:51:50 2017 -0500 Committer: Karl Wright Committed: Thu Nov 30 20:53:08 2017 -0500 ---------------------------------------------------------------------- .../apache/lucene/spatial3d/geom/GeoExactCircle.java | 7 ++++--- .../org/apache/lucene/spatial3d/geom/PlanetModel.java | 3 +++ .../lucene/spatial3d/geom/GeoExactCircleTest.java | 12 ++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8a385a07/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 54c23c5..1d14ce0 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 @@ -62,7 +62,9 @@ class GeoExactCircle extends GeoBaseCircle { throw new IllegalArgumentException("Cutoff angle out of bounds"); if (cutoffAngle < Vector.MINIMUM_RESOLUTION) throw new IllegalArgumentException("Cutoff angle cannot be effectively zero"); - + if (planetModel.minimumPoleDistance - cutoffAngle < Vector.MINIMUM_RESOLUTION) + throw new IllegalArgumentException("Cutoff angle out of bounds. It cannot be bigger than " + planetModel.minimumPoleDistance + " for this planet model"); + this.center = new GeoPoint(planetModel, lat, lon); this.cutoffAngle = cutoffAngle; @@ -310,7 +312,7 @@ class GeoExactCircle extends GeoBaseCircle { // Construct the plane going through the three given points this.plane = SidedPlane.constructNormalizedThreePointSidedPlane(center, endPoint1, endPoint2, middlePoint); if (this.plane == null) { - throw new IllegalArgumentException("Either circle is too large to fit on ellipsoid or accuracy is too high; could not construct a plane with endPoint1="+endPoint1+" bearing "+point1Bearing+", endPoint2="+endPoint2+" bearing "+point2Bearing+", middle="+middlePoint+" bearing "+middlePointBearing); + throw new IllegalArgumentException("Either circle is too small or accuracy is too high; could not construct a plane with endPoint1="+endPoint1+" bearing "+point1Bearing+", endPoint2="+endPoint2+" bearing "+point2Bearing+", middle="+middlePoint+" bearing "+middlePointBearing); } if (plane.isWithin(center) == false || !plane.evaluateIsZero(endPoint1) || !plane.evaluateIsZero(endPoint2) || !plane.evaluateIsZero(middlePoint)) throw new IllegalStateException("SidedPlane constructor built a bad plane!!"); @@ -322,7 +324,6 @@ class GeoExactCircle extends GeoBaseCircle { " end point 2 = " + endPoint2 + " bearing 2 = " + point2Bearing + " middle point = " + middlePoint + " middle bearing = " + middlePointBearing + "}"; } - } /** A description of a section of circle. http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8a385a07/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetModel.java ---------------------------------------------------------------------- diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetModel.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetModel.java index b1b39c3..37297d3 100644 --- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetModel.java +++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetModel.java @@ -77,6 +77,8 @@ public class PlanetModel implements SerializableObject { public final GeoPoint MIN_Y_POLE; /** Max Y pole */ public final GeoPoint MAX_Y_POLE; + /** Minimum surface distance between poles */ + public final double minimumPoleDistance; /** Constructor. * @param ab is the x/y scaling factor. @@ -97,6 +99,7 @@ public class PlanetModel implements SerializableObject { this.MAX_X_POLE = new GeoPoint(ab, 1.0, 0.0, 0.0, 0.0, 0.0); this.MIN_Y_POLE = new GeoPoint(ab, 0.0, -1.0, 0.0, 0.0, -Math.PI * 0.5); this.MAX_Y_POLE = new GeoPoint(ab, 0.0, 1.0, 0.0, 0.0, Math.PI * 0.5); + this.minimumPoleDistance = Math.min(surfaceDistance(NORTH_POLE, SOUTH_POLE), surfaceDistance(MIN_X_POLE, MAX_X_POLE)); } /** Deserialization constructor. http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8a385a07/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoExactCircleTest.java ---------------------------------------------------------------------- diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoExactCircleTest.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoExactCircleTest.java index 3e25bce..29dcff9 100644 --- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoExactCircleTest.java +++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoExactCircleTest.java @@ -122,6 +122,18 @@ public class GeoExactCircleTest extends RandomGeo3dShapeGenerator{ assertTrue(success); } + @Test + public void testExactCircleDoesNotFit() { + boolean exception = false; + try { + GeoCircle circle = GeoCircleFactory.makeExactGeoCircle(PlanetModel.WGS84, 1.5633796542562415, -1.0387149580695152,3.1409865861032844, 1e-12); + } catch (IllegalArgumentException e) { + exception = true; + } + assertTrue(exception); + } + + /** * in LUCENE-8054 we have problems with exact circles that have * edges that are close together. This test creates those circles with the same