-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Query Integration
-
ALL
-
-
0
The GeoNear2DStage has its own implementation for projecting a spherical region to a flat annulus. siyuan.zhou and I read through the code and suspect the issue is with the computeXScanDistance() function, but aren't clear on the details (read: math) that cause $nearSphere queries to omit points from the flat annulus that were included in the spherical region.
inline double computeXScanDistance(double y, double maxDistDegrees) { // TODO: this overestimates for large maxDistDegrees far from the equator return maxDistDegrees / std::min(cos(deg2rad(std::min(+89.0, y + maxDistDegrees))), cos(deg2rad(std::max(-89.0, y - maxDistDegrees)))); }
As a workaround, one can perform the $nearSphere queries with a "2dsphere" index to get the expected results.
Note: This is a separate issue from the one reported in SERVER-21594, as the $maxDistance specified in to the $nearSphere query doesn't necessarily cause it to cross over the pole.
Additionally, $geoWithin queries that use $centerSphere don't appear to be affected by this issue because they use the S2 library to perform the projection from the spherical region to the flat box.
- is related to
-
SERVER-24441 Change geo_full.js to not create points near the poles
- Closed