Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit b639096a76de87adaf0e62e28e29b1155ba944a9
Author: Richard Kreuter <richard@10gen.com>
Date:   Tue May 11 13:53:26 2010 -0400

    Replace sizeDiag calls w/sizeEdge; add a test. SERVER-994

commit 75b0a08c96bfd6e1a7e7a6d002dd2391d0433575
Author: Richard Kreuter <richard@10gen.com>
Date:   Fri May 7 16:29:48 2010 -0400

    Rename mongo::Geo2dType::size() to ::sizeDiag(); add a sizeEdge(). SERVER-994
  • Loading branch information
Richard Kreuter committed May 11, 2010
1 parent c513597 commit 6845ac0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
19 changes: 14 additions & 5 deletions db/index_geo2d.cpp
Expand Up @@ -467,12 +467,21 @@ namespace mongo {
return sqrt( ( dx * dx ) + ( dy * dy ) );
}

double size( const GeoHash& a ) const {
double sizeDiag( const GeoHash& a ) const {
GeoHash b = a;
b.move( 1 , 1 );
return distance( a , b );
}

double sizeEdge( const GeoHash& a ) const {
double ax,ay,bx,by;
GeoHash b = a;
b.move( 1 , 1 );
_unconvert( a, ax, ay );
_unconvert( b, bx, by );
return (abs(ax-bx));
}

const IndexDetails* getDetails() const {
return _spec->getDetails();
}
Expand Down Expand Up @@ -543,7 +552,7 @@ namespace mongo {

Box( const Geo2dType * g , const GeoHash& hash )
: _min( g , hash ) ,
_max( _min._x + g->size( hash ) , _min._y + g->size( hash ) ){
_max( _min._x + g->sizeEdge( hash ) , _min._y + g->sizeEdge( hash ) ){
}

Box( double x , double y , double size )
Expand Down Expand Up @@ -1056,14 +1065,14 @@ namespace mongo {
if ( _found && _prefix.constrains() ){
// 2
Point center( _spec , _n );
double boxSize = _spec->size( _prefix );
double boxSize = _spec->sizeEdge( _prefix );
double farthest = hopper->farthest();
if ( farthest > boxSize )
boxSize = farthest;
Box want( center._x - ( boxSize / 2 ) , center._y - ( boxSize / 2 ) , boxSize );
while ( _spec->size( _prefix ) < boxSize )
while ( _spec->sizeEdge( _prefix ) < boxSize )
_prefix = _prefix.up();
log(1) << "want: " << want << " found:" << _found << " hash size:" << _spec->size( _prefix ) << endl;
log(1) << "want: " << want << " found:" << _found << " hash size:" << _spec->sizeEdge( _prefix ) << endl;

for ( int x=-1; x<=1; x++ ){
for ( int y=-1; y<=1; y++ ){
Expand Down
7 changes: 7 additions & 0 deletions jstests/geo_box3.js
@@ -0,0 +1,7 @@
t=db.geo_box3;

t.drop();
// SERVER-994
db.foo.insert({ point : { x : -15, y : 10 } });
db.foo.ensureIndex( { point : "2d" } , { min : -21 , max : 21 } );
db.foo.find({point: {"$within": {"$box": [[-20, 7], [0, 15]]} } });

0 comments on commit 6845ac0

Please sign in to comment.