Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Do one more box of point checks in GeoCircleBrowse. SERVER-848, SERVE…

…R-1238
  • Loading branch information...
commit 224ca4aecdde61bea54af48acf58c39994a497ca 1 parent 3ba2866
@kreuter kreuter authored
Showing with 61 additions and 6 deletions.
  1. +9 −6 db/geo/2d.cpp
  2. +24 −0 jstests/geo_circle4.js
  3. +28 −0 jstests/geo_circle5.js
View
15 db/geo/2d.cpp
@@ -1063,7 +1063,7 @@ namespace mongo {
_state = DOING_EXPAND;
}
- if ( _state == DOING_EXPAND ){
+ if ( (_state == DOING_EXPAND) || (_state == DOING_AROUND) ){
GEODEBUG( "circle prefix [" << _prefix << "]" );
while ( _min.hasPrefix( _prefix ) && _min.advance( -1 , _found , this ) );
while ( _max.hasPrefix( _prefix ) && _max.advance( 1 , _found , this ) );
@@ -1075,16 +1075,13 @@ namespace mongo {
}
if ( _g->distance( _prefix , _start ) > _maxDistance ){
- GEODEBUG( "\tpast circle bounds" );
+ GEODEBUG( "\tpast circle bounds");
GeoHash tr = _prefix;
tr.move( 1 , 1 );
if ( _g->distance( tr , _start ) > _maxDistance )
_state = DOING_AROUND;
- else
- _prefix = _prefix.up();
}
- else
- _prefix = _prefix.up();
+ _prefix = _prefix.up();
return;
}
@@ -1092,7 +1089,13 @@ namespace mongo {
_state = DONE;
return;
}
+ /* Clients are expected to use moreToDo before calling
+ * fillStack, so DONE is checked for there. If any more
+ * State values are defined, you should handle them
+ * here. */
+ assert(0);
}
+
virtual bool checkDistance( const GeoHash& h , double& d ){
d = _g->distance( _start , h );
View
24 jstests/geo_circle4.js
@@ -0,0 +1,24 @@
+// Reported as server-848.
+db.server848.drop();
+
+radius=0.0001;
+center=[5,52];
+
+db.server848.save({ "_id": 1, "loc" : { "x" : 4.9999, "y" : 52 } });
+db.server848.save({ "_id": 2, "loc" : { "x" : 5, "y" : 52 } });
+db.server848.save({ "_id": 3, "loc" : { "x" : 5.0001, "y" : 52 } });
+db.server848.save({ "_id": 4, "loc" : { "x" : 5, "y" : 52.0001 } });
+db.server848.save({ "_id": 5, "loc" : { "x" : 5, "y" : 51.9999 } });
+db.server848.save({ "_id": 6, "loc" : { "x" : 4.9999, "y" : 52.0001 } });
+db.server848.save({ "_id": 7, "loc" : { "x" : 5.0001, "y" : 52.0001 } });
+db.server848.save({ "_id": 8, "loc" : { "x" : 4.9999, "y" : 51.9999 } });
+db.server848.save({ "_id": 9, "loc" : { "x" : 5.0001, "y" : 51.9999 } });
+db.server848.ensureIndex( { loc : "2d" } );
+r=db.server848.find({"loc" : {"$within" : {"$center" : [center, radius]}}}, {_id:1});
+assert.eq(5, r.count(), "A1");
+// FIXME: surely code like this belongs in utils.js.
+a=r.toArray();
+x=[];
+for (k in a) { x.push(a[k]["_id"]) }
+x.sort()
+assert.eq([1,2,3,4,5], x, "B1");
View
28 jstests/geo_circle5.js
@@ -0,0 +1,28 @@
+// reported as server-1238.
+
+db.server1238.drop();
+db.server1238.remove()
+db.server1238.save({ loc: [ 5000000, 900000 ], id: 1})
+db.server1238.save({ loc: [ 5000000, 900000 ], id: 2})
+db.server1238.ensureIndex( { loc : "2d" } , { min : -21000000 , max : 21000000 } )
+db.server1238.save({ loc: [ 5000000, 900000 ], id: 3})
+db.server1238.save({ loc: [ 5000000, 900000 ], id: 4})
+
+c1=db.server1238.find({"loc" : {"$within" : {"$center" : [[5000000, 900000], 1.0]}}}).count()
+
+c2=db.server1238.find({"loc" : {"$within" : {"$center" : [[5000001, 900000], 5.0]}}}).count()
+
+
+assert.eq(4, c1, "A1");
+assert.eq(c1, c2, "B1");
+//print(db.server1238.find({"loc" : {"$within" : {"$center" : [[5000001, 900000], 5.0]}}}).toArray());
+// [
+// {
+// "_id" : ObjectId("4c173306f5d9d34a46cb7b11"),
+// "loc" : [
+// 5000000,
+// 900000
+// ],
+// "id" : 4
+// }
+// ]
Please sign in to comment.
Something went wrong with that request. Please try again.