get your spatial on with mongodb in the cloud

22
1 Get your Spatial on with MongoDB in the Cloud Linqing Lu, Yujie Zhang PaaS Dragon, Red Hat @openshift

Upload: mongodb

Post on 12-May-2015

415 views

Category:

Technology


3 download

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

Page 1: Get your Spatial on with MongoDB in the Cloud

1

Get your Spatial on withMongoDB in the Cloud

Linqing Lu, Yujie ZhangPaaS Dragon, Red Hat@openshift

Page 2: Get your Spatial on with MongoDB in the Cloud

2

Agenda

• Learn a little spatial• Learn a little OpenShift• Create spatial application on OpenShift• Do some querys

Page 3: Get your Spatial on with MongoDB in the Cloud

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/

Page 4: Get your Spatial on with MongoDB in the Cloud

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.

Page 5: Get your Spatial on with MongoDB in the Cloud

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" } )

Page 6: Get your Spatial on with MongoDB in the Cloud

6

What is OpenShift?

Red Hat’s free platform as a service for applications in the cloud.

Page 7: Get your Spatial on with MongoDB 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!

Page 8: Get your Spatial on with MongoDB in the Cloud

8

Page 9: Get your Spatial on with MongoDB in the Cloud

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

...... ......

Page 10: Get your Spatial on with MongoDB in the Cloud

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?!

Page 11: Get your Spatial on with MongoDB in the Cloud

11

Developers ChooseHow To Work with OpenShift

Developer IDEIntegrations

Web BrowserConsole

Command LineTooling

REST APIs

Page 12: Get your Spatial on with MongoDB in the Cloud

12

Sign up!

www.openshift.com

MongoBJ2013

Page 13: Get your Spatial on with MongoDB in the Cloud

13

Page 14: Get your Spatial on with MongoDB in the Cloud

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

Page 15: Get your Spatial on with MongoDB in the Cloud

15

And, of Course, Powerful IDE Integration

Page 16: Get your Spatial on with MongoDB in the Cloud

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)

Page 17: Get your Spatial on with MongoDB in the Cloud

17

Best of OSS Innovation

Page 18: Get your Spatial on with MongoDB in the Cloud

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

Page 19: Get your Spatial on with MongoDB in the Cloud

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 } );

Page 20: Get your Spatial on with MongoDB in the Cloud

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

Page 21: Get your Spatial on with MongoDB in the Cloud

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?

Page 22: Get your Spatial on with MongoDB in the Cloud