diff options
author | Wan Bachtiar <sindbach@gmail.com> | 2017-07-26 14:41:14 +1000 |
---|---|---|
committer | Tess Avitabile <tess.avitabile@mongodb.com> | 2017-10-10 11:39:29 -0400 |
commit | f24f7830d01193db30102b8381eeaf4c011d0ea9 (patch) | |
tree | 0cbbccb27f24cf3f7e8c960c188f4b04e97b8dc4 /src/mongo/db/geo | |
parent | f3d67ba10f338a53e5c99142ebd1ac224c8f624c (diff) | |
download | mongo-f24f7830d01193db30102b8381eeaf4c011d0ea9.tar.gz |
SERVER-27968 $geoWithin with $centerSphere should return LineString and Polygon geometries
Closes #1184
Signed-off-by: Tess Avitabile <tess.avitabile@mongodb.com>
Diffstat (limited to 'src/mongo/db/geo')
-rw-r--r-- | src/mongo/db/geo/geometry_container.cpp | 23 |
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) { |