Your SlideShare is downloading. ×
  • Like
Spatial script for CIMA
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Spatial script for CIMA

  • 178 views
Published

 

Published in Technology
  • 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
178
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
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. 1 #commands for adding spatial data! 2 ! 3 #Take a look at the file first! 4 #less parkcoord.json! 5 ! 6 #get the file on the server! 7 scp parkcoord.json 30bb1262b1364026855e358a649f171b@parks-spmongo.rhcloud.com:app-root/data! 8 ! 9 #ssh into the machine!10 ssh 30bb1262b1364026855e358a649f171b@parks-spmongo.rhcloud.com!11 !12 !13 #import into mongo!14 mongoimport -d parks -c parkpoints --type json --file app-root/data/parkcoord.json -h … $OPENSHIFT_NOSQL_DB_HOST -u admin -p $OPENSHIFT_NOSQL_DB_PASSWORD!15 !16 #open the mongo shell!17 mongo !18 !19 #build the index!20 db.parkpoints.ensureIndex({"pos":"2d"});!21 !22 #Now some queries!23 #simple spatial!24 db.parkpoints.find({"pos" : { "$near" : [-37, 41]}});!25 !26 #spatial and text query using regex!27 db.parkpoints.find( { Name : /lincoln/i, pos : { $near : [-37,41] }} );!28 !29 #geonear TODO!30 db.runCommand({ geoNear : "parkpoints", near : [-37,41], num : 10 });!31 !32 !33 https://github.com/openshift/openshift-mongo-node-express-example!34 !35 http://nodewsos-spdemo.rhcloud.com/ws/parks!36 !37 !38 !39 !40 !41 !42 #create a new collection from scratch!43 db.createCollection("checkin");!44 db.checkin.ensureIndex( { "pos" : "2d" } );!45 !46 #insert a new record!47 db.checkin.insert({ "created" : new Date(), "Notes" : just landed, "pos" : [-76.7302 , 25.5332 ] })!48 ! !49 #quick query to make sure it worked!50 db.checkin.find( { pos : { $near : [-37,41] } } )!51 !52 #add a second document closer to query point!53 #this is an upsert - since we dont pass in the _id it creates a new record!54 db.checkin.save({ created : new Date(), Notes: that was a big step, pos : [-37.7302 , 40.5332 ]});!55 !56 #one way to update original document!57 myDoc = db.checkin.findOne({_id : ObjectId("50130d8ea8f6532e83026bc1")});!58 myDoc.Notes = "really the landing";!59 db.checkin.save(myDoc);!60 !61 !62 !63 !64