lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject lucene-solr:master: LUCENE-7241: Various changes towards making GeoComplexPolygon fully testable.
Date Sun, 01 May 2016 13:35:14 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master 7bc4859da -> ccc9057ea


LUCENE-7241: Various changes towards making GeoComplexPolygon fully testable.


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

Branch: refs/heads/master
Commit: ccc9057ea0bd68ecadce25dec920deef248c2e10
Parents: 7bc4859
Author: Karl Wright <DaddyWri@gmail.com>
Authored: Sun May 1 09:35:00 2016 -0400
Committer: Karl Wright <DaddyWri@gmail.com>
Committed: Sun May 1 09:35:00 2016 -0400

----------------------------------------------------------------------
 .../spatial3d/geom/GeoComplexPolygon.java       | 28 +++++++++++++++++++-
 .../spatial3d/geom/GeoPolygonFactory.java       |  6 ++++-
 .../apache/lucene/spatial3d/TestGeo3DPoint.java | 25 +++++++++--------
 3 files changed, 46 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ccc9057e/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java
b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java
index ffd39e9..f3bc115 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java
@@ -1225,7 +1225,33 @@ class GeoComplexPolygon extends GeoBasePolygon {
 
   @Override
   public String toString() {
-    return "GeoComplexPolygon: {planetmodel=" + planetModel + ", number of shapes="+shapeStartEdges.length+",
address="+ Integer.toHexString(hashCode())+"}";
+    final StringBuilder edgeDescription = new StringBuilder();
+    for (final Edge shapeStartEdge : shapeStartEdges) {
+      fillInEdgeDescription(edgeDescription, shapeStartEdge);
+    }
+    return "GeoComplexPolygon: {planetmodel=" + planetModel + ", number of shapes="+shapeStartEdges.length+",
address="+ Integer.toHexString(hashCode())+", testPoint="+testPoint+", testPointInSet="+testPointInSet+",
shapes={"+edgeDescription+"}}";
   }
+  
+  private static void fillInEdgeDescription(final StringBuilder description, final Edge startEdge)
{
+    description.append(" {");
+    Edge currentEdge = startEdge;
+    int edgeCounter = 0;
+    while (true) {
+      if (edgeCounter > 0) {
+        description.append(", ");
+      }
+      if (edgeCounter >= 20) {
+        description.append("...");
+        break;
+      }
+      description.append(currentEdge.startPoint);
+      currentEdge = currentEdge.next;
+      if (currentEdge == startEdge) {
+        break;
+      }
+      edgeCounter++;
+    }
+  }
+  
 }
   

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ccc9057e/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
index 91eb339..a4499ee 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
@@ -502,7 +502,11 @@ public class GeoPolygonFactory {
     final GeoPoint closePoint = points.get(pointIndex);
     // We pick a random angle and random arc distance, then generate a point based on closePoint
     final double angle = generator.nextDouble() * Math.PI * 2.0 - Math.PI;
-    final double maxArcDistance = points.get(0).arcDistance(points.get(1));
+    double maxArcDistance = points.get(0).arcDistance(points.get(1));
+    double trialArcDistance = points.get(0).arcDistance(points.get(2));
+    if (trialArcDistance > maxArcDistance) {
+      maxArcDistance = trialArcDistance;
+    }
     final double arcDistance = maxArcDistance - generator.nextDouble() * maxArcDistance;
     // We come up with a unit circle (x,y,z) coordinate given the random angle and arc distance.
 The point is centered around the positive x axis.
     final double x = Math.cos(arcDistance);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ccc9057e/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
index 2028c36..c977c9e 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
@@ -925,8 +925,8 @@ public class TestGeo3DPoint extends LuceneTestCase {
           angles[i] = angle;
           accumulatedAngle += angle;
         }
-        // Pick the arc distance randomly
-        arcDistance[i] = random().nextDouble() * (Math.PI - MINIMUM_ARC_ANGLE) + MINIMUM_ARC_ANGLE;
+        // Pick the arc distance randomly; not quite the full range though
+        arcDistance[i] = random().nextDouble() * (Math.PI * 0.5 - MINIMUM_ARC_ANGLE) + MINIMUM_ARC_ANGLE;
       }
       if (clockwiseDesired) {
         // Reverse the signs
@@ -938,6 +938,15 @@ public class TestGeo3DPoint extends LuceneTestCase {
       // Now, use the pole's information plus angles and arcs to create GeoPoints in the
right order.
       final List<GeoPoint> polyPoints = convertToPoints(pm, pole, angles, arcDistance);
       
+      // Next, do some holes.  No more than 2 of these.  The poles for holes must always
be within the polygon, so we're
+      // going to use Geo3D to help us select those given the points we just made.
+      
+      final int holeCount = createHoles?TestUtil.nextInt(random(), 0, 2):0;
+      
+      final List<Polygon> holeList = new ArrayList<>();
+      
+      /* Hole logic is broken and needs rethinking
+      
       // Create the geo3d polygon, so we can test out our poles.
       final GeoPolygon poly;
       try {
@@ -946,14 +955,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
         // This is what happens when three adjacent points are colinear, so try again.
         continue;
       }
-      
-      // Next, do some holes.  No more than 2 of these.  The poles for holes must always
be within the polygon, so we're
-      // going to use Geo3D to help us select those given the points we just made.
-      
-      final int holeCount = createHoles?TestUtil.nextInt(random(), 0, 2):0;
-      
-      final List<Polygon> holeList = new ArrayList<>();
-      
+            
       for (int i = 0; i < holeCount; i++) {
         // Choose a pole.  The poly has to be within the polygon, but it also cannot be on
the polygon edge.
         // If we can't find a good pole we have to give it up and not do the hole.
@@ -979,7 +981,8 @@ public class TestGeo3DPoint extends LuceneTestCase {
           }
         }
       }
-
+      */
+      
       final Polygon[] holes = holeList.toArray(new Polygon[0]);
       
       // Finally, build the polygon and return it


Mime
View raw message