GeoNearRandomTest = function(name) { this.name = name; this.t = db[name]; this.nPts = 0; // reset state this.t.drop(); Random.srand(1234); print("starting test: " + name); }; GeoNearRandomTest.prototype.mkPt = function mkPt(scale, indexBounds){ if(!indexBounds){ scale = scale || 1; // scale is good for staying away from edges return [((Random.rand() * 359.8) - 179.9) * scale, ((Random.rand() * 180) - 90) * scale]; } else{ var range = indexBounds.max - indexBounds.min; var eps = Math.pow(2, -40); // Go very close to the borders but not quite there. return [( Random.rand() * (range - eps) + eps) + indexBounds.min, ( Random.rand() * (range - eps) + eps ) + indexBounds.min]; } }; GeoNearRandomTest.prototype.insertPts = function(nPts, indexBounds, scale) { assert.eq(this.nPts, 0, "insertPoints already called"); this.nPts = nPts; var bulk = this.t.initializeUnorderedBulkOp(); for (var i=0; i