~evarlast/ubuntu/utopic/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to jstests/geo_s2index.js

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
t = db.geo_s2index
 
2
t.drop()
 
3
 
 
4
pointA = { "type" : "Point", "coordinates": [ 40, 5 ] }
 
5
t.insert( {geo : pointA , nonGeo: "pointA"})
 
6
 
 
7
pointD = { "type" : "Point", "coordinates": [ 41.001, 6.001 ] }
 
8
t.insert( {geo : pointD , nonGeo: "pointD"})
 
9
 
 
10
someline = { "type" : "LineString", "coordinates": [ [ 40, 5], [41, 6]]}
 
11
t.insert( {geo : someline , nonGeo: "someline"})
 
12
 
 
13
pointB = { "type" : "Point", "coordinates": [ 41, 6 ] }
 
14
t.insert( {geo : pointB , nonGeo: "pointB"})
 
15
 
 
16
pointC = { "type" : "Point", "coordinates": [ 41, 6 ] }
 
17
t.insert( {geo : pointC} )
 
18
 
 
19
// Add a point within the polygon but not on the border.  Don't want to be on
 
20
// the path of the polyline.
 
21
pointE = { "type" : "Point", "coordinates": [ 40.6, 5.4 ] }
 
22
t.insert( {geo : pointE} )
 
23
 
 
24
// Make sure we can index this without error.
 
25
t.insert({nonGeo: "noGeoField!"})
 
26
 
 
27
somepoly = { "type" : "Polygon",
 
28
             "coordinates" : [ [ [40,5], [40,6], [41,6], [41,5], [40,5]]]}
 
29
t.insert( {geo : somepoly, nonGeo: "somepoly" })
 
30
 
 
31
t.ensureIndex( { geo : "2dsphere", nonGeo: 1 } )
 
32
// We have a point without any geo data.  Don't error.
 
33
assert(!db.getLastError())
 
34
 
 
35
res = t.find({ "geo" : { "$geoIntersects" : { "$geometry" : pointA} } });
 
36
assert.eq(res.count(), 3);
 
37
 
 
38
res = t.find({ "geo" : { "$geoIntersects" : { "$geometry" : pointB} } });
 
39
assert.eq(res.count(), 4);
 
40
 
 
41
res = t.find({ "geo" : { "$geoIntersects" : { "$geometry" : pointD} } });
 
42
assert.eq(res.count(), 1);
 
43
 
 
44
res = t.find({ "geo" : { "$geoIntersects" : { "$geometry" : someline} } })
 
45
assert.eq(res.count(), 5);
 
46
 
 
47
res = t.find({ "geo" : { "$geoIntersects" : { "$geometry" : somepoly} } })
 
48
assert.eq(res.count(), 6);
 
49
 
 
50
res = t.find({ "geo" : { "$within" : { "$geometry" : somepoly} } })
 
51
assert.eq(res.count(), 6);
 
52
 
 
53
res = t.find({ "geo" : { "$geoIntersects" : { "$geometry" : somepoly} } }).limit(1)
 
54
assert.eq(res.itcount(), 1);
 
55
 
 
56
res = t.find({ "nonGeo": "pointA",
 
57
               "geo" : { "$geoIntersects" : { "$geometry" : somepoly} } })
 
58
assert.eq(res.count(), 1);
 
59
 
 
60
// Don't crash mongod if we give it bad input.
 
61
t.drop()
 
62
t.ensureIndex({loc: "2dsphere", x:1})
 
63
t.save({loc: [0,0]})
 
64
assert.throws(function() { return t.count({loc: {$foo:[0,0]}}) })
 
65
assert.throws(function() { return t.find({ "nonGeo": "pointA",
 
66
                                           "geo" : { "$geoIntersects" : { "$geometry" : somepoly},
 
67
                                                     "$near": {"$geometry" : somepoly }}}).count()}) 
 
68
 
 
69
// If we specify a datum, it has to be valid (WGS84).
 
70
t.drop()
 
71
t.ensureIndex({loc: "2dsphere"})
 
72
t.insert({loc: {type:'Point', coordinates: [40, 5], crs:{ type: 'name', properties:{name:'EPSG:2000'}}}})
 
73
assert(db.getLastError());
 
74
assert.eq(0, t.find().itcount())
 
75
t.insert({loc: {type:'Point', coordinates: [40, 5]}})
 
76
assert(!db.getLastError());
 
77
t.insert({loc: {type:'Point', coordinates: [40, 5], crs:{ type: 'name', properties:{name:'EPSG:4326'}}}})
 
78
assert(!db.getLastError());
 
79
t.insert({loc: {type:'Point', coordinates: [40, 5], crs:{ type: 'name', properties:{name:'urn:ogc:def:crs:OGC:1.3:CRS84'}}}})
 
80
assert(!db.getLastError());
 
81
 
 
82
// We can pass level parameters and we verify that they're valid.
 
83
// 0 <= coarsestIndexedLevel <= finestIndexedLevel <= 30.
 
84
t.drop();
 
85
t.save({loc: [0,0]})
 
86
t.ensureIndex({loc: "2dsphere"}, {finestIndexedLevel: 17, coarsestIndexedLevel: 5})
 
87
assert(!db.getLastError());
 
88
 
 
89
t.drop();
 
90
t.save({loc: [0,0]})
 
91
t.ensureIndex({loc: "2dsphere"}, {finestIndexedLevel: 31, coarsestIndexedLevel: 5})
 
92
assert(db.getLastError());
 
93
 
 
94
t.drop();
 
95
t.save({loc: [0,0]})
 
96
t.ensureIndex({loc: "2dsphere"}, {finestIndexedLevel: 30, coarsestIndexedLevel: 0})
 
97
assert(!db.getLastError());
 
98
 
 
99
t.drop();
 
100
t.save({loc: [0,0]})
 
101
t.ensureIndex({loc: "2dsphere"}, {finestIndexedLevel: 30, coarsestIndexedLevel: -1})
 
102
assert(db.getLastError());