Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5EF2AD71D for ; Wed, 12 Sep 2012 05:03:43 +0000 (UTC) Received: (qmail 7948 invoked by uid 500); 12 Sep 2012 05:03:37 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 7909 invoked by uid 99); 12 Sep 2012 05:03:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Sep 2012 05:03:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Sep 2012 05:03:33 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id CA6D823888FE; Wed, 12 Sep 2012 05:02:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1383773 - in /lucene/dev/trunk/lucene/spatial/src: java/org/apache/lucene/spatial/prefix/ java/org/apache/lucene/spatial/query/ test-files/ test/org/apache/lucene/spatial/ test/org/apache/lucene/spatial/bbox/ test/org/apache/lucene/spatial... Date: Wed, 12 Sep 2012 05:02:50 -0000 To: commits@lucene.apache.org From: dsmiley@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120912050250.CA6D823888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dsmiley Date: Wed Sep 12 05:02:49 2012 New Revision: 1383773 URL: http://svn.apache.org/viewvc?rev=1383773&view=rev Log: LUCENE-4375 Fix use of BBoxWithin BBoxIntersects and IsWithin Added: lucene/dev/trunk/lucene/spatial/src/test-files/cities-Intersects-BBox.txt - copied, changed from r1383734, lucene/dev/trunk/lucene/spatial/src/test-files/cities-IsWithin-BBox.txt Removed: lucene/dev/trunk/lucene/spatial/src/test-files/cities-IsWithin-BBox.txt Modified: lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/TermQueryPrefixTreeStrategy.java lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgs.java lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialOperation.java lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/TestTestFramework.java lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/vector/TestTwoDoublesStrategy.java Modified: lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java?rev=1383773&r1=1383772&r2=1383773&view=diff ============================================================================== --- lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java (original) +++ lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java Wed Sep 12 05:02:49 2012 @@ -51,7 +51,7 @@ public class RecursivePrefixTreeStrategy @Override public Filter makeFilter(SpatialArgs args) { final SpatialOperation op = args.getOperation(); - if (! SpatialOperation.is(op, SpatialOperation.IsWithin, SpatialOperation.Intersects, SpatialOperation.BBoxWithin, SpatialOperation.BBoxIntersects)) + if (op != SpatialOperation.Intersects) throw new UnsupportedSpatialOperation(op); Shape shape = args.getShape(); @@ -59,7 +59,7 @@ public class RecursivePrefixTreeStrategy int detailLevel = grid.getLevelForDistance(args.resolveDistErr(ctx, distErrPct)); return new RecursivePrefixTreeFilter( - getFieldName(), grid,shape, prefixGridScanLevel, detailLevel); + getFieldName(), grid, shape, prefixGridScanLevel, detailLevel); } } Modified: lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/TermQueryPrefixTreeStrategy.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/TermQueryPrefixTreeStrategy.java?rev=1383773&r1=1383772&r2=1383773&view=diff ============================================================================== --- lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/TermQueryPrefixTreeStrategy.java (original) +++ lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/TermQueryPrefixTreeStrategy.java Wed Sep 12 05:02:49 2012 @@ -44,7 +44,7 @@ public class TermQueryPrefixTreeStrategy @Override public Filter makeFilter(SpatialArgs args) { final SpatialOperation op = args.getOperation(); - if (! SpatialOperation.is(op, SpatialOperation.IsWithin, SpatialOperation.Intersects, SpatialOperation.BBoxWithin, SpatialOperation.BBoxIntersects)) + if (op != SpatialOperation.Intersects) throw new UnsupportedSpatialOperation(op); Shape shape = args.getShape(); Modified: lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgs.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgs.java?rev=1383773&r1=1383772&r2=1383773&view=diff ============================================================================== --- lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgs.java (original) +++ lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgs.java Wed Sep 12 05:02:49 2012 @@ -109,10 +109,7 @@ public class SpatialArgs { this.operation = operation; } - /** Considers {@link SpatialOperation#BBoxWithin} in returning the shape. */ public Shape getShape() { - if (shape != null && (operation == SpatialOperation.BBoxWithin || operation == SpatialOperation.BBoxIntersects)) - return shape.getBoundingBox(); return shape; } Modified: lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialOperation.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialOperation.java?rev=1383773&r1=1383772&r2=1383773&view=diff ============================================================================== --- lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialOperation.java (original) +++ lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialOperation.java Wed Sep 12 05:02:49 2012 @@ -38,7 +38,10 @@ public class SpatialOperation implements private static final List list = new ArrayList(); // Geometry Operations + + /** Bounding box of the *indexed* shape. */ public static final SpatialOperation BBoxIntersects = new SpatialOperation("BBoxIntersects", true, false, false); + /** Bounding box of the *indexed* shape. */ public static final SpatialOperation BBoxWithin = new SpatialOperation("BBoxWithin", true, false, false); public static final SpatialOperation Contains = new SpatialOperation("Contains", true, true, false); public static final SpatialOperation Intersects = new SpatialOperation("Intersects", true, false, false); Copied: lucene/dev/trunk/lucene/spatial/src/test-files/cities-Intersects-BBox.txt (from r1383734, lucene/dev/trunk/lucene/spatial/src/test-files/cities-IsWithin-BBox.txt) URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/test-files/cities-Intersects-BBox.txt?p2=lucene/dev/trunk/lucene/spatial/src/test-files/cities-Intersects-BBox.txt&p1=lucene/dev/trunk/lucene/spatial/src/test-files/cities-IsWithin-BBox.txt&r1=1383734&r2=1383773&rev=1383773&view=diff ============================================================================== --- lucene/dev/trunk/lucene/spatial/src/test-files/cities-IsWithin-BBox.txt (original) +++ lucene/dev/trunk/lucene/spatial/src/test-files/cities-Intersects-BBox.txt Wed Sep 12 05:02:49 2012 @@ -1,6 +1,6 @@ -[San Francisco] G5391959 @ IsWithin(-122.524918 37.674973 -122.360123 37.817108) -[Wellington] G2179537 @ IsWithin(174.711456 -41.360779 174.854279 -41.213837) -[Barcelona] G6544100 G3128760 @ IsWithin(2.127228 41.333313 2.226105 41.408844) +[San Francisco] G5391959 @ Intersects(-122.524918 37.674973 -122.360123 37.817108) +[Wellington] G2179537 @ Intersects(174.711456 -41.360779 174.854279 -41.213837) +[Barcelona] G6544100 G3128760 @ Intersects(2.127228 41.333313 2.226105 41.408844) Modified: lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java?rev=1383773&r1=1383772&r2=1383773&view=diff ============================================================================== --- lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java (original) +++ lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java Wed Sep 12 05:02:49 2012 @@ -192,7 +192,6 @@ public class PortedSolr3Test extends Str addDocument(newDoc(idStr,shape)); } - @SuppressWarnings("unchecked") private Document newDoc(String id, Shape shape) { Document doc = new Document(); doc.add(new StringField("id", id, Field.Store.YES)); @@ -205,17 +204,19 @@ public class PortedSolr3Test extends Str } private void checkHitsCircle(String ptStr, double distKM, int assertNumFound, int... assertIds) { - _checkHits(SpatialOperation.Intersects, ptStr, distKM, assertNumFound, assertIds); + _checkHits(false, ptStr, distKM, assertNumFound, assertIds); } private void checkHitsBBox(String ptStr, double distKM, int assertNumFound, int... assertIds) { - _checkHits(SpatialOperation.BBoxIntersects, ptStr, distKM, assertNumFound, assertIds); + _checkHits(true, ptStr, distKM, assertNumFound, assertIds); } - @SuppressWarnings("unchecked") - private void _checkHits(SpatialOperation op, String ptStr, double distKM, int assertNumFound, int... assertIds) { + private void _checkHits(boolean bbox, String ptStr, double distKM, int assertNumFound, int... assertIds) { + SpatialOperation op = SpatialOperation.Intersects; Point pt = (Point) new ShapeReadWriter(ctx).readShape(ptStr); double distDEG = DistanceUtils.dist2Degrees(distKM, DistanceUtils.EARTH_MEAN_RADIUS_KM); Shape shape = ctx.makeCircle(pt, distDEG); + if (bbox) + shape = shape.getBoundingBox(); SpatialArgs args = new SpatialArgs(op,shape); //args.setDistPrecision(0.025); Modified: lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java?rev=1383773&r1=1383772&r2=1383773&view=diff ============================================================================== --- lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java (original) +++ lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java Wed Sep 12 05:02:49 2012 @@ -27,7 +27,6 @@ import org.apache.lucene.document.Docume import org.apache.lucene.document.Field; import org.apache.lucene.document.StoredField; import org.apache.lucene.document.StringField; -import org.apache.lucene.index.IndexableField; import org.apache.lucene.spatial.query.SpatialArgsParser; import org.junit.Assert; @@ -52,7 +51,7 @@ public abstract class StrategyTestCase e public static final String QTEST_States_IsWithin_BBox = "states-IsWithin-BBox.txt"; public static final String QTEST_States_Intersects_BBox = "states-Intersects-BBox.txt"; - public static final String QTEST_Cities_IsWithin_BBox = "cities-IsWithin-BBox.txt"; + public static final String QTEST_Cities_Intersects_BBox = "cities-Intersects-BBox.txt"; public static final String QTEST_Simple_Queries_BBox = "simple-Queries-BBox.txt"; private Logger log = Logger.getLogger(getClass().getName()); Modified: lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/TestTestFramework.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/TestTestFramework.java?rev=1383773&r1=1383772&r2=1383773&view=diff ============================================================================== --- lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/TestTestFramework.java (original) +++ lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/TestTestFramework.java Wed Sep 12 05:02:49 2012 @@ -18,7 +18,6 @@ package org.apache.lucene.spatial; */ import com.spatial4j.core.context.SpatialContext; -import com.spatial4j.core.context.SpatialContext; import com.spatial4j.core.shape.Rectangle; import org.apache.lucene.spatial.query.SpatialArgsParser; import org.apache.lucene.spatial.query.SpatialOperation; @@ -40,7 +39,7 @@ public class TestTestFramework extends L @Test public void testQueries() throws IOException { - String name = StrategyTestCase.QTEST_Cities_IsWithin_BBox; + String name = StrategyTestCase.QTEST_Cities_Intersects_BBox; InputStream in = getClass().getClassLoader().getResourceAsStream(name); SpatialContext ctx = SpatialContext.GEO; @@ -57,7 +56,7 @@ public class TestTestFramework extends L Assert.assertEquals( 1, sf.ids.size() ); Assert.assertTrue( sf.ids.get(0).equals( "G5391959" ) ); Assert.assertTrue( sf.args.getShape() instanceof Rectangle); - Assert.assertEquals( SpatialOperation.IsWithin, sf.args.getOperation() ); + Assert.assertEquals( SpatialOperation.Intersects, sf.args.getOperation() ); } } Modified: lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java?rev=1383773&r1=1383772&r2=1383773&view=diff ============================================================================== --- lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java (original) +++ lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java Wed Sep 12 05:02:49 2012 @@ -51,10 +51,10 @@ public class TestBBoxStrategy extends St } @Test - public void testCitiesWithinBBox() throws IOException { + public void testCitiesIntersectsBBox() throws IOException { getAddAndVerifyIndexedDocuments(DATA_WORLD_CITIES_POINTS); - executeQueries(SpatialMatchConcern.FILTER, QTEST_Cities_IsWithin_BBox); + executeQueries(SpatialMatchConcern.FILTER, QTEST_Cities_Intersects_BBox); } } Modified: lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java?rev=1383773&r1=1383772&r2=1383773&view=diff ============================================================================== --- lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java (original) +++ lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java Wed Sep 12 05:02:49 2012 @@ -61,7 +61,7 @@ public class TestRecursivePrefixTreeStra //execute queries for each prefix grid scan level for(int i = 0; i <= maxLength; i++) { ((RecursivePrefixTreeStrategy)strategy).setPrefixGridScanLevel(i); - executeQueries(SpatialMatchConcern.FILTER, QTEST_Cities_IsWithin_BBox); + executeQueries(SpatialMatchConcern.FILTER, QTEST_Cities_Intersects_BBox); } } Modified: lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java?rev=1383773&r1=1383772&r2=1383773&view=diff ============================================================================== --- lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java (original) +++ lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java Wed Sep 12 05:02:49 2012 @@ -18,7 +18,6 @@ package org.apache.lucene.spatial.prefix */ import com.spatial4j.core.context.SpatialContext; -import com.spatial4j.core.context.SpatialContext; import com.spatial4j.core.shape.Shape; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; @@ -55,7 +54,7 @@ public class TestTermQueryPrefixGridStra SpatialArgsParser spatialArgsParser = new SpatialArgsParser(); // TODO... use a non polygon query // SpatialArgs spatialArgs = spatialArgsParser.parse( -// "IsWithin(POLYGON((-127.00390625 39.8125,-112.765625 39.98828125,-111.53515625 31.375,-125.94921875 30.14453125,-127.00390625 39.8125)))", +// "Intersects(POLYGON((-127.00390625 39.8125,-112.765625 39.98828125,-111.53515625 31.375,-125.94921875 30.14453125,-127.00390625 39.8125)))", // new SimpleSpatialContext()); // Query query = prefixGridStrategy.makeQuery(spatialArgs, fieldInfo); Modified: lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/vector/TestTwoDoublesStrategy.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/vector/TestTwoDoublesStrategy.java?rev=1383773&r1=1383772&r2=1383773&view=diff ============================================================================== --- lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/vector/TestTwoDoublesStrategy.java (original) +++ lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/vector/TestTwoDoublesStrategy.java Wed Sep 12 05:02:49 2012 @@ -58,8 +58,8 @@ public class TestTwoDoublesStrategy exte } @Test - public void testCitiesWithinBBox() throws IOException { + public void testCitiesIntersectsBBox() throws IOException { getAddAndVerifyIndexedDocuments(DATA_WORLD_CITIES_POINTS); - executeQueries(SpatialMatchConcern.FILTER, QTEST_Cities_IsWithin_BBox); + executeQueries(SpatialMatchConcern.FILTER, QTEST_Cities_Intersects_BBox); } }