diff options
author | Hari Khalsa <hkhalsa@10gen.com> | 2013-08-01 11:01:23 -0400 |
---|---|---|
committer | Hari Khalsa <hkhalsa@10gen.com> | 2013-08-05 10:46:23 -0400 |
commit | bd0cdbf21d2e91a4b63db6d092378a86f058c73d (patch) | |
tree | 0c4797e8dffcbb1aa3db47b52e995b0f21a58ebc /src/mongo/db/geo | |
parent | 00eeec1ab83c8f4921d1bc1352221168a3a01900 (diff) | |
download | mongo-bd0cdbf21d2e91a4b63db6d092378a86f058c73d.tar.gz |
SERVER-10376 SERVER-10026 end-to-end part 1: run non-indexed queries
Diffstat (limited to 'src/mongo/db/geo')
-rw-r--r-- | src/mongo/db/geo/geoquery.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/geo/geoquery.h | 13 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/mongo/db/geo/geoquery.cpp b/src/mongo/db/geo/geoquery.cpp index 6e561ddd287..85a72a0d2f6 100644 --- a/src/mongo/db/geo/geoquery.cpp +++ b/src/mongo/db/geo/geoquery.cpp @@ -58,7 +58,7 @@ namespace mongo { return true; } - bool NearQuery::parseFrom(const BSONObj &obj, double radius) { + bool NearQuery::parseFrom(const BSONObj &obj) { bool hasGeometry = false; // First, try legacy near, e.g.: @@ -98,11 +98,6 @@ namespace mongo { } } - if (fromRadians) { - minDistance *= radius; - maxDistance *= radius; - } - if (hasGeometry) { return true; } // Next, try "new" near: diff --git a/src/mongo/db/geo/geoquery.h b/src/mongo/db/geo/geoquery.h index 7a18007b905..e6cb83b7370 100644 --- a/src/mongo/db/geo/geoquery.h +++ b/src/mongo/db/geo/geoquery.h @@ -91,13 +91,24 @@ namespace mongo { NearQuery(const string& f) : field(f), minDistance(0), maxDistance(std::numeric_limits<double>::max()), fromRadians(false) {} - bool parseFrom(const BSONObj &obj, double radius); + + /** + * If fromRadians is true after a parseFrom, minDistance and maxDistance are returned in + * radians, not meters. The distances must be multiplied by the underlying index's radius + * to convert them to meters. + * + * This is annoying but useful when we don't know what index we're using at parse time. + */ + bool parseFrom(const BSONObj &obj); bool parseFromGeoNear(const BSONObj &obj, double radius); + string field; PointWithCRS centroid; + // Min and max distance IN METERS from centroid that we're willing to search. double minDistance; double maxDistance; + // Did we convert to this distance from radians? (If so, we output distances in radians.) bool fromRadians; }; |