Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

odd $near bug

  • Loading branch information...
commit c59b38288f03ab75e67a7f8158ac5a78b5650ca6 1 parent dae8c2d
@RedBeard0531 RedBeard0531 authored
Showing with 20 additions and 1 deletion.
  1. +1 −1  db/geo/2d.cpp
  2. +19 −0 jstests/geof.js
View
2  db/geo/2d.cpp
@@ -888,7 +888,7 @@ namespace mongo {
farthest = _spec->sizeDiag( _prefix );
Box want( center._x - farthest , center._y - farthest , farthest * 2 );
_prefix = _n;
- while ( _spec->sizeEdge( _prefix ) < ( farthest / 2 ) ){
+ while ( _spec->sizeEdge( _prefix ) < farthest ){
_prefix = _prefix.up();
}
View
19 jstests/geof.js
@@ -0,0 +1,19 @@
+t = db.geof
+t.drop();
+
+// corners (dist ~0.98)
+t.insert({loc: [ 0.7, 0.7]})
+t.insert({loc: [ 0.7, -0.7]})
+t.insert({loc: [-0.7, 0.7]})
+t.insert({loc: [-0.7, -0.7]})
+
+// on x axis (dist == 0.9)
+t.insert({loc: [-0.9, 0]})
+t.insert({loc: [-0.9, 0]})
+
+t.ensureIndex( { loc : "2d" } )
+
+t.find({loc: {$near: [0,0]}}).limit(2).forEach( function(o){
+ //printjson(o);
+ assert.lt(Geo.distance([0,0], o.loc), 0.95);
+});
Please sign in to comment.
Something went wrong with that request. Please try again.