Skip to content

Commit

Permalink
names have to be unique
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed May 18, 2011
1 parent 4f9ae84 commit 93eaf06
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
32 changes: 16 additions & 16 deletions jstests/geo_fiddly_box.js
Expand Up @@ -4,20 +4,20 @@
// "expand" portion of the geo-lookup expands the 2d range in only one
// direction (so points are required on either side of the expanding range)

db.users.drop();
db.users.ensureIndex({ loc : "2d" })
db.geo_fiddly_box.drop();
db.geo_fiddly_box.ensureIndex({ loc : "2d" })

db.users.insert({ "loc" : [3, 1] })
db.users.insert({ "loc" : [3, 0.5] })
db.users.insert({ "loc" : [3, 0.25] })
db.users.insert({ "loc" : [3, -0.01] })
db.users.insert({ "loc" : [3, -0.25] })
db.users.insert({ "loc" : [3, -0.5] })
db.users.insert({ "loc" : [3, -1] })
db.geo_fiddly_box.insert({ "loc" : [3, 1] })
db.geo_fiddly_box.insert({ "loc" : [3, 0.5] })
db.geo_fiddly_box.insert({ "loc" : [3, 0.25] })
db.geo_fiddly_box.insert({ "loc" : [3, -0.01] })
db.geo_fiddly_box.insert({ "loc" : [3, -0.25] })
db.geo_fiddly_box.insert({ "loc" : [3, -0.5] })
db.geo_fiddly_box.insert({ "loc" : [3, -1] })

// OK!
print( db.users.count() )
assert.eq( 7, db.users.count({ "loc" : { "$within" : { "$box" : [ [2, -2], [46, 2] ] } } }), "Not all locations found!" );
print( db.geo_fiddly_box.count() )
assert.eq( 7, db.geo_fiddly_box.count({ "loc" : { "$within" : { "$box" : [ [2, -2], [46, 2] ] } } }), "Not all locations found!" );


// Test normal lookup of a small square of points as a sanity check.
Expand All @@ -28,17 +28,17 @@ max = 1
step = 1
numItems = 0;

db.users2.drop()
db.users2.ensureIndex({ loc : "2d" }, { max : max + epsilon / 2, min : min - epsilon / 2 })
db.geo_fiddly_box2.drop()
db.geo_fiddly_box2.ensureIndex({ loc : "2d" }, { max : max + epsilon / 2, min : min - epsilon / 2 })

for(var x = min; x <= max; x += step){
for(var y = min; y <= max; y += step){
db.users2.insert({ "loc" : { x : x, y : y } })
db.geo_fiddly_box2.insert({ "loc" : { x : x, y : y } })
numItems++;
}
}

assert.eq( numItems, db.users2.count({ loc : { $within : { $box : [[min - epsilon / 3,
assert.eq( numItems, db.geo_fiddly_box2.count({ loc : { $within : { $box : [[min - epsilon / 3,
min - epsilon / 3],
[max + epsilon / 3,
max + epsilon / 3]] } } }), "Not all locations found!");
max + epsilon / 3]] } } }), "Not all locations found!");
2 changes: 1 addition & 1 deletion jstests/geo_fiddly_box2.js
Expand Up @@ -3,7 +3,7 @@
// The setup to reproduce is to create a set of points and a really big bounds so that we are required to do
// exact lookups on the points to get correct results.

t = db.tiles
t = db.geo_fiddly_box2
t.drop()

t.insert( { "letter" : "S", "position" : [ -3, 0 ] } )
Expand Down

0 comments on commit 93eaf06

Please sign in to comment.