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/08/20 11:36:33 UTC

[1/2] lucene-solr:master: LUCENE-7412: Make sure no combined edge of a polygon extends for more than 180 degrees.

Repository: lucene-solr
Updated Branches:
  refs/heads/master ca1ce0b25 -> e32597311


LUCENE-7412: Make sure no combined edge of a polygon extends for more than 180 degrees.


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

Branch: refs/heads/master
Commit: aa9b5204daa75494835a2da947f69f5daf8459a6
Parents: 22eeba9
Author: Karl Wright <Da...@gmail.com>
Authored: Sat Aug 20 07:35:38 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Sat Aug 20 07:35:38 2016 -0400

----------------------------------------------------------------------
 .../spatial3d/geom/GeoConcavePolygon.java       | 16 +++++++++++-
 .../lucene/spatial3d/geom/GeoConvexPolygon.java | 16 +++++++++++-
 .../lucene/spatial3d/geom/GeoPolygonTest.java   | 27 +++++++++++++++++---
 3 files changed, 54 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/aa9b5204/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 a133b3e..1abc06c 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
@@ -237,7 +237,21 @@ class GeoConcavePolygon extends GeoBasePolygon {
       while (invertedEdges[legalIndex(bound2Index)].isNumericallyIdentical(invertedEdge)) {
         bound2Index--;
       }
-      eitherBounds.put(edge, new EitherBound(invertedEdges[legalIndex(bound1Index)], invertedEdges[legalIndex(bound2Index)]));
+      bound1Index = legalIndex(bound1Index);
+      bound2Index = legalIndex(bound2Index);
+      // Also confirm that all interior points are within the bounds
+      int startingIndex = bound2Index;
+      while (true) {
+        startingIndex = legalIndex(startingIndex+1);
+        if (startingIndex == bound1Index) {
+          break;
+        }
+        final GeoPoint interiorPoint = points.get(startingIndex);
+        if (!invertedEdges[bound1Index].isWithin(interiorPoint) || !invertedEdges[bound2Index].isWithin(interiorPoint)) {
+          throw new IllegalArgumentException("Concave polygon has a side that is more than 180 degrees");
+        }
+      }
+      eitherBounds.put(edge, new EitherBound(invertedEdges[bound1Index], invertedEdges[bound2Index]));
       // For intersections, we look at the point at the intersection between the previous edge and this one.  We need to locate the 
       // Intersection bounds needs to look even further forwards/backwards
       if (otherInvertedEdge != null) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/aa9b5204/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 860eb26..dbf8f9f 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
@@ -230,7 +230,21 @@ class GeoConvexPolygon extends GeoBasePolygon {
       while (edges[legalIndex(bound2Index)].isNumericallyIdentical(edge)) {
         bound2Index--;
       }
-      eitherBounds.put(edge, new EitherBound(edges[legalIndex(bound1Index)], edges[legalIndex(bound2Index)]));
+      bound1Index = legalIndex(bound1Index);
+      bound2Index = legalIndex(bound2Index);
+      // Also confirm that all interior points are within the bounds
+      int startingIndex = bound2Index;
+      while (true) {
+        startingIndex = legalIndex(startingIndex+1);
+        if (startingIndex == bound1Index) {
+          break;
+        }
+        final GeoPoint interiorPoint = points.get(startingIndex);
+        if (!edges[bound1Index].isWithin(interiorPoint) || !edges[bound2Index].isWithin(interiorPoint)) {
+          throw new IllegalArgumentException("Convex polygon has a side that is more than 180 degrees");
+        }
+      }
+      eitherBounds.put(edge, new EitherBound(edges[bound1Index], edges[bound2Index]));
       // For intersections, we look at the point at the intersection between the previous edge and this one.  We need to locate the 
       // Intersection bounds needs to look even further forwards/backwards
       if (otherEdge != null) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/aa9b5204/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoPolygonTest.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoPolygonTest.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoPolygonTest.java
index a5a0207..6745060 100755
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoPolygonTest.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoPolygonTest.java
@@ -692,7 +692,7 @@ shape:
     polyList.add(p5);
     
     GeoPolygon p = GeoPolygonFactory.makeGeoPolygon(PlanetModel.WGS84, polyList);
-    System.out.println("p = "+p);
+    //System.out.println("p = "+p);
 
     XYZBounds bounds = new XYZBounds();
     p.getBounds(bounds);
@@ -733,8 +733,8 @@ shape:
     
     final GeoPoint point = new GeoPoint(PlanetModel.WGS84, -0.41518838180529244, 3.141592653589793);
     final GeoPoint encodedPoint = new GeoPoint(-0.9155623168963972, 2.3309121299774915E-10, -0.40359240449795253);
-    System.out.println("point = "+point);
-    System.out.println("encodedPoint = "+encodedPoint);
+    //System.out.println("point = "+point);
+    //System.out.println("encodedPoint = "+encodedPoint);
     
     assertTrue(p.isWithin(point));
     assertTrue(solid.isWithin(point));
@@ -906,5 +906,26 @@ shape:
     assertTrue(solid.isWithin(checkPoint));
     
   }
+
+  @Test
+  public void testPolygonFailureCase1() {
+    final List<GeoPoint> poly2List = new ArrayList<>();
+    poly2List.add(new GeoPoint(PlanetModel.WGS84, -0.6370451769779303, 2.5318373679431616));
+    poly2List.add(new GeoPoint(PlanetModel.WGS84, 1.5707963267948966, -3.141592653589793));
+    poly2List.add(new GeoPoint(PlanetModel.WGS84, -1.0850383189690824, 2.4457272005608357E-47));
+    poly2List.add(new GeoPoint(PlanetModel.WGS84, -0.5703530503197992, -3.141592653589793));
+    final BitSet poly2Bitset = new BitSet();
+    poly2Bitset.set(1);
+    
+    boolean result;
+    try {
+      final GeoConvexPolygon poly2 = new GeoConvexPolygon(PlanetModel.WGS84, poly2List);
+      result = true;
+    } catch (IllegalArgumentException e) {
+      result = false;
+    }
+    
+    assertTrue(!result);
+  }
   
 }


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

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


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

