Files
mongo/jstests/core/geo_poly_edge.js
2016-05-28 17:55:12 -04:00

23 lines
575 B
JavaScript

//
// Tests polygon edge cases
//
var coll = db.getCollection('jstests_geo_poly_edge');
coll.drop();
coll.ensureIndex({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);