From 22246ef94db3bce9407665d735faa8553f21dcc9 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Thu, 25 Feb 2010 23:34:01 -0500 Subject: can access geo through $near --- jstests/geo2.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'jstests/geo2.js') diff --git a/jstests/geo2.js b/jstests/geo2.js index 81d807d5758..c33a5de370c 100644 --- a/jstests/geo2.js +++ b/jstests/geo2.js @@ -23,17 +23,23 @@ assert.lt( fast.stats.nscanned * 10 , slow.stats.nscanned , "A1" + v ); assert.lt( fast.stats.objectsLoaded , slow.stats.objectsLoaded , "A2" + v ); assert.eq( fast.stats.avgDistance , slow.stats.avgDistance , "A3" + v ); -/* -function p( z ){ - print( z.dis + "\t" + z.obj.loc ) +function a( cur ){ + var total = 0; + var outof = 0; + while ( cur.hasNext() ){ + total += cur.next()["$distance"]; + outof++; + } + return total/outof; } -printjson( fast.stats ) -fast.results.forEach( p ) -printjson( slow.stats ) -slow.results.forEach( p ) +assert.eq( fast.stats.avgDistance , a( t.find( { loc : { $near : [ 50 , 50 ] } } ).limit(10) ) , "B1" ) -*/ +print( "---" ) +query = t.find( { loc : { $near : [ 50 , 50 ] } } ).limit(10) +query.forEach( printjson ) +print( "---" ) +query = t.find( { loc : { $near : [ 50 , 50 ] } } ).limit(3) +query.forEach( printjson ) -//t.find( { loc : { $near : [ 50 , 50 ] } } ).itcount(); -- cgit v1.2.1