Storing and Analyzing GRID Data Using Oracle Spatial and Java
Bringing Spatial Love to Your Java Application
-
Upload
mongodb -
Category
Technology
-
view
654 -
download
3
Transcript of Bringing Spatial Love to Your Java Application
![Page 1: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/1.jpg)
1
Bringing Spatial Love to Your Java Application
Steven Citron-PoustyPaaS Dust Spreader, Red Hat@TheSteve0
![Page 2: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/2.jpg)
2
Agenda
• Learn a little spatial
• Load some spatial data into mongo
• Do a query or two
SIGN UP CODE: mongosv12
![Page 3: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/3.jpg)
3
Assumptions
1) You already know Java
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 session
![Page 4: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/4.jpg)
4
What is OpenShift?
Red Hat’s free platform as a service for applications in the cloud.
![Page 5: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/5.jpg)
5 Dalbera on Flickr
![Page 6: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/6.jpg)
6
Kind of like Amazon, right? Nope.
![Page 7: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/7.jpg)
7Cook24v on Flickr
![Page 8: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/8.jpg)
8
![Page 9: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/9.jpg)
9
What’s supported?
![Page 10: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/10.jpg)
10
There’s more? What’s the catch?
• We are really in Developer Preview
• OpenShift is free-as-in-beer & free-as-in-freedom
• Three 512 MB RAM / 1 GB storage gears
• Need more resources, just ask!
![Page 11: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/11.jpg)
11
On to spatial!
![Page 12: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/12.jpg)
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+Indexing
First link on a google search for “mongodb spatial indexing”
![Page 13: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/13.jpg)
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)
![Page 14: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/14.jpg)
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" } )
![Page 15: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/15.jpg)
15
Demo
1. I have an JEE6 app and a mongo instance running
2. Loaded some spatial data in JSON format
3. Made the 2d index
4. Do some fun spatial and MongoDB work
5. Show you the web services
![Page 16: Bringing Spatial Love to Your Java Application](https://reader033.fdocuments.us/reader033/viewer/2022052619/55514757b4c905c6268b4e64/html5/thumbnails/16.jpg)
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: mongosv12
http://openshift.redhat.com