File: geo_oob_sphere.js

package info (click to toggle)
mongodb 1%3A2.0.6-1.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 17,204 kB
  • sloc: cpp: 109,783; ansic: 101,073; python: 2,287; perl: 395; makefile: 370; sh: 242; asm: 46
file content (42 lines) | stat: -rw-r--r-- 1,241 bytes parent folder | download
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
37
38
39
40
41
42
//
// Ensures spherical queries report invalid latitude values in points and center positions
//

t = db.geooobsphere
t.drop();

t.insert({ loc : { x : 30, y : 89 } })
t.insert({ loc : { x : 30, y : 89 } })
t.insert({ loc : { x : 30, y : 89 } })
t.insert({ loc : { x : 30, y : 89 } })
t.insert({ loc : { x : 30, y : 89 } })
t.insert({ loc : { x : 30, y : 89 } })
t.insert({ loc : { x : 30, y : 91 } })

t.ensureIndex({ loc : "2d" })
assert.isnull( db.getLastError() )

t.find({ loc : { $nearSphere : [ 30, 91 ], $maxDistance : 0.25 } }).count()
var err = db.getLastError()
assert( err != null )
printjson( err )

t.find({ loc : { $nearSphere : [ 30, 89 ], $maxDistance : 0.25 } }).count()
var err = db.getLastError()
assert( err != null )
printjson( err )

t.find({ loc : { $within : { $centerSphere : [[ -180, -91 ], 0.25] } } }).count()
var err = db.getLastError()
assert( err != null )
printjson( err )

db.runCommand({ geoNear : "geooobsphere", near : [179, -91], maxDistance : 0.25, spherical : true })
var err = db.getLastError()
assert( err != null )
printjson( err )

db.runCommand({ geoNear : "geooobsphere", near : [30, 89], maxDistance : 0.25, spherical : true })
var err = db.getLastError()
assert( err != null )
printjson( err )