4
roundworldpoint = { "type" : "Point", "coordinates": [ 180, 0 ] }
6
// Opposite the equator
7
roundworld = { "type" : "Polygon",
8
"coordinates" : [ [ [179,1], [-179,1], [-179,-1], [179,-1], [179,1]]]}
9
t.insert({geo : roundworld})
11
roundworld2 = { "type" : "Polygon",
12
"coordinates" : [ [ [179,1], [179,-1], [-179,-1], [-179,1], [179,1]]]}
13
t.insert({geo : roundworld2})
16
santapoint = { "type" : "Point", "coordinates": [ 180, 90 ] }
17
santa = { "type" : "Polygon",
18
"coordinates" : [ [ [179,89], [179,90], [-179,90], [-179,89], [179,89]]]}
19
t.insert({geo : santa})
20
santa2 = { "type" : "Polygon",
21
"coordinates" : [ [ [179,89], [-179,89], [-179,90], [179,90], [179,89]]]}
22
t.insert({geo : santa2})
25
penguinpoint = { "type" : "Point", "coordinates": [ 0, -90 ] }
26
penguin1 = { "type" : "Polygon",
27
"coordinates" : [ [ [0,-89], [0,-90], [179,-90], [179,-89], [0,-89]]]}
28
t.insert({geo : penguin1})
29
penguin2 = { "type" : "Polygon",
30
"coordinates" : [ [ [0,-89], [179,-89], [179,-90], [0,-90], [0,-89]]]}
31
t.insert({geo : penguin2})
33
t.ensureIndex( { geo : "2dsphere", nonGeo: 1 } )
35
res = t.find({ "geo" : { "$geoIntersects" : { "$geometry" : roundworldpoint} } });
36
assert.eq(res.count(), 2);
37
res = t.find({ "geo" : { "$geoIntersects" : { "$geometry" : santapoint} } });
38
assert.eq(res.count(), 2);
39
res = t.find({ "geo" : { "$geoIntersects" : { "$geometry" : penguinpoint} } });
40
assert.eq(res.count(), 2);