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/22 22:36:29 UTC

[1/2] lucene-solr:branch_6x: LUCENE-7244: Complain if the holes are outside the polygon.

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x c3f62d1a7 -> bb2293cf7


LUCENE-7244: Complain if the holes are outside the polygon.


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

Branch: refs/heads/branch_6x
Commit: 38c0915572333f1f77efb43028fe91927df8464d
Parents: 874f6a1
Author: Karl Wright <Da...@gmail.com>
Authored: Fri Apr 22 16:35:51 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Fri Apr 22 16:35:51 2016 -0400

----------------------------------------------------------------------
 .../spatial3d/geom/GeoConcavePolygon.java       | 35 +++++++++++---------
 .../lucene/spatial3d/geom/GeoConvexPolygon.java | 35 +++++++++++---------
 2 files changed, 40 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/38c09155/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
index 124b46b..8eaea1a 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
@@ -207,21 +207,6 @@ class GeoConcavePolygon extends GeoBasePolygon {
       invertedEdges[i] = new SidedPlane(edges[i]);
       notableEdgePoints[i] = new GeoPoint[]{start, end};
     }
-    /* Disable since GeoPolygonFactory does this too.
-    // In order to naively confirm that the polygon is concave, I would need to
-    // check every edge, and verify that every point (other than the edge endpoints)
-    // is within the edge's sided plane.  This is an order n^2 operation.  That's still
-    // not wrong, though, because everything else about polygons has a similar cost.
-    for (int edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
-      final SidedPlane edge = edges[edgeIndex];
-      for (int pointIndex = 0; pointIndex < points.size(); pointIndex++) {
-        if (pointIndex != edgeIndex && pointIndex != legalIndex(edgeIndex + 1)) {
-          if (edge.isWithin(points.get(pointIndex)))
-            throw new IllegalArgumentException("Polygon is not concave: Point " + points.get(pointIndex) + " Edge " + edge);
-        }
-      }
-    }
-    */
     
     // For each edge, create a bounds object.
     eitherBounds = new HashMap<>(edges.length);
@@ -241,6 +226,26 @@ class GeoConcavePolygon extends GeoBasePolygon {
 
     // Pick an edge point arbitrarily
     edgePoints = new GeoPoint[]{points.get(0)};
+
+    if (isWithinHoles(points.get(0))) {
+      throw new IllegalArgumentException("Polygon edge intersects a polygon hole; not allowed");
+    }
+
+  }
+
+  /** Check if a point is within the provided holes.
+   *@param point point to check.
+   *@return true if the point is within any of the holes.
+   */
+  protected boolean isWithinHoles(final GeoPoint point) {
+    if (holes != null) {
+      for (final GeoPolygon hole : holes) {
+        if (hole.isWithin(point)) {
+          return true;
+        }
+      }
+    }
+    return false;
   }
 
   /** Compute a legal point index from a possibly illegal one, that may have wrapped.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/38c09155/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
index 64aa7c4..17a2120 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
@@ -203,21 +203,6 @@ class GeoConvexPolygon extends GeoBasePolygon {
       edges[i] = sp;
       notableEdgePoints[i] = new GeoPoint[]{start, end};
     }
-    /* Disabled since GeoPolygonFactory does the checking too.
-    // In order to naively confirm that the polygon is convex, I would need to
-    // check every edge, and verify that every point (other than the edge endpoints)
-    // is within the edge's sided plane.  This is an order n^2 operation.  That's still
-    // not wrong, though, because everything else about polygons has a similar cost.
-    for (int edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
-      final SidedPlane edge = edges[edgeIndex];
-      for (int pointIndex = 0; pointIndex < points.size(); pointIndex++) {
-        if (pointIndex != edgeIndex && pointIndex != legalIndex(edgeIndex + 1)) {
-          if (!edge.isWithin(points.get(pointIndex)))
-            throw new IllegalArgumentException("Polygon is not convex: Point " + points.get(pointIndex) + " Edge " + edge);
-        }
-      }
-    }
-    */
     
     // For each edge, create a bounds object.
     eitherBounds = new HashMap<>(edges.length);
