Spatial script for MongoBoulder
Upcoming SlideShare
Loading in...5
×
 

Spatial script for MongoBoulder

on

  • 467 views

The Script I

The Script I

Statistics

Views

Total Views
467
Views on SlideShare
461
Embed Views
6

Actions

Likes
0
Downloads
1
Comments
0

1 Embed 6

https://twitter.com 6

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Spatial script for MongoBoulder Spatial script for MongoBoulder Document Transcript

  • #commands for adding spatial data#Take a look at the file first#less parkcoord.json#get the file on the serverscp parkcoord.json 30bb1262b1364026855e358a649f171b@parks-spmongo.rhcloud.com:app-root/data#ssh into the machinessh 30bb1262b1364026855e358a649f171b@parks-spmongo.rhcloud.com#import into mongomongoimport -d parks -c parkpoints --type json --file app-root/data/parkcoord.json -h$OPENSHIFT_NOSQL_DB_HOST -u admin -p $OPENSHIFT_NOSQL_DB_PASSWORD#open the mongo shellmongo#build the indexdb.parkpoints.ensureIndex({"pos":"2d"});#Now some queries##simple spatialdb.parkpoints.find({"pos" : { "$near" : [-37, 41]}});db.parkpoints.find({"pos" : { "$nearSphere" : [-37, 41]}});##bbox querydb.parkpoints.find( { "pos": { "$within": { "$box": [ [-70, 30] , [-82, 40] ] } } } )#spatial and text query using regexdb.parkpoints.find( { Name : /lincoln/i, pos : { $near : [-37,41] }} );#geoneardb.runCommand({ geoNear : "parkpoints", near : [-37,41], num : 10 });db.runCommand({ geoNear : "parkpoints", spherical: true, near : [-37,41], num : 10 });db.runCommand({ geoNear : "parkpoints", spherical: true, distanceMultiplier: 3963.192, near : [-37,41], num : 10 });https://github.com/openshift/openshift-mongo-node-express-examplehttp://nodewsos-spdemo.rhcloud.com/ws/parks
  • #create a new collection from scratchdb.createCollection("checkin");db.checkin.ensureIndex( { "pos" : "2d" } );#insert a new recorddb.checkin.insert({ "created" : new Date(), "Notes" : just landed, "pos" : [-76.7302 , 25.5332 ] })#quick query to make sure it workeddb.checkin.find( { pos : { $near : [-37,41] } } )#add a second document closer to query point#this is an upsert - since we dont pass in the _id it creates a new recorddb.checkin.save({ created : new Date(), Notes: that was a big step, pos : [-37.7302 , 40.5332 ]});#one way to update original documentmyDoc = db.checkin.findOne({_id : ObjectId("50130d8ea8f6532e83026bc1")});myDoc.Notes = "really the landing";db.checkin.save(myDoc);