lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iv...@apache.org
Subject lucene-solr:master: LUCENE-8299: Geo3D wrapper uses new polygon method factory that gives better support for polygons with many points (>100)
Date Wed, 06 Jun 2018 09:45:20 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master 0358fcb17 -> af7dfb182


LUCENE-8299: Geo3D wrapper uses new polygon method factory that gives better support for polygons
with many points (>100)


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

Branch: refs/heads/master
Commit: af7dfb182ebc175df44b2d0a846a7d11f58bf84b
Parents: 0358fcb
Author: Ignacio Vera <ivera@apache.org>
Authored: Wed Jun 6 11:39:39 2018 +0200
Committer: Ignacio Vera <ivera@apache.org>
Committed: Wed Jun 6 11:39:39 2018 +0200

----------------------------------------------------------------------
 lucene/CHANGES.txt                              |  3 +++
 .../spatial/spatial4j/Geo3dShapeFactory.java    | 10 ++++-----
 .../lucene/spatial/spatial4j/Geo3dRptTest.java  | 23 ++++++++++++++++++--
 3 files changed, 28 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/af7dfb18/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 9eecc42..8f307fe 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -267,6 +267,9 @@ Other
 
 * LUCENE-8301: Update randomizedtesting to 2.6.0. (Dawid Weiss)
 
+* LUCENE-8299: Geo3D wrapper uses new polygon method factory that gives better
+  support for polygons with many points (>100). (Ignacio vera)
+
 * LUCENE-8261: InterpolatedProperties.interpolate and recursive property
   references. (Steve Rowe, Dawid Weiss)
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/af7dfb18/lucene/spatial-extras/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShapeFactory.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShapeFactory.java
b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShapeFactory.java
index a6147df..ccbd6df 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShapeFactory.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShapeFactory.java
@@ -311,7 +311,7 @@ public class Geo3dShapeFactory implements S2ShapeFactory {
    */
   private class Geo3dPolygonBuilder extends Geo3dPointBuilder<PolygonBuilder> implements
PolygonBuilder {
 
-    List<GeoPolygon> polyHoles;
+    List<GeoPolygonFactory.PolygonDescription> polyHoles = new ArrayList<>();
 
     @Override
     public HoleBuilder hole() {
@@ -321,10 +321,7 @@ public class Geo3dShapeFactory implements S2ShapeFactory {
     class Geo3dHoleBuilder extends Geo3dPointBuilder<PolygonBuilder.HoleBuilder> implements
PolygonBuilder.HoleBuilder {
       @Override
       public PolygonBuilder endHole() {
-        if (polyHoles == null) {
-          polyHoles = new ArrayList<>();
-        }
-        polyHoles.add(GeoPolygonFactory.makeGeoPolygon(planetModel, points));
+        polyHoles.add(new GeoPolygonFactory.PolygonDescription(points));
         return Geo3dPolygonBuilder.this;
       }
     }
@@ -332,7 +329,8 @@ public class Geo3dShapeFactory implements S2ShapeFactory {
     @SuppressWarnings("unchecked")
     @Override
     public Shape build() {
-      GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(planetModel, points, polyHoles);
+      GeoPolygonFactory.PolygonDescription description = new GeoPolygonFactory.PolygonDescription(points,
polyHoles);
+      GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(planetModel, description);
       return new Geo3dShape<>(polygon, context);
     }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/af7dfb18/lucene/spatial-extras/src/test/org/apache/lucene/spatial/spatial4j/Geo3dRptTest.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/spatial4j/Geo3dRptTest.java
b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/spatial4j/Geo3dRptTest.java
index d3b144f..eb6ed5b 100644
--- a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/spatial4j/Geo3dRptTest.java
+++ b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/spatial4j/Geo3dRptTest.java
@@ -18,9 +18,11 @@ package org.apache.lucene.spatial.spatial4j;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 import com.carrotsearch.randomizedtesting.annotations.Repeat;
+import org.apache.lucene.spatial.SpatialTestData;
 import org.apache.lucene.spatial.composite.CompositeSpatialStrategy;
 import org.apache.lucene.spatial.prefix.RandomSpatialOpStrategyTestCase;
 import org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy;
@@ -96,7 +98,7 @@ public class Geo3dRptTest extends RandomSpatialOpStrategyTestCase {
     points.add(new GeoPoint(planetModel, 14 * DEGREES_TO_RADIANS, -180 * DEGREES_TO_RADIANS));
     points.add(new GeoPoint(planetModel, -15 * DEGREES_TO_RADIANS, 153 * DEGREES_TO_RADIANS));
 
-    final Shape triangle = new Geo3dShape(GeoPolygonFactory.makeGeoPolygon(planetModel, points),ctx);
+    final Shape triangle = new Geo3dShape<>(GeoPolygonFactory.makeGeoPolygon(planetModel,
points),ctx);
     final Rectangle rect = ctx.makeRectangle(-49, -45, 73, 86);
     testOperation(rect,SpatialOperation.Intersects,triangle, false);
   }
@@ -116,7 +118,7 @@ public class Geo3dRptTest extends RandomSpatialOpStrategyTestCase {
         new GeoPoint(planetModel, 54.0 * DEGREES_TO_RADIANS, 165.0 * DEGREES_TO_RADIANS),
         new GeoPoint(planetModel, -90.0 * DEGREES_TO_RADIANS, 0.0)};
     final GeoPath path = GeoPathFactory.makeGeoPath(planetModel, 29 * DEGREES_TO_RADIANS,
pathPoints);
-    final Shape shape = new Geo3dShape(path,ctx);
+    final Shape shape = new Geo3dShape<>(path,ctx);
     final Rectangle rect = ctx.makeRectangle(131, 143, 39, 54);
     testOperation(rect,SpatialOperation.Intersects,shape,true);
   }
@@ -146,6 +148,23 @@ public class Geo3dRptTest extends RandomSpatialOpStrategyTestCase {
     return new Geo3dShape<>(areaShape, ctx);
   }
 
+  @Test
+  public void testOperationsFromFile() throws IOException {
+    setupStrategy();
+    final Iterator<SpatialTestData> indexedSpatialData = getSampleData( "states-poly.txt");
+    final List<Shape> indexedShapes = new ArrayList<>();
+    while(indexedSpatialData.hasNext()) {
+      indexedShapes.add(indexedSpatialData.next().shape);
+    }
+    final Iterator<SpatialTestData> querySpatialData = getSampleData( "states-bbox.txt");
+    final List<Shape> queryShapes = new ArrayList<>();
+    while(querySpatialData.hasNext()) {
+      queryShapes.add(querySpatialData.next().shape);
+      queryShapes.add(randomQueryShape());
+    }
+    testOperation(SpatialOperation.Intersects, indexedShapes, queryShapes, random().nextBoolean());
+  }
+
   //TODO move to a new test class?
   @Test
   public void testWKT() throws Exception {


Mime
View raw message