From 72cb73c6b94c56e870f9b8f474c2be1b90624b1d Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Sun, 17 Apr 2016 08:52:59 -0400 Subject: [PATCH] LUCENE-7170: move BaseGeoPointTestCase to test-framework --- .../maven/lucene/sandbox/pom.xml.template | 7 ---- lucene/sandbox/build.xml | 35 ------------------- .../lucene/search/TestLatLonPointQueries.java | 2 +- .../geopoint/search/TestGeoPointQuery.java | 2 +- .../search/TestLegacyGeoPointQuery.java | 2 +- .../lucene/geo}/BaseGeoPointTestCase.java | 11 +++--- 6 files changed, 10 insertions(+), 49 deletions(-) rename lucene/{spatial/src/test/org/apache/lucene/spatial/util => test-framework/src/java/org/apache/lucene/geo}/BaseGeoPointTestCase.java (99%) 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 @@ lucene-test-framework test - - org.apache.lucene - lucene-spatial - ${project.version} - test-jar - test - @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 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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; } }