2011-03-25 20:38:07 -04:00
|
|
|
// Make sure the very basics of geo arrays are sane by creating a few multi location docs
|
2016-02-04 12:29:01 -05:00
|
|
|
t = db.geoarray;
|
2011-03-25 20:38:07 -04:00
|
|
|
|
2013-01-18 11:26:30 -05:00
|
|
|
function test(index) {
|
|
|
|
|
t.drop();
|
2016-03-09 12:17:50 -05:00
|
|
|
t.insert({zip: "10001", loc: [[10, 10], [50, 50]]});
|
|
|
|
|
t.insert({zip: "10002", loc: [[20, 20], [50, 50]]});
|
|
|
|
|
var res = t.insert({zip: "10003", loc: [[30, 30], [50, 50]]});
|
|
|
|
|
assert.writeOK(res);
|
2013-01-18 11:26:30 -05:00
|
|
|
|
|
|
|
|
if (index) {
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.commandWorked(t.ensureIndex({loc: "2d", zip: 1}));
|
|
|
|
|
assert.eq(2, t.getIndexKeys().length);
|
2013-01-18 11:26:30 -05:00
|
|
|
}
|
|
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
res = t.insert({zip: "10004", loc: [[40, 40], [50, 50]]});
|
|
|
|
|
assert.writeOK(res);
|
2013-01-18 11:26:30 -05:00
|
|
|
|
|
|
|
|
// test normal access
|
2016-03-09 12:17:50 -05:00
|
|
|
printjson(t.find({loc: {$within: {$box: [[0, 0], [45, 45]]}}}).toArray());
|
|
|
|
|
assert.eq(4, t.find({loc: {$within: {$box: [[0, 0], [45, 45]]}}}).count());
|
|
|
|
|
assert.eq(4, t.find({loc: {$within: {$box: [[45, 45], [50, 50]]}}}).count());
|
2013-01-18 11:26:30 -05:00
|
|
|
}
|
|
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
// test(false); // this was removed as part of SERVER-6400
|
2016-02-04 12:29:01 -05:00
|
|
|
test(true);
|