Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012

  • 1,166 views
Uploaded on

 

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

Views

Total Views
1,166
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
6
Comments
0
Likes
2

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. Building Spatial Web Services with MongoDB + NodeJS in Less than 30 Minutes Steven Citron-Pousty PaaS Dust Spreader, Red Hat @TheSteve01
  • 2. Agenda • Learn a little spatial • Load some spatial data into mongo • Do a query or two • Repo for today’s code is here – https://github.com/openshift/openshift-mongo-node- express-example SIGN UP CODE: jseverywhere2
  • 3. Assumptions 1) You already know that Node.JS + Mongo is like chocolate and peanut butter 2) You can use the command line 3) You are comfortable with Mongo command line 4) Please ask questions – though since we only have 30 minutes they may have to wait until the end or after the session3
  • 4. What is OpenShift? Red Hat’s free platform as a service for applications in the cloud.4
  • 5. 5 Dalbera on Flickr
  • 6. Kind of like Amazon, right? Nope.6
  • 7. Cook24v on Flickr 7
  • 8. 8
  • 9. What’s supported?9
  • 10. There’s more? What’s the catch?• OpenShift is free-as-in-beer & free-as-in-freedom• Three 512 MB RAM / 1 GB storage gears• Need more resources, just ask!• We are really in Developer Preview10
  • 11. On to spatial!11
  • 12. Spatial is fun The only spatial functionality Mongo currently has is: 1) Near 2) Containment All of it is laid out on one page: http://www.mongodb.org/display/DOCS/Geospatial+Inde xing First link on a google search for “mongodb spatial indexing”12
  • 13. Caveats 1. Assumes coords. are between -180 and 180 2. Can handle any 2D coordinates 3. Has methods to handle curvature of the earth (spherical)13
  • 14. How to make it work 1) Put your coordinates into an arrary { loc : [ 50 , 30 ] } //SUGGESTED OPTION { loc : { x : 50 , y : 30 } } { loc : { foo : 50 , y : 30 } } { loc : { lon : 40.739037, lat: 73.992964 } } 2) Make a 2d index db.places.ensureIndex( { loc : "2d" } )14
  • 15. Demo 1. I have an Node.JS app and a mongo instance running 2. Load some spatial data in JSON format 3. Make the 2d index 4. Do some fun spatial and MongoDB work 5. Show you the web services15
  • 16. Conclusion 1. Spatial is easy and fun on Mongo 2. You can now build your own FourSquare or other checkin application. 3. You can also build your own field data entry system. 4. You can build and deploy your application quickly without having to think about infrastructure. SIGN UP CODE: jseverywhere http://openshift.redhat.com16