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 2016/04/19 15:10:57 UTC
lucene-solr:branch_6x: LUCENE-7192: Catch the case where we have two
points in the same poly that are not adjacent but identical.
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x 01a7ee4ee -> e4012c6b3
LUCENE-7192: Catch the case where we have two points in the same poly that are not adjacent but identical.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/e4012c6b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e4012c6b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e4012c6b
Branch: refs/heads/branch_6x
Commit: e4012c6b32ef2ac7f612fe69cf955c4f210d0ef9
Parents: 01a7ee4
Author: Karl Wright <Da...@gmail.com>
Authored: Tue Apr 19 09:09:40 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Tue Apr 19 09:10:48 2016 -0400
----------------------------------------------------------------------
.../spatial3d/geom/GeoPolygonFactory.java | 121 ++++++++++---------
1 file changed, 63 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e4012c6b/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 8cb3386..6cc4257 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
@@ -229,73 +229,78 @@ public class GeoPolygonFactory {
// Check if the extension of currentPath to considerPointIndex is workable
final GeoPoint considerStartPoint = currentPath.lastPoint;
final GeoPoint considerEndPoint = points.get(considerPointIndex);
- // Create a plane including these two
- final Plane considerPlane = new Plane(considerStartPoint, considerEndPoint);
- boolean isChoiceLegal = true;
- //System.err.println(" considering "+considerStartPoint+" to "+considerEndPoint);
- if (isChoiceLegal) {
- // Consider the previous plane/point
- if (currentPath.lastPlane != null) {
- if (currentPath.lastPlane.evaluateIsZero(considerEndPoint)) {
- //System.err.println(" coplanar with last plane");
- // no good
- isChoiceLegal = false;
- } else if (considerPlane.evaluateIsZero(currentPath.previous.lastPoint)) {
- //System.err.println(" last point coplanar with this plane");
- isChoiceLegal = false;
+ final int nextPointIndex = getLegalIndex(considerPointIndex + 1, points.size());
+ if (!considerStartPoint.isNumericallyIdentical(considerEndPoint)) {
+ // Create a plane including these two
+ final Plane considerPlane = new Plane(considerStartPoint, considerEndPoint);
+
+ boolean isChoiceLegal = true;
+
+ //System.err.println(" considering "+considerStartPoint+" to "+considerEndPoint);
+ if (isChoiceLegal) {
+ // Consider the previous plane/point
+ if (currentPath.lastPlane != null) {
+ if (currentPath.lastPlane.evaluateIsZero(considerEndPoint)) {
+ //System.err.println(" coplanar with last plane");
+ // no good
+ isChoiceLegal = false;
+ } else if (considerPlane.evaluateIsZero(currentPath.previous.lastPoint)) {
+ //System.err.println(" last point coplanar with this plane");
+ isChoiceLegal = false;
+ }
}
}
- }
-
- if (isChoiceLegal && considerPointIndex == startPointIndex) {
- // Verify that the first plane (already recorded) works together with the last plane
- final SafePath firstPlaneEndpoint = currentPath.findFirstEndpoint();
- if (firstPlaneEndpoint == null) {
- //System.err.println(" path not long enough");
- isChoiceLegal = false;
- } else {
- if (firstPlaneEndpoint.lastPlane.evaluateIsZero(considerStartPoint)) {
- //System.err.println(" last point is coplanar with start plane");
- isChoiceLegal = false;
- } else if (considerPlane.evaluateIsZero(firstPlaneEndpoint.lastPoint)) {
- //System.err.println(" first point is coplanar with last plane");
+
+ if (isChoiceLegal && considerPointIndex == startPointIndex) {
+ // Verify that the first plane (already recorded) works together with the last plane
+ final SafePath firstPlaneEndpoint = currentPath.findFirstEndpoint();
+ if (firstPlaneEndpoint == null) {
+ //System.err.println(" path not long enough");
isChoiceLegal = false;
+ } else {
+ if (firstPlaneEndpoint.lastPlane.evaluateIsZero(considerStartPoint)) {
+ //System.err.println(" last point is coplanar with start plane");
+ isChoiceLegal = false;
+ } else if (considerPlane.evaluateIsZero(firstPlaneEndpoint.lastPoint)) {
+ //System.err.println(" first point is coplanar with last plane");
+ isChoiceLegal = false;
+ }
}
}
- }
-
- if (isChoiceLegal) {
- // All points between the start and end, if any, must be on the plane.
- int checkIndex = getLegalIndex(currentPath.lastPointIndex + 1, points.size());
- while (checkIndex != considerPointIndex) {
- if (!considerPlane.evaluateIsZero(points.get(checkIndex))) {
- // This possibility is no good. But does it say anything about other possibilities? I think
- // it may mean we don't have to consider any further extensions; gotta work that through
- // mathematically though before coding it.
- //System.err.println(" interior point not coplanar with trial plane");
- isChoiceLegal = false;
- break;
- //return null;
+
+ if (isChoiceLegal) {
+ // All points between the start and end, if any, must be on the plane.
+ int checkIndex = getLegalIndex(currentPath.lastPointIndex + 1, points.size());
+ while (checkIndex != considerPointIndex) {
+ if (!considerPlane.evaluateIsZero(points.get(checkIndex))) {
+ // This possibility is no good. But does it say anything about other possibilities? I think
+ // it may mean we don't have to consider any further extensions; gotta work that through
+ // mathematically though before coding it.
+ //System.err.println(" interior point not coplanar with trial plane");
+ isChoiceLegal = false;
+ break;
+ //return null;
+ }
+ checkIndex = getLegalIndex(checkIndex + 1, points.size());
}
- checkIndex = getLegalIndex(checkIndex + 1, points.size());
- }
- }
-
-
- final int nextPointIndex = getLegalIndex(considerPointIndex + 1, points.size());
- if (isChoiceLegal) {
- // Extend the path and call ourselves recursively.
- if (considerPointIndex == startPointIndex) {
- // Current path has been validated; return it
- return currentPath;
}
- //System.err.println(" adding to path: "+considerEndPoint+"; "+considerPlane);
- final SafePath newPath = new SafePath(currentPath, considerEndPoint, considerPointIndex, considerPlane);
- final SafePath result = findSafePath(newPath, points, nextPointIndex, startPointIndex);
- if (result != null) {
- return result;
+
+ if (isChoiceLegal) {
+ // Extend the path and call ourselves recursively.
+ if (considerPointIndex == startPointIndex) {
+ // Current path has been validated; return it
+ return currentPath;
+ }
+ //System.err.println(" adding to path: "+considerEndPoint+"; "+considerPlane);
+ final SafePath newPath = new SafePath(currentPath, considerEndPoint, considerPointIndex, considerPlane);
+ final SafePath result = findSafePath(newPath, points, nextPointIndex, startPointIndex);
+ if (result != null) {
+ return result;
+ }
}
+
}
+
if (considerPointIndex == startPointIndex) {
break;
}