File: geo_box3.js

package info (click to toggle)
mongodb 1%3A2.4.10-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 82,464 kB
  • sloc: cpp: 740,225; ansic: 152,098; sh: 13,820; python: 11,864; makefile: 1,012; perl: 922; pascal: 617; java: 452; lisp: 222; asm: 174
file content (36 lines) | stat: -rw-r--r-- 1,352 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// How to construct a test to stress the flaw in SERVER-994:
// construct an index, think up a bounding box inside the index that
// doesn't include the center of the index, and put a point inside the
// bounding box.

// This is the bug reported in SERVER-994.
t=db.geo_box3;
t.drop();
t.insert({ point : { x : -15000000, y : 10000000 } });
t.ensureIndex( { point : "2d" } , { min : -21000000 , max : 21000000 } );
var c=t.find({point: {"$within": {"$box": [[-20000000, 7000000], [0, 15000000]]} } });
assert.eq(1, c.count(), "A1");

// Same thing, modulo 1000000.
t=db.geo_box3;
t.drop();
t.insert({ point : { x : -15, y : 10 } });
t.ensureIndex( { point : "2d" } , { min : -21 , max : 21 } );
var c=t.find({point: {"$within": {"$box": [[-20, 7], [0, 15]]} } });
assert.eq(1, c.count(), "B1");

// Two more examples, one where the index is centered at the origin,
// one not.
t=db.geo_box3;
t.drop();
t.insert({ point : { x : 1.0 , y : 1.0 } });
t.ensureIndex( { point : "2d" } , { min : -2 , max : 2 } );
var c=t.find({point: {"$within": {"$box": [[.1, .1], [1.99, 1.99]]} } });
assert.eq(1, c.count(), "C1");

t=db.geo_box3;
t.drop();
t.insert({ point : { x : 3.9 , y : 3.9 } });
t.ensureIndex( { point : "2d" } , { min : 0 , max : 4 } );
var c=t.find({point: {"$within": {"$box": [[2.05, 2.05], [3.99, 3.99]]} } });
assert.eq(1, c.count(), "D1");