SlideShare uma empresa Scribd logo
1 de 16
Building Spatial Web Services
     with MongoDB + NodeJS in
        Less than 30 Minutes
      Steven Citron-Pousty
      PaaS Dust Spreader, Red Hat
      @TheSteve0


1
Agenda
    • Learn a little spatial
    • Load some spatial data into mongo
    • Do a query or two
    • Repo for today’s code is here –
      https://github.com/openshift/openshift-mongo-node-
      express-example

              SIGN UP CODE:
                jseverywhere
2
Assumptions
    1) You already know that Node.JS + Mongo is like
       chocolate and peanut butter
    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




3
What is OpenShift?

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




4
5
    Dalbera on Flickr
Kind of like Amazon, right? Nope.




6
Cook24v on Flickr
 7
8
What’s supported?




9
There’s more? 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




10
On to spatial!




11
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+Inde
 xing
 First link on a google search for “mongodb spatial
 indexing”

12
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)




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




14
Demo
 1. I have an Node.JS app and a mongo instance running
 2. Load some spatial data in JSON format
 3. Make the 2d index
 4. Do some fun spatial and MongoDB work
 5. Show you the web services




15
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:
                    jseverywhere
        http://openshift.redhat.com
16

Mais conteúdo relacionado

Mais procurados

Spatial script for my JS.Everywhere 2012
Spatial script for my JS.Everywhere 2012Spatial script for my JS.Everywhere 2012
Spatial script for my JS.Everywhere 2012
Steven Pousty
 
Confessions of a relational addict
Confessions of a relational addictConfessions of a relational addict
Confessions of a relational addict
Chandra Patni
 
Распределенные системы хранения данных, особенности реализации DHT в проекте ...
Распределенные системы хранения данных, особенности реализации DHT в проекте ...Распределенные системы хранения данных, особенности реализации DHT в проекте ...
Распределенные системы хранения данных, особенности реализации DHT в проекте ...
yaevents
 
37562259 top-consuming-process
37562259 top-consuming-process37562259 top-consuming-process
37562259 top-consuming-process
skumner
 
Administration
AdministrationAdministration
Administration
MongoSF
 

Mais procurados (18)

Spatial script for my JS.Everywhere 2012
Spatial script for my JS.Everywhere 2012Spatial script for my JS.Everywhere 2012
Spatial script for my JS.Everywhere 2012
 
Back to Basics German 3: Einführung in Replica Sets
Back to Basics German 3: Einführung in Replica SetsBack to Basics German 3: Einführung in Replica Sets
Back to Basics German 3: Einführung in Replica Sets
 
Confessions of a relational addict
Confessions of a relational addictConfessions of a relational addict
Confessions of a relational addict
 
GCE NFS HA
GCE NFS HAGCE NFS HA
GCE NFS HA
 
Redis clustering
Redis clusteringRedis clustering
Redis clustering
 
Introduction to Hadoop - FinistJug
Introduction to Hadoop - FinistJugIntroduction to Hadoop - FinistJug
Introduction to Hadoop - FinistJug
 
Mongo db cluster administration and Shredded Databases
Mongo db cluster administration and Shredded DatabasesMongo db cluster administration and Shredded Databases
Mongo db cluster administration and Shredded Databases
 
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
 
Hadoop con2016 - Implement Real-time Centralized logging System by Elastic Stack
Hadoop con2016 - Implement Real-time Centralized logging System by Elastic StackHadoop con2016 - Implement Real-time Centralized logging System by Elastic Stack
Hadoop con2016 - Implement Real-time Centralized logging System by Elastic Stack
 
Распределенные системы хранения данных, особенности реализации DHT в проекте ...
Распределенные системы хранения данных, особенности реализации DHT в проекте ...Распределенные системы хранения данных, особенности реализации DHT в проекте ...
Распределенные системы хранения данных, особенности реализации DHT в проекте ...
 
zmq.rs - A brief history of concurrency in Rust
zmq.rs - A brief history of concurrency in Rustzmq.rs - A brief history of concurrency in Rust
zmq.rs - A brief history of concurrency in Rust
 
37562259 top-consuming-process
37562259 top-consuming-process37562259 top-consuming-process
37562259 top-consuming-process
 
Sharding - patterns & antipatterns, Константин Осипов, Алексей Рыбак
Sharding -  patterns & antipatterns, Константин Осипов, Алексей РыбакSharding -  patterns & antipatterns, Константин Осипов, Алексей Рыбак
Sharding - patterns & antipatterns, Константин Осипов, Алексей Рыбак
 
