You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/08/15 21:11:18 UTC
svn commit: r1696090 - in
/lucene/dev/branches/lucene6699/lucene/spatial3d/src:
java/org/apache/lucene/geo3d/dXYZSolid.java
java/org/apache/lucene/geo3d/dXdYdZSolid.java
test/org/apache/lucene/geo3d/XYZSolidTest.java
Author: mikemccand
Date: Sat Aug 15 19:11:18 2015
New Revision: 1696090
URL: http://svn.apache.org/r1696090
Log:
LUCENE-6699: more degenerate solids
Modified:
lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXYZSolid.java
lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXdYdZSolid.java
lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/XYZSolidTest.java
Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXYZSolid.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXYZSolid.java?rev=1696090&r1=1696089&r2=1696090&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXYZSolid.java (original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXYZSolid.java Sat Aug 15 19:11:18 2015
@@ -138,13 +138,14 @@ public class dXYZSolid extends BaseXYZSo
//System.err.println(this+" getrelationship with "+path);
final int insideRectangle = isShapeInsideArea(path);
if (insideRectangle == SOME_INSIDE) {
- //System.err.println(" some inside");
+ //System.err.println(" some shape points inside area");
return OVERLAPS;
}
// Figure out if the entire XYZArea is contained by the shape.
final int insideShape = isAreaInsideShape(path);
if (insideShape == SOME_INSIDE) {
+ //System.err.println(" some area points inside shape");
return OVERLAPS;
}
@@ -154,18 +155,19 @@ public class dXYZSolid extends BaseXYZSo
}
// The entire locus of points in this shape is on a single plane, so we only need ot look for an intersection with that plane.
+ System.err.println("xPlane = "+xPlane);
if (path.intersects(xPlane, notableXPoints, minYPlane, maxYPlane, minZPlane, maxZPlane)) {
//System.err.println(" edges intersect");
return OVERLAPS;
}
if (insideRectangle == ALL_INSIDE) {
- //System.err.println(" shape inside rectangle");
+ //System.err.println(" shape points inside area");
return WITHIN;
}
if (insideShape == ALL_INSIDE) {
- //System.err.println(" shape contains rectangle");
+ //System.err.println(" shape contains all area");
return CONTAINS;
}
//System.err.println(" disjoint");
Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXdYdZSolid.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXdYdZSolid.java?rev=1696090&r1=1696089&r2=1696090&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXdYdZSolid.java (original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXdYdZSolid.java Sat Aug 15 19:11:18 2015
@@ -81,13 +81,14 @@ public class dXdYdZSolid extends BaseXYZ
//System.err.println(this+" getrelationship with "+path);
final int insideRectangle = isShapeInsideArea(path);
if (insideRectangle == SOME_INSIDE) {
- //System.err.println(" some inside");
+ //System.err.println(" some shape points inside area");
return OVERLAPS;
}
// Figure out if the entire XYZArea is contained by the shape.
final int insideShape = isAreaInsideShape(path);
if (insideShape == SOME_INSIDE) {
+ //System.err.println(" some area points inside shape");
return OVERLAPS;
}
@@ -96,18 +97,13 @@ public class dXdYdZSolid extends BaseXYZ
return OVERLAPS;
}
- if (path.isWithin(thePoint)) {
- //System.err.println(" edges intersect");
- return OVERLAPS;
- }
-
if (insideRectangle == ALL_INSIDE) {
- //System.err.println(" shape inside rectangle");
+ //System.err.println(" shape inside area entirely");
return WITHIN;
}
if (insideShape == ALL_INSIDE) {
- //System.err.println(" shape contains rectangle");
+ //System.err.println(" shape contains area entirely");
return CONTAINS;
}
//System.err.println(" disjoint");
Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/XYZSolidTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/XYZSolidTest.java?rev=1696090&r1=1696089&r2=1696090&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/XYZSolidTest.java (original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/XYZSolidTest.java Sat Aug 15 19:11:18 2015
@@ -27,16 +27,15 @@ public class XYZSolidTest {
@Test
- public void testRelationships() {
+ public void testNonDegenerateRelationships() {
XYZSolid s;
GeoShape shape;
// Something bigger than the world
s = new XYZSolid(PlanetModel.SPHERE, -2.0, 2.0, -2.0, 2.0, -2.0, 2.0);
- // Any shape, including world, should be within.
+ // Any shape, except whole world, should be within.
shape = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
assertEquals(GeoArea.WITHIN, s.getRelationship(shape));
shape = new GeoWorld(PlanetModel.SPHERE);
-
// An XYZSolid represents a surface shape, which when larger than the world is in fact
// the entire world, so it should overlap the world.
assertEquals(GeoArea.OVERLAPS, s.getRelationship(shape));
@@ -67,5 +66,160 @@ public class XYZSolidTest {
}
+ @Test
+ public void testDegenerateRelationships() {
+ GeoArea solid;
+ GeoShape shape;
+
+ // Basic test of the factory method - non-degenerate
+ solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE, -2.0, 2.0, -2.0, 2.0, -2.0, 2.0);
+ // Any shape, except whole world, should be within.
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
+ assertEquals(GeoArea.WITHIN, solid.getRelationship(shape));
+ shape = new GeoWorld(PlanetModel.SPHERE);
+ // An XYZSolid represents a surface shape, which when larger than the world is in fact
+ // the entire world, so it should overlap the world.
+ assertEquals(GeoArea.OVERLAPS, solid.getRelationship(shape));
+
+ // Build a degenerate point, not on sphere
+ solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+ // disjoint with everything?
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ shape = new GeoWorld(PlanetModel.SPHERE);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+
+ // Build a degenerate point that IS on the sphere
+ solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0);
+ // inside everything that it touches?
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
+ assertEquals(GeoArea.CONTAINS, solid.getRelationship(shape));
+ shape = new GeoWorld(PlanetModel.SPHERE);
+ assertEquals(GeoArea.CONTAINS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, Math.PI, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+
+ // Build a shape degenerate in (x,y), which has no points on sphere
+ solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE, 0.0, 0.0, 0.0, 0.0, -0.1, 0.1);
+ // disjoint with everything?
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ shape = new GeoWorld(PlanetModel.SPHERE);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+
+ // Build a shape degenerate in (x,y) which has one point on sphere
+ solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE, 0.0, 0.0, 0.0, 0.0, -0.1, 1.1);
+ // inside everything that it touches?
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ shape = new GeoWorld(PlanetModel.SPHERE);
+ assertEquals(GeoArea.CONTAINS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, Math.PI * 0.5, 0.0, 0.1);
+ assertEquals(GeoArea.CONTAINS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, -Math.PI * 0.5, 0.0, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+
+ // Build a shape degenerate in (x,y) which has two points on sphere
+ solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE, 0.0, 0.0, 0.0, 0.0, -1.1, 1.1);
+ // inside everything that it touches?
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ shape = new GeoWorld(PlanetModel.SPHERE);
+ assertEquals(GeoArea.CONTAINS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, Math.PI * 0.5, 0.0, 0.1);
+ assertEquals(GeoArea.OVERLAPS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, -Math.PI * 0.5, 0.0, 0.1);
+ assertEquals(GeoArea.OVERLAPS, solid.getRelationship(shape));
+
+ // Build a shape degenerate in (x,z), which has no points on sphere
+ solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE, 0.0, 0.0, -0.1, 0.1, 0.0, 0.0);
+ // disjoint with everything?
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ shape = new GeoWorld(PlanetModel.SPHERE);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ // Build a shape degenerate in (x,z) which has one point on sphere
+ solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE, 0.0, 0.0, -0.1, 1.1, 0.0, 0.0);
+ // inside everything that it touches?
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ shape = new GeoWorld(PlanetModel.SPHERE);
+ assertEquals(GeoArea.CONTAINS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, Math.PI * 0.5, 0.1);
+ assertEquals(GeoArea.CONTAINS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, -Math.PI * 0.5, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+
+ // Build a shape degenerate in (x,y) which has two points on sphere
+ solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE, 0.0, 0.0, -1.1, 1.1, 0.0, 0.0);
+ // inside everything that it touches?
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ shape = new GeoWorld(PlanetModel.SPHERE);
+ assertEquals(GeoArea.CONTAINS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, Math.PI * 0.5, 0.1);
+ assertEquals(GeoArea.OVERLAPS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, -Math.PI * 0.5, 0.1);
+ assertEquals(GeoArea.OVERLAPS, solid.getRelationship(shape));
+
+ // MHL for y-z check
+
+ // Build a shape that is degenerate in x, which has zero points intersecting sphere
+ solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE, 0.0, 0.0, -0.1, 0.1, -0.1, 0.1);
+ // disjoint with everything?
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ shape = new GeoWorld(PlanetModel.SPHERE);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+
+ // Build a shape that is degenerate in x, which has zero points intersecting sphere, second variation
+ solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE, 0.0, 0.0, -0.1, 0.1, 1.1, 1.2);
+ // disjoint with everything?
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ shape = new GeoWorld(PlanetModel.SPHERE);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+
+ // Build a shape that is disjoint in X but intersects sphere in a complete circle
+ solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE, 0.0, 0.0, -1.1, 1.1, -1.1, 1.1);
+ // inside everything that it touches?
+ shape = new GeoWorld(PlanetModel.SPHERE);
+ assertEquals(GeoArea.CONTAINS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, Math.PI, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, Math.PI * 0.5, 0.1);
+ assertEquals(GeoArea.OVERLAPS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, -Math.PI * 0.5, 0.1);
+ assertEquals(GeoArea.OVERLAPS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, Math.PI * 0.5, 0.0, 0.1);
+ assertEquals(GeoArea.OVERLAPS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, -Math.PI * 0.5, 0.0, 0.1);
+ assertEquals(GeoArea.OVERLAPS, solid.getRelationship(shape));
+
+ // Build a shape that is disjoint in X but intersects sphere in a half circle in Y
+ solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE, 0.0, 0.0, 0.0, 1.1, -1.1, 1.1);
+ // inside everything that it touches?
+ shape = new GeoWorld(PlanetModel.SPHERE);
+ assertEquals(GeoArea.CONTAINS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, Math.PI, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, Math.PI * 0.5, 0.1);
+ assertEquals(GeoArea.OVERLAPS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, 0.0, -Math.PI * 0.5, 0.1);
+ assertEquals(GeoArea.DISJOINT, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, Math.PI * 0.5, 0.0, 0.1);
+ assertEquals(GeoArea.OVERLAPS, solid.getRelationship(shape));
+ shape = new GeoCircle(PlanetModel.SPHERE, -Math.PI * 0.5, 0.0, 0.1);
+ assertEquals(GeoArea.OVERLAPS, solid.getRelationship(shape));
+
+ // MHL for degenerate Y
+ // MHL for degenerate Z
+
+ }
+
}