You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by iv...@apache.org on 2018/06/06 09:45:39 UTC
lucene-solr:branch_7x: LUCENE-8299: Geo3D wrapper uses new polygon
method factory that gives better support for polygons with many points (>100)
Repository: lucene-solr
Updated Branches:
refs/heads/branch_7x d0e9284a7 -> 0de00d505
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/0de00d50
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/0de00d50
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/0de00d50
Branch: refs/heads/branch_7x
Commit: 0de00d5055e035e4e5217f6cbdd8f97bd2dec618
Parents: d0e9284
Author: Ignacio Vera <iv...@apache.org>
Authored: Wed Jun 6 11:44:57 2018 +0200
Committer: Ignacio Vera <iv...@apache.org>
Committed: Wed Jun 6 11:44:57 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/0de00d50/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 90de0e1..6a1fd1a 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -163,6 +163,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/0de00d50/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/0de00d50/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 e7f9c2a..0e0ca8a 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 {