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 2017/09/14 07:53:45 UTC

lucene-solr:branch_6x: LUCENE-7906: Fix random shape generator. Committed on behalf of Ignacio Vera.

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x bdd291824 -> 1ed0d4e5f


LUCENE-7906: Fix random shape generator.  Committed on behalf of Ignacio Vera.


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

Branch: refs/heads/branch_6x
Commit: 1ed0d4e5fb24ee82d3c0931051ead663d468ec62
Parents: bdd2918
Author: Karl Wright <Da...@gmail.com>
Authored: Thu Sep 14 03:51:54 2017 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Thu Sep 14 03:53:38 2017 -0400

----------------------------------------------------------------------
 .../geom/RandomGeo3dShapeGenerator.java         | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1ed0d4e5/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomGeo3dShapeGenerator.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomGeo3dShapeGenerator.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomGeo3dShapeGenerator.java
index 72b7109..d41bf1b 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomGeo3dShapeGenerator.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomGeo3dShapeGenerator.java
@@ -174,13 +174,13 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
   public GeoPoint randomGeoPoint(PlanetModel planetModel, Constraints constraints) {
     int iterations = 0;
     while (iterations < MAX_POINT_ITERATIONS) {
-      double lat = randomDouble();
-      if (Math.PI/2 - Math.abs(lat)  <0){
-        continue;
+      double lat = randomDouble() * Math.PI/2;
+      if (random().nextBoolean()) {
+        lat = (-1)*lat;
       }
-      double lon =  randomDouble();
-      if (Math.PI - Math.abs(lat)   <0){
-        continue;
+      double lon =  randomDouble() * Math.PI;
+      if (random().nextBoolean()) {
+        lon = (-1)*lon;
       }
       iterations++;
       GeoPoint point = new GeoPoint(planetModel, lat, lon);
@@ -810,13 +810,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
    * @return the cutoff angle.
    */
   private double randomCutoffAngle() {
-    while(true) {
-      double radius = randomDouble();
-      if (radius <0 || radius > Math.PI){
-        continue;
-      }
-      return radius;
-    }
+    return randomDouble() * Math.PI;
   }
 
   /**