• Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
256
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
1
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. #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
  • 2. #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);