18 #include "mongo/client/export_macros.h"
27 template <
typename TCoordinates>
28 inline BSONObj GEOQUERY(
const char* op,
const GeoObj<TCoordinates>& geoObj) {
29 return BSON(op << BSON(
"$geometry" << geoObj.toBSON()));
32 template <
typename TCoordinates>
33 inline BSONObj WITHINQUERY(
const GeoObj<TCoordinates>& geoObj) {
34 return GEOQUERY(
"$geoWithin", geoObj);
37 template <
typename TCoordinates>
38 inline BSONObj WITHINQUERY(
const BoundingBox<TCoordinates>& geoBB) {
39 return BSON(
"$geoWithin" << BSON(
"$box" << geoBB.toNestedBSONArray()));
42 template <
typename TCoordinates>
43 inline BSONObj INTERSECTSQUERY(
const GeoObj<TCoordinates>& geoObj) {
44 return GEOQUERY(
"$geoIntersects", geoObj);
47 template <
typename TCoordinates>
48 inline BSONObj NEARQUERY(
const GeoObj<TCoordinates>& geoObj) {
49 return GEOQUERY(
"$near", geoObj);
52 template <
typename TCoordinates>
53 inline BSONObj NEARQUERY(
const GeoObj<TCoordinates>& geoObj,
double maxDistance) {
54 uassert(0,
"$maxDistance param to $near query must be non-negative.", maxDistance >= 0.0);
55 return BSON(
"$near" << BSON(
"$geometry" << geoObj.toBSON() <<
"$maxDistance" << maxDistance));
58 template <
typename TCoordinates>
59 inline BSONObj NEARSPHEREQUERY(
const GeoObj<TCoordinates>& geoObj) {
60 return GEOQUERY(
"$nearSphere", geoObj);
63 template <
typename TCoordinates>
64 inline BSONObj NEARSPHEREQUERY(
const GeoObj<TCoordinates>& geoObj,
double maxDistance) {
65 uassert(0,
"$maxDistance param to $nearSphere query must be non-negative.", maxDistance >= 0.0);
67 "$nearSphere" << BSON(
"$geometry" << geoObj.toBSON() <<
"$maxDistance" << maxDistance));
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20