Skip to content

Commit

Permalink
Adding a within bounding box search to QueryBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlaurent committed Oct 22, 2010
1 parent 43eeba7 commit 63442cb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/com/mongodb/QueryBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 ){
Expand Down

0 comments on commit 63442cb

Please sign in to comment.