Index: lucene/spatial/src/test/org/apache/lucene/spatial/vector/TestTwoDoublesStrategy.java =================================================================== --- lucene/spatial/src/test/org/apache/lucene/spatial/vector/TestTwoDoublesStrategy.java (revision 1354461) +++ lucene/spatial/src/test/org/apache/lucene/spatial/vector/TestTwoDoublesStrategy.java (working copy) @@ -18,7 +18,15 @@ package org.apache.lucene.spatial.vector; import com.spatial4j.core.context.simple.SimpleSpatialContext; +import com.spatial4j.core.exception.InvalidShapeException; +import com.spatial4j.core.query.SpatialArgs; +import com.spatial4j.core.query.SpatialOperation; +import com.spatial4j.core.shape.Circle; +import com.spatial4j.core.shape.Point; +import com.spatial4j.core.shape.simple.CircleImpl; +import com.spatial4j.core.shape.simple.PointImpl; import org.apache.lucene.search.FieldCache; +import org.apache.lucene.search.Query; import org.apache.lucene.spatial.SpatialMatchConcern; import org.apache.lucene.spatial.StrategyTestCase; import org.apache.lucene.spatial.util.NumericFieldInfo; @@ -40,6 +48,22 @@ } @Test + public void testCircleShapeSupport() { + Circle circle = new CircleImpl(new PointImpl(0, 0), 10, this.ctx); + SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle); + Query query = this.strategy.makeQuery(args, this.fieldInfo); + + assertNotNull(query); + } + + @Test(expected = InvalidShapeException.class) + public void testInvalidQueryShape() { + Point point = new PointImpl(0, 0); + SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, point); + this.strategy.makeQuery(args, this.fieldInfo); + } + + @Test public void testCitiesWithinBBox() throws IOException { getAddAndVerifyIndexedDocuments(DATA_WORLD_CITIES_POINTS); executeQueries(SpatialMatchConcern.FILTER, QTEST_Cities_IsWithin_BBox); Index: lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java =================================================================== --- lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java (revision 1354461) +++ lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java (working copy) @@ -113,10 +113,13 @@ public Query makeQuery(SpatialArgs args, TwoDoublesFieldInfo fieldInfo) { // For starters, just limit the bbox Shape shape = args.getShape(); - if (!(shape instanceof Rectangle)) { - throw new InvalidShapeException("A rectangle is the only supported shape (so far), not "+shape.getClass());//TODO + if (!(shape instanceof Rectangle || shape instanceof Circle)) { + throw new InvalidShapeException("Only Rectangles and Circles are currently supported, " + + "found [" + shape.getClass() + "]");//TODO } - Rectangle bbox = (Rectangle) shape; + + Rectangle bbox = shape.getBoundingBox(); + if (bbox.getCrossesDateLine()) { throw new UnsupportedOperationException( "Crossing dateline not yet supported" ); }