Helper method for Geo Within Box
@@ -52,4 +52,22 @@ public final class MongodbExpressions {
return Expressions.booleanOperation(MongodbOps.NEAR_SPHERE, expr, ConstantImpl.create(new Double[]{latVal, longVal}));
}
+ /**
+ * Finds points within bounds of the rectangle
+ *
+ * @param blLatVal bottom left latitude
+ * @param blLongVal bottom left longitude
+ * @param urLatVal upper right latitude
+ * @param urLongVal upper right longitude
+ * @return predicate
+ */
+ public static BooleanExpression withinBox(Expression<Double[]> expr, double blLongVal, double blLatVal, double urLongVal, double urLatVal) {
+ return Expressions.booleanOperation(
+ MongodbOps.GEO_WITHIN_BOX,
+ expr,
+ ConstantImpl.create(new Double[]{blLongVal, blLatVal}),
+ ConstantImpl.create(new Double[]{urLongVal, urLatVal})
+ );
+ }
+
}