@@ -236,8 +221,28 @@ class GeoConvexPolygon extends GeoBasePolygon {
     
     // Pick an edge point arbitrarily
     edgePoints = new GeoPoint[]{points.get(0)};
+    
+    if (isWithinHoles(points.get(0))) {
+      throw new IllegalArgumentException("Polygon edge intersects a polygon hole; not allowed");
+    }
+
   }
 
+  /** Check if a point is within the provided holes.
+   *@param point point to check.
+   *@return true if the point is within any of the holes.
+   */
+  protected boolean isWithinHoles(final GeoPoint point) {
+    if (holes != null) {
+      for (final GeoPolygon hole : holes) {
+        if (hole.isWithin(point)) {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+  
   /** Compute a legal point index from a possibly illegal one, that may have wrapped.
    *@param index is the index.
    *@return the normalized index.


[2/2] lucene-solr:branch_6x: Merge branch 'branch_6x' of https://git-wip-us.apache.org/repos/asf/lucene-solr into branch_6x

Posted by kw...@apache.org.
Merge branch 'branch_6x' of https://git-wip-us.apache.org/repos/asf/lucene-solr into branch_6x


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

Branch: refs/heads/branch_6x
Commit: bb2293cf7e144c163ca395db0dcaf4b15d668a2d
Parents: 38c0915 c3f62d1
Author: Karl Wright <Da...@gmail.com>
Authored: Fri Apr 22 16:36:12 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Fri Apr 22 16:36:12 2016 -0400

----------------------------------------------------------------------
 lucene/CHANGES.txt                              |  18 +-
 .../org/apache/lucene/search/LRUQueryCache.java | 303 +++++++++-----
 .../lucene/search/QueryCachingPolicy.java       |  69 +---
 .../search/UsageTrackingQueryCachingPolicy.java |  29 +-
 .../java/org/apache/lucene/util/BitUtil.java    |   4 +-
 .../apache/lucene/search/TestIndexSearcher.java |   2 +-
 .../apache/lucene/search/TestLRUQueryCache.java |  79 +++-
 .../lucene/search/TestQueryCachingPolicy.java   |  56 ---
 .../TestUsageTrackingFilterCachingPolicy.java   |  17 +-
 .../apache/lucene/index/memory/MemoryIndex.java |   1 +
 .../apache/lucene/queries/TermsQueryTest.java   |  16 +-
 .../org/apache/lucene/document/LatLonGrid.java  |  28 +-
 .../document/LatLonPointInPolygonQuery.java     |  66 +---
 .../org/apache/lucene/document/LatLonTree.java  | 396 +++++++++++++++++++
 .../apache/lucene/document/TestLatLonGrid.java  |   6 +-
 .../apache/lucene/document/TestLatLonTree.java  |  53 +++
 .../geopoint/document/GeoPointField.java        | 110 +++++-
 .../geopoint/document/GeoPointTokenStream.java  |   4 +-
 .../geopoint/search/GeoPointDistanceQuery.java  |   5 +-
 .../geopoint/search/GeoPointInBBoxQuery.java    |   2 -
 .../geopoint/search/GeoPointInPolygonQuery.java |   4 +-
 .../search/GeoPointNumericTermsEnum.java        |  17 +-
 .../search/GeoPointPrefixTermsEnum.java         |  26 +-
 .../GeoPointTermQueryConstantScoreWrapper.java  |   7 +-
 .../lucene/spatial/util/GeoEncodingUtils.java   | 152 -------
 .../lucene/spatial/util/MortonEncoder.java      | 103 +++++
 .../geopoint/search/TestGeoPointQuery.java      |   5 +-
 .../search/TestLegacyGeoPointQuery.java         |   5 +-
 .../spatial/util/TestGeoEncodingUtils.java      | 101 -----
 .../lucene/spatial/util/TestGeoPointField.java  |  51 +++
 .../lucene/spatial/util/TestMortonEncoder.java  | 108 +++++
 .../org/apache/lucene/util/LuceneTestCase.java  |   4 +-
 .../solr/cloud/ConnectionManagerTest.java       |  40 +-
 .../test/org/apache/solr/core/SolrCoreTest.java |  40 ++
 .../solr/common/cloud/ConnectionManager.java    |   8 +-
 35 files changed, 1254 insertions(+), 681 deletions(-)
----------------------------------------------------------------------