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/29 19:33:18 UTC
[1/2] lucene-solr:master: LUCENE-7241: Add public functionality for
handling large polygons in geo3d.
Repository: lucene-solr
Updated Branches:
refs/heads/master 48f2b2a3b -> 7ed472fb5
LUCENE-7241: Add public functionality for handling large polygons in geo3d.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/595a55bb
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/595a55bb
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/595a55bb
Branch: refs/heads/master
Commit: 595a55bbb54bdcf671e9563246302a93ee1d1f80
Parents: 7bc50ec
Author: Karl Wright <Da...@gmail.com>
Authored: Fri Apr 29 13:32:55 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Fri Apr 29 13:32:55 2016 -0400
----------------------------------------------------------------------
.../org/apache/lucene/spatial3d/Geo3DPoint.java | 57 +++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/595a55bb/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DPoint.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DPoint.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DPoint.java
index 0f2395c..42c513c 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DPoint.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DPoint.java
@@ -128,7 +128,8 @@ public final class Geo3DPoint extends Field {
}
/**
- * Create a query for matching a polygon.
+ * Create a query for matching a polygon. The polygon should have a limited number of edges (less than 100) and be well-defined,
+ * with well-separated vertices.
* <p>
* The supplied {@code polygons} must be clockwise on the outside level, counterclockwise on the next level in, etc.
* @param field field name. must not be null.
@@ -164,6 +165,23 @@ public final class Geo3DPoint extends Field {
}
/**
+ * Create a query for matching a large polygon. This differs from the related newPolygonQuery in that it
+ * does little or no legality checking and is optimized for very large numbers of polygon edges.
+ * <p>
+ * The supplied {@code polygons} must be clockwise on the outside level, counterclockwise on the next level in, etc.
+ * @param field field name. must not be null.
+ * @param polygons is the list of polygons to use to construct the query; must be at least one.
+ * @return query matching points within this polygon
+ */
+ public static Query newLargePolygonQuery(final String field, final Polygon... polygons) {
+ if (polygons.length < 1) {
+ throw new IllegalArgumentException("need at least one polygon");
+ }
+ final GeoShape shape = fromLargePolygon(polygons);
+ return newShapeQuery(field, shape);
+ }
+
+ /**
* Create a query for matching a path.
* <p>
* @param field field name. must not be null.
@@ -189,6 +207,43 @@ public final class Geo3DPoint extends Field {
}
/**
+ * Convert a Polygon object to a large GeoPolygon.
+ * @param polygons is the list of polygons to convert.
+ * @return the large GeoPolygon.
+ */
+ private static GeoPolygon fromLargePolygon(final Polygon... polygons) {
+ return GeoPolygonFactory.makeLargeGeoPolygon(PlanetModel.WGS84, convertToDescription(polygons));
+ }
+
+ /**
+ * Convert a list of polygons to a list of polygon descriptions.
+ * @param polygons is the list of polygons to convert.
+ * @return the list of polygon descriptions.
+ */
+ private static List<GeoPolygonFactory.PolygonDescription> convertToDescription(final Polygon... polygons) {
+ final List<GeoPolygonFactory.PolygonDescription> descriptions = new ArrayList<>(polygons.length);
+ for (final Polygon polygon : polygons) {
+ final Polygon[] theHoles = polygon.getHoles();
+ final List<GeoPolygonFactory.PolygonDescription> holes = convertToDescription(theHoles);
+
+ // Now do the polygon itself
+ final double[] polyLats = polygon.getPolyLats();
+ final double[] polyLons = polygon.getPolyLons();
+
+ // I presume the arguments have already been checked
+ final List<GeoPoint> points = new ArrayList<>(polyLats.length-1);
+ // We skip the last point anyway because the API requires it to be repeated, and geo3d doesn't repeat it.
+ for (int i = 0; i < polyLats.length - 1; i++) {
+ final int index = polyLats.length - 2 - i;
+ points.add(new GeoPoint(PlanetModel.WGS84, fromDegrees(polyLats[index]), fromDegrees(polyLons[index])));
+ }
+
+ descriptions.add(new GeoPolygonFactory.PolygonDescription(points, holes));
+ }
+ return descriptions;
+ }
+
+ /**
* Convert a Polygon object into a GeoPolygon.
* This method uses
* @param polygon is the Polygon object.
[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/7ed472fb
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/7ed472fb
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/7ed472fb
Branch: refs/heads/master
Commit: 7ed472fb52eb7159385bd06324d3cc6f3ec26f12
Parents: 595a55b 48f2b2a
Author: Karl Wright <Da...@gmail.com>
Authored: Fri Apr 29 13:33:09 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Fri Apr 29 13:33:09 2016 -0400
----------------------------------------------------------------------
dev-tools/scripts/addVersion.py | 5 +-
dev-tools/scripts/scriptutil.py | 5 ++
lucene/CHANGES.txt | 4 +-
.../codecs/simpletext/SimpleTextBKDReader.java | 2 +
.../apache/lucene/search/PointInSetQuery.java | 14 ++--
.../apache/lucene/search/PointRangeQuery.java | 8 ++-
.../org/apache/lucene/util/DocIdSetBuilder.java | 73 ++++++++++++--------
.../lucene/search/TestReqExclBulkScorer.java | 6 +-
.../apache/lucene/util/TestDocIdSetBuilder.java | 13 ++--
.../GeoPointTermQueryConstantScoreWrapper.java | 8 ++-
.../spatial3d/PointInShapeIntersectVisitor.java | 7 +-
.../codecs/asserting/AssertingPointsFormat.java | 5 ++
.../solr/search/GraphTermsQParserPlugin.java | 50 +++++++-------
.../solr/cloud/TestMiniSolrCloudClusterSSL.java | 3 +-
14 files changed, 121 insertions(+), 82 deletions(-)
----------------------------------------------------------------------