SlideShare a Scribd company logo
@mongodb @idbentley @10gen




MongoDB 2.4 Geo
Features
Ian Bentley
Web Engineer, 10gen
Planar Geometry
         2.4 Geospatial features – Ian Bentley
xkcd.com/977


Spherical Geometry
         2.4 Geospatial features – Ian Bentley
MongoDB has had geo for a
while
• `2d` index
   – Store points on 2d plane
   – Search for points within a:
      • Rectangle ($box)
      • Polygon ($polygon)
      • Circle ($center)
      • Circle on a sphere ($centerSphere)
   – Search for nearest points ($near, $nearSphere)




                      2.4 Geospatial features – Ian Bentley
Some desirable things!
• Storing non-point geometries
• Within searches on a sphere
• Searching for intersecting geometries on a
 sphere
• Better support for compound indexes




                 2.4 Geospatial features – Ian Bentley
Storing non-point geometries
• GeoJSON – A collaborative community project
 that produced a specification for encoding
 geometric entities in JSON
• Gaining wide support
  – OpenLayers
  – PostGIS
  – Libraries in several languages




                    2.4 Geospatial features – Ian Bentley
GeoJSON allows us to
encode
Points:


{
    geo: {
          type: "Point",
          coordinates: [100.0, 0.0]
    }
}




                     2.4 Geospatial features – Ian Bentley
GeoJSON allows us to
encode
LineStrings:


{
    geo: {
         type: "LineString",
         coordinates: [ [100.0, 0.0], [101.0, 1.0] ]
    }
}




                    2.4 Geospatial features – Ian Bentley
GeoJSON allows us to
encode
Polygons:


{         geo: {
              type: "Polygon",
              coordinates: [
                   [ [100.0, 0.0], [101.0, 0.0],
                     [101.0, 1.0], [100.0, 1.0],
                     [100.0, 0.0] ]
              ]
    } }


                          2.4 Geospatial features – Ian Bentley
Within searches on a sphere
• $geoWithin operator
• Takes a GeoJSON polygon geometry as a
 specifier
• Returns any geometries of any type that are fully
 contained within the polygon
• Works without any index.




                  2.4 Geospatial features – Ian Bentley
Intersecting geometries on a
sphere
• $geoIntersects operator
• Takes any GeoJSON geometry as a specifier
• Returns any geometries that have a non-empty
 intersection
• Lots of edge cases – intersecting edges, points
 on lines.
• Works without any index.



                  2.4 Geospatial features – Ian Bentley
Better support for compound
indexes
• Unlike 2d indexes, 2dsphere indexes aren’t
 required to be the first field of a compound index
   – Filtering potential documents before doing geo query can
     drastically improve the performance of some queries
      • “Find me Hot Dog Stands within New York state”
      • “Find me geometries in New York state that are
        Hot Dog Stands”
• Multiple geo fields can be in the same index
   – “Find routes with start location 50miles from JFK and end
     location 100miles from YYC”

                     2.4 Geospatial features – Ian Bentley
Demo Example
• You can find all the code, and data powering the
 demo on github, and read about it on my blog
• Let’s take a close look at the python that does
 the actual work.




                    2.4 Geospatial features – Ian Bentley
It’s this simple - within
def find_within(points):
   # When defining a polygon, the first point should
   # also appear as the last point.
   points.append(points[0])
   poly = {
        "type": "Polygon",
        "coordinates": [points]
   }
   places = collection.find(
       {"geo": { "$within": { "$geometry": poly } } } )
   places.limit(500)
   return places
                       2.4 Geospatial features – Ian Bentley
It’s this simple - intersects
def find_intersects(points):
   line = {
       "type": "LineString",
       "coordinates": points
       }
   places = collection.find(
       {"geo":{ "$geoIntersects":
           { "$geometry": line } } } )
   places.limit(50)
   return places




                      2.4 Geospatial features – Ian Bentley
It’s this simple - near
def find_nearest(point):
   point = {
            "type": "Point",
            "coordinates": point
            }
   places = collection.find(
       {"geo": { "$near": { "$geometry": point } } })
   places.limit(10)
   return places




                      2.4 Geospatial features – Ian Bentley
How 2dsphere works
How do you index a spherical
coordinate?
• Divide the geometry that you are indexing into a
 grid.
• For each cell in the grid, calculate a key, based
 upon its position on the sphere.
• Insert each cell into a standard B-tree
• MongoDB uses google’s S2 C++ library for the
 heavy lifting.


                  2.4 Geospatial features – Ian Bentley
Coarse Grid overlayed on the
UK
          2.4 Geospatial features – Ian Bentley