Tarantool 1.6 talk at SECR 2014 conference
Tarantool 1.6 talk at SECR 2014 conferenceTarantool 1.6 talk at SECR 2014 conference
Tarantool 1.6 talk at SECR 2014 conference
 
Customizing Your Shell With Dotfiles
Customizing Your Shell With DotfilesCustomizing Your Shell With Dotfiles
Customizing Your Shell With Dotfiles
 
Ruby on embedded devices rug::b Aug 2014
Ruby on embedded devices rug::b Aug 2014Ruby on embedded devices rug::b Aug 2014
Ruby on embedded devices rug::b Aug 2014
 
Administration
AdministrationAdministration
Administration
 
MongoDB 3.0.0 vs 2.6.x vs 2.4.x Benchmark
MongoDB 3.0.0 vs 2.6.x vs 2.4.x BenchmarkMongoDB 3.0.0 vs 2.6.x vs 2.4.x Benchmark
MongoDB 3.0.0 vs 2.6.x vs 2.4.x Benchmark
 

Semelhante a Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012

Bringing Spatial Love to Your Java Application
Bringing Spatial Love to Your Java ApplicationBringing Spatial Love to Your Java Application
Bringing Spatial Love to Your Java Application
MongoDB
 
Mongo db bangalore
Mongo db bangaloreMongo db bangalore
Mongo db bangalore
MongoDB
 
MongoDB and the MEAN Stack
MongoDB and the MEAN StackMongoDB and the MEAN Stack
MongoDB and the MEAN Stack
MongoDB
 
Mongo db first steps with csharp
Mongo db first steps with csharpMongo db first steps with csharp
Mongo db first steps with csharp
Serdar Buyuktemiz
 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud
Shekhar Gulati
 
Accra MongoDB User Group
Accra MongoDB User GroupAccra MongoDB User Group
Accra MongoDB User Group
MongoDB
 

Semelhante a Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012 (20)

Bringing Spatial Love to Your Java Application
Bringing Spatial Love to Your Java ApplicationBringing Spatial Love to Your Java Application
Bringing Spatial Love to Your Java Application
 
Social IRC bots in the Cloud with OpenShift - Mongo London presentation by Ma...
Social IRC bots in the Cloud with OpenShift - Mongo London presentation by Ma...Social IRC bots in the Cloud with OpenShift - Mongo London presentation by Ma...
Social IRC bots in the Cloud with OpenShift - Mongo London presentation by Ma...
 
Mongo db bangalore
Mongo db bangaloreMongo db bangalore
Mongo db bangalore
 
Building Social IRC Bots with Node.js and MongoDB
Building Social IRC Bots with Node.js and MongoDBBuilding Social IRC Bots with Node.js and MongoDB
Building Social IRC Bots with Node.js and MongoDB
 
Bringing spatial love to your python application
Bringing spatial love to your python applicationBringing spatial love to your python application
Bringing spatial love to your python application
 
Philadelphia MongoDB User Group - Your First MongoDB Application
Philadelphia MongoDB User Group - Your First MongoDB ApplicationPhiladelphia MongoDB User Group - Your First MongoDB Application
Philadelphia MongoDB User Group - Your First MongoDB Application
 
MongoDB on CloudFoundry
MongoDB on CloudFoundryMongoDB on CloudFoundry
MongoDB on CloudFoundry
 
MongoDB on CloudFoundry
MongoDB on CloudFoundryMongoDB on CloudFoundry
MongoDB on CloudFoundry
 
MongoDB and the MEAN Stack
MongoDB and the MEAN StackMongoDB and the MEAN Stack
MongoDB and the MEAN Stack
 
New paradigms
New paradigmsNew paradigms
New paradigms
 
Mongo db first steps with csharp
Mongo db first steps with csharpMongo db first steps with csharp
Mongo db first steps with csharp
 
MongoDB Part 2
MongoDB Part 2MongoDB Part 2
MongoDB Part 2
 
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDBMongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Cons
 
Introduction to using MongoDB with Ruby
Introduction to using MongoDB with RubyIntroduction to using MongoDB with Ruby
Introduction to using MongoDB with Ruby
 
Bringing Some Spatial Love to your Application with OpenShift - Mongo Berlin ...
Bringing Some Spatial Love to your Application with OpenShift - Mongo Berlin ...Bringing Some Spatial Love to your Application with OpenShift - Mongo Berlin ...
Bringing Some Spatial Love to your Application with OpenShift - Mongo Berlin ...
 
