summaryrefslogtreecommitdiff
path: root/src/mongo/db/geo
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2017-10-10 13:10:40 -0400
committerTess Avitabile <tess.avitabile@mongodb.com>2017-10-10 13:10:49 -0400
commitf864f1ee2cea8bcd9ee4a34776ad069ab7208ff4 (patch)
tree964ebc2cc7775e1011b821abe9d3299bbd3bb0b0 /src/mongo/db/geo
parente76653c66ea5b191bce2432d319e0c6759d2042e (diff)
downloadmongo-f864f1ee2cea8bcd9ee4a34776ad069ab7208ff4.tar.gz
SERVER-27968 $geoWithin with $centerSphere should return LineString and Polygon geometries
Diffstat (limited to 'src/mongo/db/geo')
-rw-r--r--src/mongo/db/geo/geometry_container.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/mongo/db/geo/geometry_container.cpp b/src/mongo/db/geo/geometry_container.cpp
index 2b571f1b9f0..c9b4b2f3f48 100644
--- a/src/mongo/db/geo/geometry_container.cpp
+++ b/src/mongo/db/geo/geometry_container.cpp
@@ -448,6 +448,17 @@ bool GeometryContainer::contains(const S2Polyline& otherLine) const {
return _polygon->bigPolygon->Contains(otherLine);
}
+ if (NULL != _cap && (_cap->crs == SPHERE)) {
+ // If the radian distance of a line to the centroid of the complement spherical cap is less
+ // than the arc radian of the complement cap, then the line is not within the spherical cap.
+ S2Cap complementSphere = _cap->cap.Complement();
+ if (S2Distance::minDistanceRad(complementSphere.axis(), otherLine) <
+ complementSphere.angle().radians()) {
+ return false;
+ }
+ return true;
+ }
+
if (NULL != _multiPolygon) {
const vector<S2Polygon*>& polys = _multiPolygon->polygons.vector();
for (size_t i = 0; i < polys.size(); ++i) {
@@ -493,6 +504,18 @@ bool GeometryContainer::contains(const S2Polygon& otherPolygon) const {
return _polygon->bigPolygon->Contains(otherPolygon);
}
+ if (NULL != _cap && (_cap->crs == SPHERE)) {
+ // If the radian distance of a polygon to the centroid of the complement spherical cap is
+ // less than the arc radian of the complement cap, then the polygon is not within the
+ // spherical cap.
+ S2Cap complementSphere = _cap->cap.Complement();
+ if (S2Distance::minDistanceRad(complementSphere.axis(), otherPolygon) <
+ complementSphere.angle().radians()) {
+ return false;
+ }
+ return true;
+ }
+
if (NULL != _multiPolygon) {
const vector<S2Polygon*>& polys = _multiPolygon->polygons.vector();
for (size_t i = 0; i < polys.size(); ++i) {