Coverings
• A covering of a geometry is a minimal set of cells
 that completely cover’s a geometry
• S2 can efficiently generate coverings for arbitrary
 geometries.




                  2.4 Geospatial features – Ian Bentley
Covering of Grid of the UK
         2.4 Geospatial features – Ian Bentley
Covering of A4 surrounding
Trafalgar Square
          2.4 Geospatial features – Ian Bentley
Cells
• S2 defines cell sizes from level 1 to level 31
• The higher the level, the smaller the cell
• Different levels are optimized for different queries
   – If you have densely packed geometries, and you are
     doing a $near search, a higher level will be efficient
   – If you are doing a $within search with a large polygon, a
     lower level will be more efficient
• By default we use all levels between 500m and
 100km on a side

                      2.4 Geospatial features – Ian Bentley
Near search
         2.4 Geospatial features – Ian Bentley
Near search
         2.4 Geospatial features – Ian Bentley
Near search
         2.4 Geospatial features – Ian Bentley
Near search
         2.4 Geospatial features – Ian Bentley
Near search
         2.4 Geospatial features – Ian Bentley
Near search
         2.4 Geospatial features – Ian Bentley
Q&A

More Related Content

Similar to Webinar: MongoDB 2.4 Feature Demo and Q&A on Geo Capabilities

OSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross LawleyOSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
NETWAYS
 
Efficient Query Processing in Geographic Web Search Engines
Efficient Query Processing in Geographic Web Search EnginesEfficient Query Processing in Geographic Web Search Engines
Efficient Query Processing in Geographic Web Search Engines
Yen-Yu Chen
 
The Latest in Spatial & Temporal Search: Presented by David Smiley
The Latest in Spatial & Temporal Search: Presented by David SmileyThe Latest in Spatial & Temporal Search: Presented by David Smiley
The Latest in Spatial & Temporal Search: Presented by David Smiley
Lucidworks
 
Lucene solr 4 spatial extended deep dive
Lucene solr 4 spatial   extended deep diveLucene solr 4 spatial   extended deep dive
Lucene solr 4 spatial extended deep dive
lucenerevolution
 
Indexing Strategies to Help You Scale
Indexing Strategies to Help You ScaleIndexing Strategies to Help You Scale
Indexing Strategies to Help You Scale
MongoDB
 
Webinar: Building Your First Application with MongoDB
Webinar: Building Your First Application with MongoDBWebinar: Building Your First Application with MongoDB
Webinar: Building Your First Application with MongoDB
MongoDB
 
2012 URISA Track, Geologic Mapping 101: Common Pitfalls and Suggestions for a...
2012 URISA Track, Geologic Mapping 101: Common Pitfalls and Suggestions for a...2012 URISA Track, Geologic Mapping 101: Common Pitfalls and Suggestions for a...
2012 URISA Track, Geologic Mapping 101: Common Pitfalls and Suggestions for a...
GIS in the Rockies
 
Geoindexing with MongoDB
Geoindexing with MongoDBGeoindexing with MongoDB
Geoindexing with MongoDB
leafnode
 
Day 6 - PostGIS
Day 6 - PostGISDay 6 - PostGIS
Day 6 - PostGIS
Barry Jones
 
Jquery2012 defs
Jquery2012 defsJquery2012 defs
Jquery2012 defs
司徒 正美
 
PostGIS and Spatial SQL
PostGIS and Spatial SQLPostGIS and Spatial SQL
PostGIS and Spatial SQL
Todd Barr
 
OSCON july 2011
OSCON july 2011OSCON july 2011
OSCON july 2011chelm
 

Similar to Webinar: MongoDB 2.4 Feature Demo and Q&A on Geo Capabilities (12)

OSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross LawleyOSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
 
Efficient Query Processing in Geographic Web Search Engines
Efficient Query Processing in Geographic Web Search EnginesEfficient Query Processing in Geographic Web Search Engines
Efficient Query Processing in Geographic Web Search Engines
 
The Latest in Spatial & Temporal Search: Presented by David Smiley
The Latest in Spatial & Temporal Search: Presented by David SmileyThe Latest in Spatial & Temporal Search: Presented by David Smiley
The Latest in Spatial & Temporal Search: Presented by David Smiley
 
Lucene solr 4 spatial extended deep dive
Lucene solr 4 spatial   extended deep diveLucene solr 4 spatial   extended deep dive
Lucene solr 4 spatial extended deep dive
 
Indexing Strategies to Help You Scale
Indexing Strategies to Help You ScaleIndexing Strategies to Help You Scale
Indexing Strategies to Help You Scale
 
