get your spatial on with mongodb in the cloud
DESCRIPTION
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.TRANSCRIPT
1
Get your Spatial on withMongoDB in the Cloud
Linqing Lu, Yujie ZhangPaaS Dragon, Red Hat@openshift
2
Agenda
• Learn a little spatial• Learn a little OpenShift• Create spatial application on OpenShift• Do some querys
3
Spatial is fun
The spatial functionality Mongo currently has is:1)2d Index (Near, Containment)2)2dsphere Index
All of it is laid out on the following page:http://docs.mongodb.org/manual/applications/2d/http://docs.mongodb.org/manual/applications/2dsphere/
4
2d Index
1.Assumes coords are between -180 and 1802.Can handle any 2D coordinates3.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.
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 indexdb.places.ensureIndex( { loc : "2d" } )
3)Make a 2dsphere index db.places.ensureIndex( { loc : "2dsphere" } )
6
What is OpenShift?
Red Hat’s free platform as a service for applications in the cloud.
7
What is PaaS?PaaS = Platform as a Service(AKA, a Cloud Application Platform)
Code Deploy Enjoy
Save Time and MoneyCode your app
Push-button Deploy, and your App is running in the Cloud!
8
9
Without PaaS?!
How to Build an App:
Have an ideaGet budgetSubmit hardware acquisition requestWaitGet hardwareDeploy framework/appserver/databaseDeploy testing toolsTest testing toolsCode, test, repeatConfigure Prod servers (and buy them if needed)Push to ProdSecurity workLaunchOrder more servers to meet demandWaitDeploy new serversScale
...... ......
10
How to Build an App:
Have an ideaGet budgetSubmit hardware acquisition requestWaitGet hardwareDeploy framework/appserver/databaseDeploy testing toolsTest testing toolsCode, test, repeatConfigure Prod servers (and buy them if needed)Push to ProdSecurity workLaunchOrder more servers to meet demandWaitDeploy new serversScale
...... ......
Without PaaS?!
11
Developers ChooseHow To Work with OpenShift
Developer IDEIntegrations
Web BrowserConsole
Command LineTooling
REST APIs
12
Sign up!
www.openshift.com
MongoBJ2013
13
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 push
15
And, of Course, Powerful IDE Integration
16
Partnerships
Focused on developer acquisition
Each reaching >1M developersWant association with Red Hat brand & field in exchange for developers
Not yet ready for partners who want us to drive business for them (i.e. EnterpriseDB, New Relic)
17
Best of OSS Innovation
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 Preview
19
Demo
1.I have an app and a mongo instance running2.Load some spatial data in JSON format3.Make the 2d index4.Do 2 queries
• Finddb.parkpoints.find({"pos" : { "$near" : [-37, 41]}});db.parkpoints.find({ Name: /lincoln/i, pos: {$near: [-37,41] }} );
• geoNeardb.runCommand({geoNear: "parkpoints" , near: [50,50], num: 10 } );
20
Conclusion
1.Spatial is easy and fun on Mongo2.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.comCOME BY THE BOOTH
21
➔ IRC: freenode #openshift➔ Facebook/Twitter/Weibo: @openshift➔ Email: [email protected]➔ Community: www.openshift.com➔ Codes: github.com/openshift➔ Quickstarts: github.com/openshift-quickstart
Need more?