iverase commented on a change in pull request #2155: URL: https://github.com/apache/lucene-solr/pull/2155#discussion_r547165818
########## File path: lucene/core/src/java/org/apache/lucene/document/LatLonPointQuery.java ########## @@ -0,0 +1,174 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.lucene.document; + +import org.apache.lucene.document.ShapeField.QueryRelation; +import org.apache.lucene.geo.Component2D; +import org.apache.lucene.geo.GeoEncodingUtils; +import org.apache.lucene.geo.LatLonGeometry; +import org.apache.lucene.geo.Line; +import org.apache.lucene.index.PointValues.Relation; +import org.apache.lucene.util.NumericUtils; + +import java.util.Arrays; +import java.util.function.Function; +import java.util.function.Predicate; + +import static org.apache.lucene.geo.GeoEncodingUtils.decodeLatitude; +import static org.apache.lucene.geo.GeoEncodingUtils.decodeLongitude; +import static org.apache.lucene.geo.GeoEncodingUtils.encodeLatitude; +import static org.apache.lucene.geo.GeoEncodingUtils.encodeLongitude; + +/** + * Finds all previously indexed geo points that comply the given {@link QueryRelation} with + * the specified array of {@link LatLonGeometry}. + * + * <p>The field must be indexed using one or more {@link LatLonPoint} added per document. + * + **/ +final class LatLonPointQuery extends SpatialQuery { + final private LatLonGeometry[] geometries; + final private Component2D component2D; + + /** + * Creates a query that matches all indexed shapes to the provided array of {@link LatLonGeometry} + */ + LatLonPointQuery(String field, QueryRelation queryRelation, LatLonGeometry... geometries) { + super(field, queryRelation); + if (queryRelation == QueryRelation.WITHIN) { + for (LatLonGeometry geometry : geometries) { + if (geometry instanceof Line) { + // TODO: line queries do not support within relations + throw new IllegalArgumentException("LatLonPointQuery does not support " + QueryRelation.WITHIN + " queries with line geometries"); + } + } + } + this.component2D = LatLonGeometry.create(geometries); + this.geometries = geometries.clone(); + } + + @Override + protected SpatialVisitor getSpatialVisitor() { + if (component2D.getMinY() > component2D.getMaxY()) { + // encodeLatitudeCeil may cause minY to be > maxY iff + // the delta between the longitude < the encoding resolution + return EMPTYVISITOR; Review comment: The problem was in the way the component predicate is built. I have another thought and I think I push a better solution in 1cebeff ---------------------------------------------------------------- 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 --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org