Webinar: Building Your First Application with MongoDB
Webinar: Building Your First Application with MongoDBWebinar: Building Your First Application with MongoDB
Webinar: Building Your First Application with MongoDB
 
2012 URISA Track, Geologic Mapping 101: Common Pitfalls and Suggestions for a...
2012 URISA Track, Geologic Mapping 101: Common Pitfalls and Suggestions for a...2012 URISA Track, Geologic Mapping 101: Common Pitfalls and Suggestions for a...
2012 URISA Track, Geologic Mapping 101: Common Pitfalls and Suggestions for a...
 
Geoindexing with MongoDB
Geoindexing with MongoDBGeoindexing with MongoDB
Geoindexing with MongoDB
 
Day 6 - PostGIS
Day 6 - PostGISDay 6 - PostGIS
Day 6 - PostGIS
 
Jquery2012 defs
Jquery2012 defsJquery2012 defs
Jquery2012 defs
 
PostGIS and Spatial SQL
PostGIS and Spatial SQLPostGIS and Spatial SQL
PostGIS and Spatial SQL
 
OSCON july 2011
OSCON july 2011OSCON july 2011
OSCON july 2011
 

More from MongoDB

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB
 

More from MongoDB (20)

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
 

Recently uploaded

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 

Recently uploaded (20)

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 

Webinar: MongoDB 2.4 Feature Demo and Q&A on Geo Capabilities

  • 1. @mongodb @idbentley @10gen MongoDB 2.4 Geo Features Ian Bentley Web Engineer, 10gen
  • 2. Planar Geometry 2.4 Geospatial features – Ian Bentley
  • 3. xkcd.com/977 Spherical Geometry 2.4 Geospatial features – Ian Bentley
  • 4. MongoDB has had geo for a while • `2d` index – Store points on 2d plane – Search for points within a: • Rectangle ($box) • Polygon ($polygon) • Circle ($center) • Circle on a sphere ($centerSphere) – Search for nearest points ($near, $nearSphere) 2.4 Geospatial features – Ian Bentley
  • 5. Some desirable things! • Storing non-point geometries • Within searches on a sphere • Searching for intersecting geometries on a sphere • Better support for compound indexes 2.4 Geospatial features – Ian Bentley
  • 6. Storing non-point geometries • GeoJSON – A collaborative community project that produced a specification for encoding geometric entities in JSON • Gaining wide support – OpenLayers – PostGIS – Libraries in several languages 2.4 Geospatial features – Ian Bentley
  • 7. GeoJSON allows us to encode Points: { geo: { type: "Point", coordinates: [100.0, 0.0] } } 2.4 Geospatial features – Ian Bentley
  • 8. GeoJSON allows us to encode LineStrings: { geo: { type: "LineString", coordinates: [ [100.0, 0.0], [101.0, 1.0] ] } } 2.4 Geospatial features – Ian Bentley
  • 9. GeoJSON allows us to encode Polygons: { geo: { type: "Polygon", coordinates: [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ] ] } } 2.4 Geospatial features – Ian Bentley
  • 10. Within searches on a sphere • $geoWithin operator • Takes a GeoJSON polygon geometry as a specifier • Returns any geometries of any type that are fully contained within the polygon • Works without any index. 2.4 Geospatial features – Ian Bentley
  • 11. Intersecting geometries on a sphere • $geoIntersects operator • Takes any GeoJSON geometry as a specifier • Returns any geometries that have a non-empty intersection • Lots of edge cases – intersecting edges, points on lines. • Works without any index. 2.4 Geospatial features – Ian Bentley
  • 12. Better support for compound indexes • Unlike 2d indexes, 2dsphere indexes aren’t required to be the first field of a compound index – Filtering potential documents before doing geo query can drastically improve the performance of some queries • “Find me Hot Dog Stands within New York state” • “Find me geometries in New York state that are Hot Dog Stands” • Multiple geo fields can be in the same index – “Find routes with start location 50miles from JFK and end location 100miles from YYC” 2.4 Geospatial features – Ian Bentley
  • 14. • You can find all the code, and data powering the demo on github, and read about it on my blog • Let’s take a close look at the python that does the actual work. 2.4 Geospatial features – Ian Bentley
  • 15. It’s this simple - within def find_within(points): # When defining a polygon, the first point should # also appear as the last point. points.append(points[0]) poly = { "type": "Polygon", "coordinates": [points] } places = collection.find( {"geo": { "$within": { "$geometry": poly } } } ) places.limit(500) return places 2.4 Geospatial features – Ian Bentley
  • 16. It’s this simple - intersects def find_intersects(points): line = { "type": "LineString", "coordinates": points } places = collection.find( {"geo":{ "$geoIntersects": { "$geometry": line } } } ) places.limit(50) return places 2.4 Geospatial features – Ian Bentley
  • 17. It’s this simple - near def find_nearest(point): point = { "type": "Point", "coordinates": point } places = collection.find( {"geo": { "$near": { "$geometry": point } } }) places.limit(10) return places 2.4 Geospatial features – Ian Bentley
  • 19. How do you index a spherical coordinate? • Divide the geometry that you are indexing into a grid. • For each cell in the grid, calculate a key, based upon its position on the sphere. • Insert each cell into a standard B-tree • MongoDB uses google’s S2 C++ library for the heavy lifting. 2.4 Geospatial features – Ian Bentley
  • 20. Coarse Grid overlayed on the UK 2.4 Geospatial features – Ian Bentley
  • 21. Coverings • A covering of a geometry is a minimal set of cells that completely cover’s a geometry • S2 can efficiently generate coverings for arbitrary geometries. 2.4 Geospatial features – Ian Bentley
  • 22. Covering of Grid of the UK 2.4 Geospatial features – Ian Bentley
  • 23. Covering of A4 surrounding Trafalgar Square 2.4 Geospatial features – Ian Bentley
  • 24. Cells • S2 defines cell sizes from level 1 to level 31 • The higher the level, the smaller the cell • Different levels are optimized for different queries – If you have densely packed geometries, and you are doing a $near search, a higher level will be efficient – If you are doing a $within search with a large polygon, a lower level will be more efficient • By default we use all levels between 500m and 100km on a side 2.4 Geospatial features – Ian Bentley
  • 25. Near search 2.4 Geospatial features – Ian Bentley
  • 26. Near search 2.4 Geospatial features – Ian Bentley
  • 27. Near search 2.4 Geospatial features – Ian Bentley
  • 28. Near search 2.4 Geospatial features – Ian Bentley
  • 29. Near search 2.4 Geospatial features – Ian Bentley
  • 30. Near search 2.4 Geospatial features – Ian Bentley
  • 31. Q&A

