Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-7170: move BaseGeoPointTestCase to test-framework

Robert Muir72cb73c6b94c
diff --git a/dev-tools/maven/lucene/sandbox/pom.xml.template b/dev-tools/maven/lucene/sandbox/pom.xml.template
index d357c6465e4..baa8a3c04db 100644
--- a/dev-tools/maven/lucene/sandbox/pom.xml.template
+++ b/dev-tools/maven/lucene/sandbox/pom.xml.template
@@ -48,13 +48,6 @@
<artifactId>lucene-test-framework</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-spatial</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
@lucene-sandbox.internal.dependencies@
@lucene-sandbox.external.dependencies@
@lucene-sandbox.internal.test.dependencies@
diff --git a/lucene/sandbox/build.xml b/lucene/sandbox/build.xml
index 4323241e2ed..93bc2754ece 100644
--- a/lucene/sandbox/build.xml
+++ b/lucene/sandbox/build.xml
@@ -23,39 +23,4 @@
<import file="../module-build.xml"/>
- <target name="compile-test-spatial" depends="init" if="module.has.tests">
- <ant dir="${common.dir}/spatial" target="compile-test" inheritAll="false"/>
- </target>
-
- <path id="classpath">
- <path refid="base.classpath"/>
- <pathelement path="${spatial.jar}"/>
- </path>
- <target name="compile-core" depends="jar-spatial,common.compile-core" />
-
- <path id="test.classpath">
- <pathelement location="${build.dir}/classes/java"/>
- <pathelement location="${build.dir}/classes/test"/>
- <pathelement location="${common.dir}/build/spatial/classes/test"/>
- <path refid="test.base.classpath"/>
- <pathelement path="${spatial.jar}"/>
- <path refid="junit-path"/>
- </path>
-
- <path id="junit.classpath">
- <path refid="test.classpath"/>
- <pathelement path="${java.class.path}"/>
- </path>
-
- <target name="javadocs" depends="javadocs-spatial,compile-core,check-javadocs-uptodate"
- unless="javadocs-uptodate-${name}">
- <invoke-module-javadoc>
- <links>
- <link href="../spatial"/>
- </links>
- </invoke-module-javadoc>
- </target>
-
- <target name="compile-test" depends="jar-spatial,compile-test-spatial,common.compile-test" />
-
</project>
diff --git a/lucene/sandbox/src/test/org/apache/lucene/search/TestLatLonPointQueries.java b/lucene/sandbox/src/test/org/apache/lucene/search/TestLatLonPointQueries.java
index 8c909e6b593..39c7a045832 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/search/TestLatLonPointQueries.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/search/TestLatLonPointQueries.java
@@ -18,7 +18,7 @@ package org.apache.lucene.search;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.LatLonPoint;
-import org.apache.lucene.spatial.util.BaseGeoPointTestCase;
+import org.apache.lucene.geo.BaseGeoPointTestCase;
import org.apache.lucene.geo.Polygon;
import org.apache.lucene.geo.GeoEncodingUtils;
diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestGeoPointQuery.java b/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestGeoPointQuery.java
index 7e64430be41..e5b766daa64 100644
--- a/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestGeoPointQuery.java
+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestGeoPointQuery.java
@@ -19,11 +19,11 @@ package org.apache.lucene.spatial.geopoint.search;
import org.apache.lucene.document.Document;
import org.apache.lucene.search.Query;
import org.apache.lucene.spatial.util.GeoEncodingUtils;
+import org.apache.lucene.geo.BaseGeoPointTestCase;
import org.apache.lucene.geo.Polygon;
import org.apache.lucene.geo.Rectangle;
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
import org.apache.lucene.spatial.geopoint.document.GeoPointField.TermEncoding;
-import org.apache.lucene.spatial.util.BaseGeoPointTestCase;
/**
* random testing for GeoPoint query logic
diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestLegacyGeoPointQuery.java b/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestLegacyGeoPointQuery.java
index 75cc377d0e5..d0b57fe9d4f 100644
--- a/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestLegacyGeoPointQuery.java
+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestLegacyGeoPointQuery.java
@@ -19,11 +19,11 @@ package org.apache.lucene.spatial.geopoint.search;
import org.apache.lucene.document.Document;
import org.apache.lucene.search.Query;
import org.apache.lucene.spatial.util.GeoEncodingUtils;
+import org.apache.lucene.geo.BaseGeoPointTestCase;
import org.apache.lucene.geo.Polygon;
import org.apache.lucene.geo.Rectangle;
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
import org.apache.lucene.spatial.geopoint.document.GeoPointField.TermEncoding;
-import org.apache.lucene.spatial.util.BaseGeoPointTestCase;
/**
* random testing for GeoPoint query logic (with deprecated numeric encoding)
diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/geo/BaseGeoPointTestCase.java
similarity index 99%
rename from lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
rename to lucene/test-framework/src/java/org/apache/lucene/geo/BaseGeoPointTestCase.java
index daf3cbda197..dbdf189f3c4 100644
--- a/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/geo/BaseGeoPointTestCase.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.lucene.spatial.util;
+package org.apache.lucene.geo;
import java.io.IOException;
import java.text.DecimalFormat;
@@ -771,13 +771,16 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
static final boolean rectContainsPoint(Rectangle rect, double pointLat, double pointLon) {
assert Double.isNaN(pointLat) == false;
+
+ if (pointLat < rect.minLat || pointLat > rect.maxLat) {
+ return false;
+ }
if (rect.minLon <= rect.maxLon) {
- return GeoRelationUtils.pointInRectPrecise(pointLat, pointLon, rect.minLat, rect.maxLat, rect.minLon, rect.maxLon);
+ return pointLon >= rect.minLon && pointLon <= rect.maxLon;
} else {
// Rect crosses dateline:
- return GeoRelationUtils.pointInRectPrecise(pointLat, pointLon, rect.minLat, rect.maxLat, -180.0, rect.maxLon)
- || GeoRelationUtils.pointInRectPrecise(pointLat, pointLon, rect.minLat, rect.maxLat, rect.minLon, 180.0);
+ return pointLon <= rect.maxLon || pointLon >= rect.minLon;
}
}