You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/01/29 16:32:33 UTC
[GitHub] [lucene-solr] iverase commented on a change in pull request #1170:
LUCENE-9141: Simplify LatLonShapeXQuery API.
iverase commented on a change in pull request #1170: LUCENE-9141: Simplify LatLonShapeXQuery API.
URL: https://github.com/apache/lucene-solr/pull/1170#discussion_r372492736
##########
File path: lucene/core/src/java/org/apache/lucene/document/LatLonShape.java
##########
@@ -107,40 +111,36 @@ public static Query newBoxQuery(String field, QueryRelation queryRelation, doubl
* note: does not support dateline crossing
**/
public static Query newLineQuery(String field, QueryRelation queryRelation, Line... lines) {
- if (queryRelation == QueryRelation.CONTAINS && lines.length > 1) {
- BooleanQuery.Builder builder = new BooleanQuery.Builder();
- for (int i =0; i < lines.length; i++) {
- builder.add(newLineQuery(field, queryRelation, lines[i]), BooleanClause.Occur.MUST);
- }
- return builder.build();
- }
- return new LatLonShapeLineQuery(field, queryRelation, lines);
+ return newGeometryCollectionQuery(field, queryRelation, lines);
}
/** create a query to find all indexed geo shapes that intersect a provided polygon (or array of polygons)
* note: does not support dateline crossing
**/
public static Query newPolygonQuery(String field, QueryRelation queryRelation, Polygon... polygons) {
- if (queryRelation == QueryRelation.CONTAINS && polygons.length > 1) {
- BooleanQuery.Builder builder = new BooleanQuery.Builder();
- for (int i =0; i < polygons.length; i++) {
- builder.add(newPolygonQuery(field, queryRelation, polygons[i]), BooleanClause.Occur.MUST);
- }
- return builder.build();
- }
- return new LatLonShapePolygonQuery(field, queryRelation, polygons);
+ return newGeometryCollectionQuery(field, queryRelation, polygons);
}
- /** create a query to find all indexed shapes that comply the {@link QueryRelation} with the provided point
+ /** create a query to find all indexed shapes that comply the {@link QueryRelation} with the provided points
**/
public static Query newPointQuery(String field, QueryRelation queryRelation, double[]... points) {
- if (queryRelation == QueryRelation.CONTAINS && points.length > 1) {
+ Point[] pointArray = new Point[points.length];
+ for (int i =0; i < points.length; i++) {
+ pointArray[i] = new Point(points[i][0], points[i][1]);
+ }
+ return newGeometryCollectionQuery(field, queryRelation, pointArray);
+ }
+
+ /** create a query to find all indexed geo shapes that intersect a provided geometry collection.
+ **/
+ public static Query newGeometryCollectionQuery(String field, QueryRelation queryRelation, LatLonGeometry... latLonGeometries) {
Review comment:
Yes, I think it is a better name
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org