nknize commented on a change in pull request #1170: LUCENE-9141: Simplify 
LatLonShapeXQuery API.
URL: https://github.com/apache/lucene-solr/pull/1170#discussion_r372475804
 
 

 ##########
 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:
   nit: do you think we could just name this `newGeometryQuery`? This way we 
just treat geometries and single and/or collections? Feels a little less 
confusing IMHO.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to