Permalink
Browse files

Adding a within bounding box search to QueryBuilder

  • Loading branch information...
1 parent 43eeba7 commit 63442cb5823dd31700b5af7d9a0320a1132394ea @jeanlaurent jeanlaurent committed Oct 22, 2010
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/main/com/mongodb/QueryBuilder.java
@@ -215,6 +215,21 @@ public QueryBuilder near( double x , double y , double maxDistance ){
new Double[]{ x , y , maxDistance } );
return this;
}
+
+ /**
+ * Append a within bounding box search using a two corners to the current QueryBuilder.
+ *
+ * @param x the x coordinate of the first box corner.
+ * @param y the y coordinate of the first box corner.
+ * @param xx the x coordinate of the second box corner.
+ * @param yy the y coordinate of the second box corner.
+ * @return the current QueryBuilder with an appended within bounding box search.
+ */
+ public QueryBuilder withinBox(double x, double y, double xx, double yy) {
+ addOperand( "$within" ,
+ new BasicDBObject( "$box" , new Object[] { new Double[] { x, y }, new Double[] { xx, yy } } ) );
+ return this;
+ }
public QueryBuilder or( DBObject ... ors ){

0 comments on commit 63442cb

Please sign in to comment.