mirror of https://github.com/apache/lucene.git
Use more accurate version of inside cutoff planes.
This commit is contained in:
parent
31f3d1f209
commit
5545e9edf1
|
@ -865,8 +865,10 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
||||||
this.testPointCutoffPlane = new SidedPlane(thePoint, testPointPlane, testPoint);
|
this.testPointCutoffPlane = new SidedPlane(thePoint, testPointPlane, testPoint);
|
||||||
this.checkPointCutoffPlane = new SidedPlane(testPoint, travelPlane, thePoint);
|
this.checkPointCutoffPlane = new SidedPlane(testPoint, travelPlane, thePoint);
|
||||||
|
|
||||||
this.testPointOtherCutoffPlane = new SidedPlane(testPoint, travelPlane, -(travelPlane.x * intersectionPoint.x + travelPlane.y * intersectionPoint.y + travelPlane.z * intersectionPoint.z));
|
// Convert travel plane to a sided plane
|
||||||
this.checkPointOtherCutoffPlane = new SidedPlane(thePoint, testPointPlane, -(testPointPlane.x * intersectionPoint.x + testPointPlane.y * intersectionPoint.y + testPointPlane.z * intersectionPoint.z));
|
this.testPointOtherCutoffPlane = new SidedPlane(testPoint, travelPlane, travelPlane.D);
|
||||||
|
// Convert testPoint plane to a sided plane
|
||||||
|
this.checkPointOtherCutoffPlane = new SidedPlane(thePoint, testPointPlane, testPointPlane.D);
|
||||||
|
|
||||||
// Figure out which of the above/below planes are inside vs. outside. To do this,
|
// Figure out which of the above/below planes are inside vs. outside. To do this,
|
||||||
// we look for the point that is within the bounds of the testPointPlane and travelPlane. The two sides that intersected there are the inside
|
// we look for the point that is within the bounds of the testPointPlane and travelPlane. The two sides that intersected there are the inside
|
||||||
|
@ -881,8 +883,8 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
||||||
assert belowBelow != null : "Below + below should not be coplanar";
|
assert belowBelow != null : "Below + below should not be coplanar";
|
||||||
final GeoPoint[] belowAbove = travelBelowPlane.findIntersections(planetModel, testPointAbovePlane, testPointCutoffPlane, testPointOtherCutoffPlane, checkPointCutoffPlane, checkPointOtherCutoffPlane);
|
final GeoPoint[] belowAbove = travelBelowPlane.findIntersections(planetModel, testPointAbovePlane, testPointCutoffPlane, testPointOtherCutoffPlane, checkPointCutoffPlane, checkPointOtherCutoffPlane);
|
||||||
assert belowAbove != null : "Below + above should not be coplanar";
|
assert belowAbove != null : "Below + above should not be coplanar";
|
||||||
|
|
||||||
assert aboveAbove.length + aboveBelow.length + belowBelow.length + belowAbove.length == 1 : "Can be exactly one inside point, instead was: aa="+aboveAbove.length+" ab=" + aboveBelow.length+" bb="+ belowBelow.length+" ba=" + belowAbove.length;
|
assert ((aboveAbove.length > 0)?1:0) + ((aboveBelow.length > 0)?1:0) + ((belowBelow.length > 0)?1:0) + ((belowAbove.length > 0)?1:0) == 1 : "Can be exactly one inside point, instead was: aa="+aboveAbove.length+" ab=" + aboveBelow.length+" bb="+ belowBelow.length+" ba=" + belowAbove.length;
|
||||||
|
|
||||||
final GeoPoint insideIntersection;
|
final GeoPoint insideIntersection;
|
||||||
if (aboveAbove.length > 0) {
|
if (aboveAbove.length > 0) {
|
||||||
|
@ -911,8 +913,8 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
||||||
insideIntersection = belowAbove[0];
|
insideIntersection = belowAbove[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
insideTravelCutoffPlane = new SidedPlane(thePoint, travelInsidePlane, insideIntersection);
|
insideTravelCutoffPlane = new SidedPlane(thePoint, testPointInsidePlane, testPointInsidePlane.D);
|
||||||
insideTestPointCutoffPlane = new SidedPlane(testPoint, testPointInsidePlane, insideIntersection);
|
insideTestPointCutoffPlane = new SidedPlane(testPoint, travelInsidePlane, travelInsidePlane.D);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,12 @@ public class GeoPolygonTest {
|
||||||
gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.5);
|
gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.5);
|
||||||
assertTrue(c.isWithin(gp));
|
assertTrue(c.isWithin(gp));
|
||||||
|
|
||||||
|
shapes = new ArrayList<>();
|
||||||
|
shapes.add(new GeoPolygonFactory.PolygonDescription(points));
|
||||||
|
|
||||||
|
c = GeoPolygonFactory.makeLargeGeoPolygon(PlanetModel.SPHERE, shapes);
|
||||||
|
assertTrue(c.isWithin(gp));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -141,6 +147,7 @@ public class GeoPolygonTest {
|
||||||
GeoPolygon c;
|
GeoPolygon c;
|
||||||
GeoPoint gp;
|
GeoPoint gp;
|
||||||
List<GeoPoint> points;
|
List<GeoPoint> points;
|
||||||
|
List<GeoPolygonFactory.PolygonDescription> shapes;
|
||||||
|
|
||||||
points = new ArrayList<GeoPoint>();
|
points = new ArrayList<GeoPoint>();
|
||||||
points.add(new GeoPoint(PlanetModel.SPHERE, 0.0, -0.4));
|
points.add(new GeoPoint(PlanetModel.SPHERE, 0.0, -0.4));
|
||||||
|
@ -177,6 +184,43 @@ public class GeoPolygonTest {
|
||||||
gp = new GeoPoint(PlanetModel.SPHERE, 0.0, Math.PI);
|
gp = new GeoPoint(PlanetModel.SPHERE, 0.0, Math.PI);
|
||||||
assertFalse(c.isWithin(gp));
|
assertFalse(c.isWithin(gp));
|
||||||
|
|
||||||
|
// Now, same thing for large polygon
|
||||||
|
shapes = new ArrayList<>();
|
||||||
|
shapes.add(new GeoPolygonFactory.PolygonDescription(points));
|
||||||
|
|
||||||
|
c = GeoPolygonFactory.makeLargeGeoPolygon(PlanetModel.SPHERE, shapes);
|
||||||
|
gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.65);
|
||||||
|
assertFalse(c.isWithin(gp)); //??? fails
|
||||||
|
|
||||||
|
// Sample some points within
|
||||||
|
gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.45);
|
||||||
|
assertTrue(c.isWithin(gp));
|
||||||
|
gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.5);
|
||||||
|
assertTrue(c.isWithin(gp));
|
||||||
|
gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.55);
|
||||||
|
assertTrue(c.isWithin(gp));
|
||||||
|
gp = new GeoPoint(PlanetModel.SPHERE, -0.05, -0.5);
|
||||||
|
assertTrue(c.isWithin(gp));
|
||||||
|
gp = new GeoPoint(PlanetModel.SPHERE, 0.05, -0.5);
|
||||||
|
assertTrue(c.isWithin(gp));
|
||||||
|
// Sample some nearby points outside
|
||||||
|
gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.65);
|
||||||
|
assertFalse(c.isWithin(gp)); //??? fails
|
||||||
|
gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.35);
|
||||||
|
assertFalse(c.isWithin(gp));
|
||||||
|
gp = new GeoPoint(PlanetModel.SPHERE, -0.15, -0.5);
|
||||||
|
assertFalse(c.isWithin(gp));
|
||||||
|
gp = new GeoPoint(PlanetModel.SPHERE, 0.15, -0.5);
|
||||||
|
assertFalse(c.isWithin(gp));
|
||||||
|
// Random points outside
|
||||||
|
gp = new GeoPoint(PlanetModel.SPHERE, 0.0, 0.0);
|
||||||
|
assertFalse(c.isWithin(gp));
|
||||||
|
gp = new GeoPoint(PlanetModel.SPHERE, Math.PI * 0.5, 0.0);
|
||||||
|
assertFalse(c.isWithin(gp));
|
||||||
|
gp = new GeoPoint(PlanetModel.SPHERE, 0.0, Math.PI);
|
||||||
|
assertFalse(c.isWithin(gp));
|
||||||
|
|
||||||
|
// Next bunch of small polygon points
|
||||||
points = new ArrayList<GeoPoint>();
|
points = new ArrayList<GeoPoint>();
|
||||||
points.add(new GeoPoint(PlanetModel.SPHERE, 0.0, -0.4));
|
points.add(new GeoPoint(PlanetModel.SPHERE, 0.0, -0.4));
|
||||||
points.add(new GeoPoint(PlanetModel.SPHERE, 0.1, -0.5));
|
points.add(new GeoPoint(PlanetModel.SPHERE, 0.1, -0.5));
|
||||||
|
|
Loading…
Reference in New Issue