summaryrefslogtreecommitdiff
path: root/jstests/core/geo_poly_edge.js
blob: 8608af366150b0288bc5d049ac27640b02b172be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//
// Tests polygon edge cases
//

var coll = db.getCollection('jstests_geo_poly_edge');
coll.drop();

coll.createIndex({loc: "2d"});

coll.insert({loc: [10, 10]});
coll.insert({loc: [10, -10]});

assert.eq(coll.find({loc: {$within: {$polygon: [[10, 10], [10, 10], [10, -10]]}}}).itcount(), 2);

assert.eq(coll.find({loc: {$within: {$polygon: [[10, 10], [10, 10], [10, 10]]}}}).itcount(), 1);

coll.insert({loc: [179, 0]});
coll.insert({loc: [0, 179]});

assert.eq(
    coll.find({loc: {$within: {$polygon: [[0, 0], [1000, 0], [1000, 1000], [0, 1000]]}}}).itcount(),
    3);