Editor's Notes

  1. Hit Record and make sure it recordsOpen your demo.Move your mouse.Make announcement about QA five minutes before and as you start
  2. This is 6th grade geometry on the cartesian plane. Often called (inexactly) Euclidean geometryAn plane is infinite in all directions. This is a convenient way of reasoning about geometry because math on the plane is easy. As a simplification of a sphere, however, it has pretty big problems as soon as you start to worry about large polygons, long lines, or any degree of accuracy.
  3. As is excellently highlighted by Randall Munroe of xkcd, projecting a sphere onto a plane is non-obvious. It’s similarly not easy the other direction.Managing the math for sphere’s is much more difficult than on a plane, and definitely not something most of us want to implement.
  4. The 2d index was introduced in Mongodb 2.2End this slide by saying: “All this is great, but there are some additional features that we might like.”
  5. Points are great, but we want to store arbitrary polygons, lines, etc.
  6. Notice that the first point is the same as the last point.This is the simplest polygon form. The coordinate specification is a list of list of point specs. The first list of point specifications describes the exterior shell of the polygon, and each subsequent list of points describes a hole in the polygon.MongoDB will reject any polygons that self intersect with a parse error.
  7. Within searches on the plane with large polygons can be significantly different than on the sphere because they follow the curvature of the sphere.
  8. Re: edge cases: Some are documented on mongodb.org, but there are far too many to detail, so make sure to play around with your particular edge cases.
  9. If you have a collection of documents that are all the businesses in America, filtering for type Hot Dog Stand will reduce the set of results significantly, and searching for an exact match string compare on a normal mongo index is a very quick operation, compared to a geo index search. Because of that stating the question in the first order will be much faster than stating it in the second way.Indexing multiple geo fields was not possible between 2.4, and make possible a whole suite of queries that weren’t possible before.
  10. 1st point and 2nd point define the first line.2nd point and 3rd point define the second line.So on.
  11. $maxDistance operator is an optional operator that allows us to specify a maximum distance away from a point, which to go looking.
  12. Tricky bitsHow do you use that index efficiently?How do you decide the size of the cells? How do you calculate thebtree key
  13. Works by looking at concentric donuts starting from the center point.Here we are searching for pubs near a point on Leicester SquareNothing in donut 1
  14. The porcupine is within the second donut, but although the Brewmaster is within the covering for the second donut, it isn’t actually within the donut
  15. This continues until we have found enough points to fill a batch