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.
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Get your Spatial on with MongoDB in the Cloud
1. Get your Spatial on with
MongoDB in the Cloud
Linqing Lu, Yujie Zhang
PaaS Dragon, Red Hat
@openshift
1
2. Agenda
• Learn a little spatial
• Learn a little OpenShift
• Create spatial application on OpenShift
• Do some querys
2
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/
3
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. 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. What is OpenShift?
Red Hat’s free platform as a service for applications in the cloud.
6
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
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. 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. Developers Choose
How To Work with OpenShift
Developer IDE
Integrations
Command Line Web Browser
Tooling Console
REST APIs
11
16. Partnerships
Focused on developer acquisition
Each reaching >1M developers
Want 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)
16
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
18
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. 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 BOOTH
20