You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2015/05/06 20:50:59 UTC
svn commit: r1678060 - in /lucene/dev/branches/branch_5x: ./ lucene/
lucene/spatial/ lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/
Author: dsmiley
Date: Wed May 6 18:50:59 2015
New Revision: 1678060
URL: http://svn.apache.org/r1678060
Log:
LUCENE-6196: Fix RandomizedShapeTestCase.randomPointIn(Shape)
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/lucene/ (props changed)
lucene/dev/branches/branch_5x/lucene/spatial/ (props changed)
lucene/dev/branches/branch_5x/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RandomizedShapeTestCase.java
lucene/dev/branches/branch_5x/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RectIntersectionTestHelper.java
Modified: lucene/dev/branches/branch_5x/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RandomizedShapeTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RandomizedShapeTestCase.java?rev=1678060&r1=1678059&r2=1678060&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RandomizedShapeTestCase.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RandomizedShapeTestCase.java Wed May 6 18:50:59 2015
@@ -272,15 +272,17 @@ public abstract class RandomizedShapeTes
return p;
}
- protected Point randomPointIn(Shape shape) {
+ protected Point randomPointInOrNull(Shape shape) {
if (!shape.hasArea())// or try the center?
throw new UnsupportedOperationException("Need area to define shape!");
Rectangle bbox = shape.getBoundingBox();
- Point p;
- do {
- p = randomPointIn(bbox);
- } while (!bbox.relate(p).intersects());
- return p;
+ for (int i = 0; i < 1000; i++) {
+ Point p = randomPointIn(bbox);
+ if (shape.relate(p).intersects()) {
+ return p;
+ }
+ }
+ return null;//tried too many times and failed
}
}
Modified: lucene/dev/branches/branch_5x/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RectIntersectionTestHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RectIntersectionTestHelper.java?rev=1678060&r1=1678059&r2=1678060&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RectIntersectionTestHelper.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RectIntersectionTestHelper.java Wed May 6 18:50:59 2015
@@ -72,13 +72,13 @@ public abstract class RectIntersectionTe
@SuppressWarnings("unchecked")
@Override
- protected Point randomPointIn(Shape shape) {
+ protected Point randomPointInOrNull(Shape shape) {
if (!shape.hasArea()) {
final Point pt = randomPointInEmptyShape((S) shape);
assert shape.relate(pt).intersects() : "faulty randomPointInEmptyShape";
return pt;
}
- return super.randomPointIn(shape);
+ return super.randomPointInOrNull(shape);
}
public void testRelateWithRectangle() {
@@ -132,7 +132,10 @@ public abstract class RectIntersectionTe
case WITHIN:
i_W++;
for (int j = 0; j < MAX_TRIES; j++) {
- Point p = randomPointIn(s);
+ Point p = randomPointInOrNull(s);
+ if (p == null) {//couldn't find a random point in shape
+ break;
+ }
assertRelation(null, CONTAINS, r, p);
}
break;