Permalink
Browse files

updated geo script

  • Loading branch information...
Tim Burks
Tim Burks committed Jul 17, 2010
1 parent 611557c commit 5076ccd558ce382485b4a47c7354ecf59e62caf5
Showing with 12 additions and 11 deletions.
  1. +12 −11 geo.nu
View
23 geo.nu
@@ -8,11 +8,11 @@
(mongo connectWithOptions:(dict host:"127.0.0.1"))
(puts "connected")
-(set count (mongo count:nil inCollection:"places" inDatabase:"geo"))
+(set count (mongo countWithCondition:nil inCollection:"places" inDatabase:"geo"))
(puts count)
-(if YES
+(if NO
(puts "building")
;; rebuild the place database
(mongo dropCollection:"places" inDatabase:"geo")
@@ -27,16 +27,17 @@
(set longitude (/ (% (NuMath random) 180000) 1000))
(set place (dict name:(+ "location-" i "-" j)
location:(dict latitude:latitude longitude:longitude)))
- (mongo insert:place intoCollection:collection)))))
+ (mongo insertObject:place intoCollection:collection)))))
(mongo ensureCollection:"geo.places" hasIndex:(dict location:"2d") withOptions:0))
;; search the place database
(puts "querying")
-(1 times:(do (i)
- (set cursor (mongo find:(dict location:(dict $near:(dict latitude:70 longitude:80))) inCollection:"geo.places"))
- (set i 0)
- (while (and (cursor next) (< i 10))
- (set object (cursor currentObject))
- (puts (object description))
- (set i (+ i 1)))
- ))
+(100 times:
+ (do (i)
+ (set cursor (mongo find:(dict location:(dict $near:(dict latitude:70 longitude:80))) inCollection:"geo.places"))
+ (set i 0)
+ (while (and (cursor next) (< i 10))
+ (set object (cursor currentObject))
+ (puts (object description))
+ (set i (+ i 1)))
+ ))

0 comments on commit 5076ccd

Please sign in to comment.