Successfully reported this slideshow.

Get your Spatial on with MongoDB in the Cloud

654 views

Published on

Want to move from code to cloud in under an hour? Red Hat's OpenShift Platform-as-a-Service (PaaS) makes it easy to develop, deploy, and scale applications in the cloud. Come learn about how PaaS can make you into a happier and more productive coder. - Get started with OpenShift as the PaaS for your web application. - Deploy your first application using the command line tools or the web console. - Add and manage the MongoDB backend. - Manage application changes with Git. - Enjoy the perfect combination of OpenShift and MongoDB.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Get your Spatial on with MongoDB in the Cloud

  1. 1. Get your Spatial on with MongoDB in the Cloud Linqing Lu, Yujie Zhang PaaS Dragon, Red Hat @openshift1
  2. 2. Agenda • Learn a little spatial • Learn a little OpenShift • Create spatial application on OpenShift • Do some querys2
  3. 3. Spatial is funThe spatial functionality Mongo currently has is:1)2d Index (Near, Containment)2)2dsphere IndexAll of it is laid out on the following page:http://docs.mongodb.org/manual/applications/2d/http://docs.mongodb.org/manual/applications/2dsphere/3
  4. 4. 2d Index 1.Assumes coords are between -180 and 180 2.Can handle any 2D coordinates 3.Has methods to handle curvature of the earth 4.$near:The query returns the 100 closest documents and sorts the documents from nearest to farthest. 5.$box:The query returns documents that are within the bounds of the rectangle, according to their point-based location data.4
  5. 5. How to make it work 1)Put your coordinates into an arrary {loc:[50,30]} //SUGGESTED OPTION {loc:{lon:40.739037,lat:73.992964}} {loc:{type:"Point",coordinates:[40,50]}} {loc:{type:"LineString",coordinates:[[40,50],[41,6]]}} {loc:{type:"Polygon",coordinates:[[[0,0],[3,6],[6,1],[0,0]]]}} 2)Make a 2d index db.places.ensureIndex( { loc : "2d" } ) 3)Make a 2dsphere index db.places.ensureIndex( { loc : "2dsphere" } )5
  6. 6. What is OpenShift? Red Hat’s free platform as a service for applications in the cloud.6
  7. 7. What is PaaS? PaaS = Platform as a Service (AKA, a Cloud Application Platform) Code Deploy Enjoy Push-button Save Time and Money Deploy, and Code your app your App is running in the Cloud!7
  8. 8. 8
  9. 9. Without PaaS?! How to Build an App: Have an idea Get budget Submit hardware acquisition request Wait Get hardware Deploy framework/appserver/database Deploy testing tools Test testing tools Code, test, repeat Configure Prod servers (and buy them if needed) Push to Prod Security work Launch Order more servers to meet demand Wait Deploy new servers Scale ...... ......9
  10. 10. Without PaaS?! How to Build an App: Have an idea Get budget Submit hardware acquisition request Wait Get hardware Deploy framework/appserver/database Deploy testing tools Test testing tools Code, test, repeat Configure Prod servers (and buy them if needed) Push to Prod Security work Launch Order more servers to meet demand Wait Deploy new servers Scale ...... ......10
  11. 11. Developers Choose How To Work with OpenShift Developer IDE IntegrationsCommand Line Web Browser Tooling Console REST APIs11
  12. 12. Sign up! MongoBJ2013 www.openshift.com12
  13. 13. 13
  14. 14. OpenShift’s CLI Tool gem install rhc 1.Create App, Embed database rhc app create myapp jbossas mysql 2.Add codes to your repo directory and commit them git add . && git commit 3.Push your codes to the Cloud. Done! git push14
  15. 15. And, of Course, Powerful IDE Integration15
  16. 16. Partnerships Focused on developer acquisition Each reaching >1M developers Want association with Red Hat brand & field in exchange for developersNot yet ready for partners who want us to drive business for them (i.e.EnterpriseDB, New Relic)16
  17. 17. Best of OSS Innovation17
  18. 18. Looks great, but 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 Preview18
  19. 19. Demo 1.I have an app and a mongo instance running 2.Load some spatial data in JSON format 3.Make the 2d index 4.Do 2 queries • Find db.parkpoints.find({"pos" : { "$near" : [-37, 41]}}); db.parkpoints.find({ Name: /lincoln/i, pos: {$near: [-37,41] }} ); • geoNear db.runCommand({geoNear: "parkpoints" , near: [50,50], num: 10 } );19
  20. 20. Conclusion 1.Spatial is easy and fun on Mongo 2.You can now build your own FourSquare or other checkin application. 3.You can build and deploy your application quickly without having to think about infrastructure. www.openshift.com COME BY THE BOOTH20
  21. 21. Need more? ➔ IRC: freenode #openshift ➔ Facebook/Twitter/Weibo: @openshift ➔ Email: openshift@redhat.com ➔ Community: www.openshift.com ➔ Codes: github.com/openshift ➔ Quickstarts: github.com/openshift-quickstart21

×