Branch: refs/heads/master
Commit: e325973119eae1fe8b7a81d505680952ec08964f
Parents: aa9b520 ca1ce0b
Author: Karl Wright <Da...@gmail.com>
Authored: Sat Aug 20 07:36:01 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Sat Aug 20 07:36:01 2016 -0400

----------------------------------------------------------------------
 dev-tools/idea/lucene/join/join.iml             |    1 +
 .../idea/lucene/queryparser/queryparser.iml     |    1 +
 .../lucene/spatial-extras/spatial-extras.iml    |    1 +
 .../idea/solr/contrib/analytics/analytics.iml   |    1 +
 dev-tools/idea/solr/core/src/java/solr-core.iml |    1 +
 .../idea/solr/core/src/solr-core-tests.iml      |    1 +
 dev-tools/scripts/addVersion.py                 |    6 +-
 dev-tools/scripts/buildAndPushRelease.py        |    2 +-
 lucene/CHANGES.txt                              |   19 +
 .../apache/lucene/analysis/ja/util/CSVUtil.java |    2 +-
 .../apache/lucene/analysis/ja/TestCSVUtil.java  |   52 +
 .../apache/lucene/legacy/LegacyDoubleField.java |  174 ++
 .../org/apache/lucene/legacy/LegacyField.java   |   90 +
 .../apache/lucene/legacy/LegacyFieldType.java   |  149 ++
 .../apache/lucene/legacy/LegacyFloatField.java  |  174 ++
 .../apache/lucene/legacy/LegacyIntField.java    |  175 ++
 .../apache/lucene/legacy/LegacyLongField.java   |  184 ++
 .../lucene/legacy/LegacyNumericRangeQuery.java  |  537 +++++
 .../lucene/legacy/LegacyNumericTokenStream.java |  357 ++++
 .../apache/lucene/legacy/LegacyNumericType.java |   34 +
 .../lucene/legacy/LegacyNumericUtils.java       |  510 +++++
 .../org/apache/lucene/legacy/package-info.java  |   21 +
 .../index/TestBackwardsCompatibility.java       |    8 +-
 .../apache/lucene/legacy/TestLegacyField.java   |  196 ++
 .../lucene/legacy/TestLegacyFieldReuse.java     |   81 +
 .../lucene/legacy/TestLegacyNumericUtils.java   |  571 +++++
 .../apache/lucene/legacy/TestLegacyTerms.java   |  164 ++
 .../TestMultiValuedNumericRangeQuery.java       |   84 +
 .../lucene/legacy/TestNumericRangeQuery32.java  |  461 ++++
 .../lucene/legacy/TestNumericRangeQuery64.java  |  490 +++++
 .../lucene/legacy/TestNumericTokenStream.java   |  188 ++
 .../analysis/LegacyNumericTokenStream.java      |  357 ----
 .../org/apache/lucene/analysis/TokenStream.java |    7 +-
 .../PackedTokenAttributeImpl.java               |   11 +
 .../PositionIncrementAttributeImpl.java         |    5 +
 .../java/org/apache/lucene/document/Field.java  |   33 -
 .../org/apache/lucene/document/FieldType.java   |   98 +-
 .../lucene/document/LegacyDoubleField.java      |  172 --
 .../lucene/document/LegacyFloatField.java       |  174 --
 .../apache/lucene/document/LegacyIntField.java  |  174 --
 .../apache/lucene/document/LegacyLongField.java |  182 --
 .../java/org/apache/lucene/geo/Rectangle.java   |   29 +
 .../org/apache/lucene/search/LRUQueryCache.java |    1 +
 .../lucene/search/LegacyNumericRangeQuery.java  |  536 -----
 .../apache/lucene/store/ByteBufferGuard.java    |  136 ++
 .../lucene/store/ByteBufferIndexInput.java      |  104 +-
 .../org/apache/lucene/store/MMapDirectory.java  |    8 +-
 .../org/apache/lucene/util/AttributeImpl.java   |   11 +
 .../org/apache/lucene/util/AttributeSource.java |   10 +
 .../apache/lucene/util/LegacyNumericUtils.java  |  508 -----
 .../java/org/apache/lucene/util/Version.java    |    7 +
 .../lucene/analysis/TestNumericTokenStream.java |  169 --
 .../TestGrowableByteArrayDataOutput.java        |    2 +-
 .../org/apache/lucene/document/TestField.java   |   94 -
 .../apache/lucene/document/TestFieldType.java   |    9 -
 .../org/apache/lucene/geo/TestGeoUtils.java     |   11 +-
 .../org/apache/lucene/geo/TestPolygon2D.java    |    9 +-
 .../org/apache/lucene/index/TestFieldReuse.java |   53 +-
 .../apache/lucene/index/TestIndexSorting.java   |    2 +-
 .../index/TestIndexingSequenceNumbers.java      |    4 +
 .../test/org/apache/lucene/index/TestTerms.java |  134 --
 .../org/apache/lucene/search/TestBoolean2.java  |   13 +-
 .../TestMultiValuedNumericRangeQuery.java       |   80 -
 .../lucene/search/TestNumericRangeQuery32.java  |  589 ------
 .../lucene/search/TestNumericRangeQuery64.java  |  623 ------
 .../lucene/search/TestSearcherManager.java      |  142 ++
 .../TestSimpleExplanationsWithFillerDocs.java   |    2 +
 .../apache/lucene/store/TestMmapDirectory.java  |   38 +
 .../lucene/util/TestLegacyNumericUtils.java     |  564 -----
 lucene/join/build.xml                           |    6 +-
 .../search/join/DocValuesTermsCollector.java    |    9 +-
 .../org/apache/lucene/search/join/JoinUtil.java |    6 +-
 .../search/join/TermsIncludingScoreQuery.java   |    2 +-
 .../apache/lucene/search/join/TestJoinUtil.java |    6 +-
 .../memory/TestMemoryIndexAgainstRAMDir.java    |    7 -
 .../search/TestDiversifiedTopDocsCollector.java |    5 +-
 .../lucene/queries/mlt/TestMoreLikeThis.java    |    1 +
 lucene/queryparser/build.xml                    |    6 +-
 .../LegacyNumericRangeQueryNodeBuilder.java     |   10 +-
 .../standard/config/LegacyNumericConfig.java    |   15 +-
 .../nodes/LegacyNumericRangeQueryNode.java      |    9 +-
 .../LegacyNumericRangeQueryBuilder.java         |    8 +-
 .../standard/TestLegacyNumericQueryParser.java  |   34 +-
 .../xml/CoreParserTestIndexData.java            |    2 +-
 .../builders/TestNumericRangeQueryBuilder.java  |    2 +-
 .../apache/lucene/document/FloatRangeField.java |  262 +++
 .../apache/lucene/document/IntRangeField.java   |  262 +++
 .../apache/lucene/document/LongRangeField.java  |  260 +++
 .../search/BaseRangeFieldQueryTestCase.java     |  238 +--
 .../search/TestDoubleRangeFieldQueries.java     |  154 +-
 .../search/TestFloatRangeFieldQueries.java      |  240 +++
 .../lucene/search/TestIntRangeFieldQueries.java |  240 +++
 .../search/TestLongRangeFieldQueries.java       |  240 +++
 lucene/spatial-extras/build.xml                 |    8 +-
 .../lucene/spatial/bbox/BBoxStrategy.java       |   39 +-
 .../prefix/BytesRefIteratorTokenStream.java     |    2 +-
 .../spatial/vector/PointVectorStrategy.java     |   37 +-
 .../lucene/spatial/bbox/TestBBoxStrategy.java   |    8 +-
 .../lucene/store/MockDirectoryWrapper.java      |    2 +-
 .../java/org/apache/lucene/util/TestUtil.java   |   13 +-
 lucene/tools/junit4/tests.policy                |    4 -
 solr/CHANGES.txt                                |   59 +
 .../solr/analytics/util/AnalyticsParsers.java   |    2 +-
 .../util/valuesource/DateFieldSource.java       |    2 +-
 .../org/apache/solr/cloud/AddReplicaCmd.java    |  192 ++
 .../java/org/apache/solr/cloud/BackupCmd.java   |  132 ++
 .../org/apache/solr/cloud/CreateAliasCmd.java   |  101 +
 .../apache/solr/cloud/CreateCollectionCmd.java  |  291 +++
 .../org/apache/solr/cloud/CreateShardCmd.java   |  120 ++
 .../org/apache/solr/cloud/DeleteAliasCmd.java   |   95 +
 .../apache/solr/cloud/DeleteCollectionCmd.java  |  121 ++
 .../org/apache/solr/cloud/DeleteNodeCmd.java    |   91 +
 .../org/apache/solr/cloud/DeleteReplicaCmd.java |  155 ++
 .../org/apache/solr/cloud/DeleteShardCmd.java   |  126 ++
 .../java/org/apache/solr/cloud/MigrateCmd.java  |  333 +++
 .../OverseerCollectionConfigSetProcessor.java   |   22 +-
 .../cloud/OverseerCollectionMessageHandler.java | 1979 ++----------------
 .../org/apache/solr/cloud/OverseerRoleCmd.java  |  102 +
 .../apache/solr/cloud/OverseerStatusCmd.java    |  122 ++
 .../solr/cloud/OverseerTaskProcessor.java       |    6 +-
 .../org/apache/solr/cloud/ReplaceNodeCmd.java   |  163 ++
 .../java/org/apache/solr/cloud/RestoreCmd.java  |  243 +++
 .../org/apache/solr/cloud/SplitShardCmd.java    |  458 ++++
 .../java/org/apache/solr/core/CoreSorter.java   |   12 +-
 .../java/org/apache/solr/core/SolrConfig.java   |   29 +-
 .../solr/handler/admin/CollectionsHandler.java  |    5 +-
 .../solr/handler/component/StatsField.java      |   17 +-
 .../org/apache/solr/request/IntervalFacets.java |    2 +-
 .../org/apache/solr/request/NumericFacets.java  |    3 +-
 .../java/org/apache/solr/schema/BBoxField.java  |    7 +-
 .../java/org/apache/solr/schema/EnumField.java  |   17 +-
 .../java/org/apache/solr/schema/FieldType.java  |    3 +-
 .../schema/SpatialPointVectorFieldType.java     |    9 +-
 .../org/apache/solr/schema/TrieDoubleField.java |    2 +-
 .../java/org/apache/solr/schema/TrieField.java  |   44 +-
 .../org/apache/solr/schema/TrieFloatField.java  |    2 +-
 .../org/apache/solr/schema/TrieIntField.java    |    2 +-
 .../org/apache/solr/schema/TrieLongField.java   |    2 +-
 .../org/apache/solr/search/CacheConfig.java     |   24 +-
 .../org/apache/solr/search/QueryParsing.java    |    2 +-
 .../apache/solr/search/QueryWrapperFilter.java  |    2 +-
 .../apache/solr/search/ReRankQParserPlugin.java |   35 +-
 .../org/apache/solr/search/ReRankWeight.java    |   48 +
 .../apache/solr/search/SolrIndexSearcher.java   |   69 +-
 .../apache/solr/search/facet/FacetField.java    |  955 +--------
 .../solr/search/facet/FacetFieldProcessor.java  |  369 ++++
 .../facet/FacetFieldProcessorByArray.java       |  213 ++
 .../facet/FacetFieldProcessorByArrayDV.java     |  294 +++
 .../facet/FacetFieldProcessorByArrayUIF.java    |   71 +
 .../FacetFieldProcessorByEnumTermsStream.java   |  356 ++++
 .../facet/FacetFieldProcessorByHashNumeric.java |  439 ++++
 .../search/facet/FacetFieldProcessorDV.java     |  291 ---
 .../facet/FacetFieldProcessorNumeric.java       |  443 ----
 .../solr/search/facet/FacetProcessor.java       |  203 +-
 .../apache/solr/search/facet/FacetQuery.java    |    5 -
 .../apache/solr/search/facet/FacetRange.java    |    5 -
 .../solr/search/facet/UnInvertedField.java      |    6 +-
 .../join/BlockJoinDocSetFacetComponent.java     |   34 +-
 .../search/join/BlockJoinFacetAccsHolder.java   |   97 +
 .../search/join/BlockJoinFacetCollector.java    |  131 --
 .../search/join/BlockJoinFacetComponent.java    |  165 +-
 .../join/BlockJoinFacetComponentSupport.java    |  156 ++
 .../apache/solr/search/mlt/CloudMLTQParser.java |    2 +-
 .../solr/search/mlt/SimpleMLTQParser.java       |    2 +-
 .../org/apache/solr/uninverting/FieldCache.java |   20 +-
 .../solr/uninverting/UninvertingReader.java     |   16 +-
 .../org/apache/solr/update/TransactionLog.java  |    2 +-
 .../org/apache/solr/update/VersionInfo.java     |    2 +-
 .../org/apache/solr/cloud/DeleteNodeTest.java   |   75 +
 .../org/apache/solr/cloud/ReplaceNodeTest.java  |  104 +
 .../apache/solr/core/TestSolrConfigHandler.java |   56 +-
 .../solr/search/TestMaxScoreQueryParser.java    |    1 +
 .../solr/search/facet/TestJsonFacets.java       |   10 +-
 .../solr/search/function/TestOrdValues.java     |    4 +-
 .../search/join/BlockJoinFacetSimpleTest.java   |   24 +
 .../solr/uninverting/TestDocTermOrds.java       |    6 +-
 .../TestFieldCacheSanityChecker.java            |    8 +-
 .../solr/uninverting/TestFieldCacheSort.java    |    8 +-
 .../solr/uninverting/TestLegacyFieldCache.java  |   10 +-
 .../solr/uninverting/TestNumericTerms32.java    |   14 +-
 .../solr/uninverting/TestNumericTerms64.java    |   16 +-
 .../solr/uninverting/TestUninvertingReader.java |   10 +-
 solr/site/SYSTEM_REQUIREMENTS.mdtext            |    2 +-
 .../client/solrj/impl/LBHttpSolrClient.java     |    2 +-
 .../solrj/request/CollectionAdminRequest.java   |   52 +-
 .../apache/solr/common/cloud/ZkNodeProps.java   |   12 +
 .../apache/solr/common/cloud/ZkStateReader.java |   14 +-
 .../solr/common/params/CollectionParams.java    |    3 +
 .../cloud/TestCollectionStateWatchers.java      |   51 +-
 solr/webapp/web/css/angular/index.css           |   12 +-
 .../web/js/angular/controllers/collections.js   |    7 +-
 solr/webapp/web/js/angular/controllers/cores.js |   10 +-
 .../web/js/angular/controllers/dataimport.js    |   58 +-
 solr/webapp/web/js/angular/controllers/files.js |    6 +-
 .../webapp/web/js/angular/controllers/schema.js |    4 +
 solr/webapp/web/js/angular/services.js          |    6 +-
 solr/webapp/web/partials/dataimport.html        |    8 +-
 197 files changed, 12886 insertions(+), 9208 deletions(-)
----------------------------------------------------------------------