diff options
author | Hari Khalsa <hkhalsa@10gen.com> | 2013-10-16 17:29:43 -0400 |
---|---|---|
committer | Hari Khalsa <hkhalsa@10gen.com> | 2013-10-24 16:41:06 -0400 |
commit | 9d7c6dd9a2a662c741a9f960d9c6b2da1968d532 (patch) | |
tree | 5b17f1f92dcfb6f64df1b305087f9dcb533c4db8 /src/mongo/db/geo/geoparser.cpp | |
parent | 3228ad9c3ca78d55f814689686bf2e619fcde9a9 (diff) | |
download | mongo-9d7c6dd9a2a662c741a9f960d9c6b2da1968d532.tar.gz |
SERVER-10026 move 2d into stages, remove old query from 2d execution
Diffstat (limited to 'src/mongo/db/geo/geoparser.cpp')
-rw-r--r-- | src/mongo/db/geo/geoparser.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mongo/db/geo/geoparser.cpp b/src/mongo/db/geo/geoparser.cpp index 01d75dc0bf6..c17fb8b755a 100644 --- a/src/mongo/db/geo/geoparser.cpp +++ b/src/mongo/db/geo/geoparser.cpp @@ -373,6 +373,7 @@ namespace mongo { BSONElement maxE = coordIt.next(); if (!maxE.isABSONObj()) { return false; } if (!isLegacyPoint(maxE.Obj())) { return false; } + // XXX: VERIFY AREA >= 0 return true; } @@ -599,6 +600,8 @@ namespace mongo { BSONElement radiusElt = objIt.next(); double radius = radiusElt.number(); out->cap = S2Cap::FromAxisAngle(centerPoint, S1Angle::Radians(radius)); + out->circle.radius = radius; + out->circle.center = Point(x.Number(), y.Number()); out->crs = SPHERE; } return true; @@ -643,4 +646,32 @@ namespace mongo { return true; } + bool GeoParser::parsePointWithMaxDistance(const BSONObj& obj, PointWithCRS* out, double* maxOut) { + BSONObjIterator it(obj); + if (!it.more()) { return false; } + + BSONElement lng = it.next(); + if (!lng.isNumber()) { return false; } + if (!it.more()) { return false; } + + BSONElement lat = it.next(); + if (!lat.isNumber()) { return false; } + if (!it.more()) { return false; } + + BSONElement dist = it.next(); + if (!dist.isNumber()) { return false; } + if (it.more()) { return false; } + + out->crs = FLAT; + out->oldPoint.x = lng.number(); + out->oldPoint.y = lat.number(); + *maxOut = dist.number(); + if (isValidLngLat(lng.Number(), lat.Number())) { + out->flatUpgradedToSphere = true; + out->point = coordToPoint(lng.Number(), lat.Number()); + out->cell = S2Cell(out->point); + } + return true; + } + } // namespace mongo |