Using MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 MinutesUsing MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 Minutes
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Accra MongoDB User Group
Accra MongoDB User GroupAccra MongoDB User Group
Accra MongoDB User Group
 

Mais de Steven Pousty

APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + DockerAPPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
Steven Pousty
 
Workshop For pycon13
Workshop For pycon13Workshop For pycon13
Workshop For pycon13
Steven Pousty
 
Spatial script for CIMA
Spatial script for CIMASpatial script for CIMA
Spatial script for CIMA
Steven Pousty
 
Spatial script for Spatial mongo for PHP and Zend
Spatial script for Spatial mongo for PHP and ZendSpatial script for Spatial mongo for PHP and Zend
Spatial script for Spatial mongo for PHP and Zend
Steven Pousty
 
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem ManagementDropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Steven Pousty
 
Using PostGIS To Add Some Spatial Flavor To Your Application
Using PostGIS To Add Some Spatial Flavor To Your ApplicationUsing PostGIS To Add Some Spatial Flavor To Your Application
Using PostGIS To Add Some Spatial Flavor To Your Application
Steven Pousty
 

Mais de Steven Pousty (16)

APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + DockerAPPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
 
Introduction to PaaS for application developers
Introduction to PaaS for application developersIntroduction to PaaS for application developers
Introduction to PaaS for application developers
 
London Cloud Summit 2014 - raising the tide: getting developers in the cloud
London Cloud Summit 2014  - raising the tide: getting developers in the cloudLondon Cloud Summit 2014  - raising the tide: getting developers in the cloud
London Cloud Summit 2014 - raising the tide: getting developers in the cloud
 
Workshop For pycon13
Workshop For pycon13Workshop For pycon13
Workshop For pycon13
 
Build a PaaS with OpenShift Origin
Build a PaaS with OpenShift OriginBuild a PaaS with OpenShift Origin
Build a PaaS with OpenShift Origin
 
Monkigras - dropping science on your developer ecosystem
Monkigras - dropping science on your developer ecosystemMonkigras - dropping science on your developer ecosystem
Monkigras - dropping science on your developer ecosystem
 
Spatial script for MongoBoulder
Spatial script for MongoBoulderSpatial script for MongoBoulder
Spatial script for MongoBoulder
 
Spatial script for CIMA
Spatial script for CIMASpatial script for CIMA
Spatial script for CIMA
 
Spatial script for Spatial mongo for PHP and Zend
Spatial script for Spatial mongo for PHP and ZendSpatial script for Spatial mongo for PHP and Zend
Spatial script for Spatial mongo for PHP and Zend
 
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem ManagementDropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
 
Open shift intro for Philly PUG
Open shift intro for Philly PUGOpen shift intro for Philly PUG
Open shift intro for Philly PUG
 
Open shift intro for Philly PUG
Open shift intro for Philly PUGOpen shift intro for Philly PUG
Open shift intro for Philly PUG
 
Script for Spatial Mongo
Script for Spatial MongoScript for Spatial Mongo
Script for Spatial Mongo
 
deCarta at BAPI
deCarta at BAPI deCarta at BAPI
deCarta at BAPI
 
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your AppLinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
 
Using PostGIS To Add Some Spatial Flavor To Your Application
Using PostGIS To Add Some Spatial Flavor To Your ApplicationUsing PostGIS To Add Some Spatial Flavor To Your Application
Using PostGIS To Add Some Spatial Flavor To Your Application
 

Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012

  • 1. Building Spatial Web Services with MongoDB + NodeJS in Less than 30 Minutes Steven Citron-Pousty PaaS Dust Spreader, Red Hat @TheSteve0 1
  • 2. Agenda • Learn a little spatial • Load some spatial data into mongo • Do a query or two • Repo for today’s code is here – https://github.com/openshift/openshift-mongo-node- express-example SIGN UP CODE: jseverywhere 2
  • 3. Assumptions 1) You already know that Node.JS + Mongo is like chocolate and peanut butter 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 3
  • 4. What is OpenShift? Red Hat’s free platform as a service for applications in the cloud. 4
  • 5. 5 Dalbera on Flickr
  • 6. Kind of like Amazon, right? Nope. 6
  • 8. 8
  • 10. There’s more? 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 10
  • 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+Inde xing First link on a google search for “mongodb spatial indexing” 12
  • 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) 13
  • 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" } ) 14
  • 15. Demo 1. I have an Node.JS app and a mongo instance running 2. Load some spatial data in JSON format 3. Make the 2d index 4. Do some fun spatial and MongoDB work 5. Show you the web services 15
  • 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: jseverywhere http://openshift.redhat.com 16