diff options
author | gregs <greg@10gen.com> | 2011-09-06 17:35:31 -0400 |
---|---|---|
committer | gregs <greg@10gen.com> | 2011-09-06 17:40:44 -0400 |
commit | 333e0276374e229764277053ea4be6b92c6fe3ed (patch) | |
tree | 22fb7cebda6ee97d38aaa014a40c2e4a5c1e3a4e /jstests | |
parent | 0ad61856a65c6ae5801c7fd666f7e4e6b9b129bd (diff) | |
download | mongo-333e0276374e229764277053ea4be6b92c6fe3ed.tar.gz |
need to add error value to bounding boxes on polygons + boxes SERVER-3725
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/geo_poly_line.js | 17 | ||||
-rw-r--r-- | jstests/slowNightly/geo_polygon.js | 26 |
2 files changed, 32 insertions, 11 deletions
diff --git a/jstests/geo_poly_line.js b/jstests/geo_poly_line.js new file mode 100644 index 00000000000..aca77b6ab0a --- /dev/null +++ b/jstests/geo_poly_line.js @@ -0,0 +1,17 @@ +// Test that weird polygons work SERVER-3725 + +t = db.geo_polygon5; +t.drop(); + +t.insert({loc:[0,0]}) +t.insert({loc:[1,0]}) +t.insert({loc:[2,0]}) +t.insert({loc:[3,0]}) +t.insert({loc:[4,0]}) + +t.ensureIndex( { loc : "2d" } ); + +printjson( t.find({ loc: { "$within": { "$polygon" : [[0,0], [2,0], [4,0]] } } }).toArray() ) + +assert.eq( 5, t.find({ loc: { "$within": { "$polygon" : [[0,0], [2,0], [4,0]] } } }).itcount() ) + diff --git a/jstests/slowNightly/geo_polygon.js b/jstests/slowNightly/geo_polygon.js index b4dd3e85669..a6324d7d5ab 100644 --- a/jstests/slowNightly/geo_polygon.js +++ b/jstests/slowNightly/geo_polygon.js @@ -26,24 +26,28 @@ if ( shouldRun ) { for( var n = 0; n < numTests; n++ ){ t.dropIndexes() t.ensureIndex( { loc : "2d" }, { bits : 2 + n } ); - - + assert.eq( 9 , t.find( { loc: { "$within": { "$polygon" : [[0,0], [1,1], [0,2]] }}} ).count() , "Triangle Test" ); assert.eq( num , t.find( { loc : { "$within" : { "$polygon" : [ [-180,-180], [-180,180], [180,180], [180,-180] ] } } } ).count() , "Bounding Box Test" ); - + assert.eq( 441 , t.find( { loc : { "$within" : { "$polygon" : [ [0,0], [0,10], [10,10], [10,0] ] } } } ).count() , "Square Test" ); assert.eq( 25 , t.find( { loc : { "$within" : { "$polygon" : [ [0,0], [0,2], [2,2], [2,0] ] } } } ).count() , "Square Test 2" ); - if(0){ // SERVER-3726 - assert.eq( 331 , t.find( { loc : { "$within" : { "$polygon" : [ [0,0], [0,10], [10,10], [10,0], [5,5] ] } } } ).count() , "Square Missing Chunk Test" ); - assert.eq( 21 , t.find( { loc : { "$within" : { "$polygon" : [ [0,0], [0,2], [2,2], [2,0], [1,1] ] } } } ).count() , "Square Missing Chunk Test 2" ); + + if(1){ // SERVER-3726 + // Points exactly on diagonals may be in or out, depending on how the error calculating the slope falls. + assert.between( 341 - 18 , t.find( { loc : { "$within" : { "$polygon" : [ [0,0], [0,10], [10,10], [10,0], [5,5] ] } } } ).count(), 341, "Square Missing Chunk Test", true ); + assert.between( 21 - 2 , t.find( { loc : { "$within" : { "$polygon" : [ [0,0], [0,2], [2,2], [2,0], [1,1] ] } } } ).count(), 21 , "Square Missing Chunk Test 2", true ); } - + assert.eq( 1 , t.find( { loc: { "$within": { "$polygon" : [[0,0], [0,0], [0,0]] }}} ).count() , "Point Test" ); - if(0){ // SERVER-3725 - assert.eq( 5 , t.find( { loc: { "$within": { "$polygon" : [[0,0], [1,0], [2,0]] }}} ).count() , "Line Test 1" ); - assert.eq( 3 , t.find( { loc: { "$within": { "$polygon" : [[0,0], [0,0], [1,0]] }}} ).count() , "Line Test 2" ); - assert.eq( 5 , t.find( { loc: { "$within": { "$polygon" : [[0,2], [0,1], [0,0]] }}} ).count() , "Line Test 3" ); + + // SERVER-3725 + { + assert.eq( 5 , t.find( { loc: { "$within": { "$polygon" : [[0,0], [1,0], [2,0]] }}} ).count() , "Line Test 1" ); + assert.eq( 3 , t.find( { loc: { "$within": { "$polygon" : [[0,0], [0,0], [1,0]] }}} ).count() , "Line Test 2" ); + assert.eq( 5 , t.find( { loc: { "$within": { "$polygon" : [[0,2], [0,1], [0,0]] }}} ).count() , "Line Test 3" ); } + assert.eq( 3 , t.find( { loc: { "$within": { "$polygon" : [[0,1], [0,0], [0,0]] }}} ).count() , "Line Test 4" ); } } |