SlideShare uma empresa Scribd logo
1 de 10
Location Based Services Lalit Kapoor - @idefine Washington, DC Monday, June 27, 2011
MongoDB Is Easy! Document Object Store JSON (BSON) Schema-less Multiple language support (c++ to python to nodejs) Easy-to-Scale (http://www.mongodb.org/display/DOCS/Production+Deployments) Support for geospatial indexing and queries
Building Your First Location Aware App Pulse Mobile
Pulse Help people in emergency situations Find the closest hospital Notify important contacts (immediate family, friends, primary care physician, etc) Extra features that would make this app rock! Provide real-time updates of your location to hospital and contacts Send pictures to hospital Get ER wait times (this data is available in some states) Notify hospital of important medical information: blood-type, allergies, current medications, EMR, etc (integrate with google health/careverge) Integrate with 3rd party devices (watches, wristbands, etc) that know your vitals such as: blood pressure and heart rate. Transmit to your smart phone and then to hospital and contacts
LBS w/MongoDB Get or collect some location data (addresses are fine) Store it in mongoDB if data is in tsv/csv/json use mongoimport find lat/lng if you don’t already have it use Google’s MAP API to find lat/long if you have an address build a 2d index (lat/lng) db.collection.ensureIndex({field:”2d”}); let the geospatial queries begin!
Get Some Data Location of Hospitals In The United States Medicare.gov has information about the quality of care at each hospital - this data also happens to include the address for over 4000 hospitals in the US
Import into MongoDB mongoimport --headerline --type csv --drop --db mongodc --collection hospitals --file OutcomeofCareMeasures.csv
Geospatial Indexing db.places.ensureIndex({loc:”2d”}); / (compounded indexes):  db.places.ensureIndex( { loc : "2d" , category : 1 } ); Geohash is calculated and stored in a B-Tree Sharding Capable (as of 1.7.2 - Thanks Mathias - from 10gen) Current Limitations “Doesn’t currently handle wrapping at the poles or at the transition from -180° to +180° longitude, however we detect when a search would wrap and raise an error” (Resolved in 1.9+) Need to use geoNear command instead of $near for now when sharding (see JIRA SERVER-1981) - Proposed for resolution in 2011 geoNear not in the pymongoDrivers! Eval Hack - http://permalink.gmane.org/gmane.comp.db.mongodb.user/67 (Thanks smsfail on #mongodb) eval_result = db.eval('db.runCommand( { geoNear : "location" , near :[%s,%s], num : %s } );' % (lat, lon, num)) results = eval_result.get('results', []) Do not shard on a geo key - works, but inefficient. See JIRA SERVER-1982.
Geospatial Querying geoNeargives you back the distance  (in radians if sphere=true) Results are sorted by distance away from points $near vs. $nearSphere (1.7.0) $within [box, center, polygon] instead of $near Not sorted by distance More examples and details on the wiki
Questions? Lalit Kapoor - @idefine

Mais conteúdo relacionado

Semelhante a MongoDC - Location Aware Applications w/mongodb

LiveLinkedData - TransWebData - Nantes 2013
LiveLinkedData - TransWebData - Nantes 2013LiveLinkedData - TransWebData - Nantes 2013
LiveLinkedData - TransWebData - Nantes 2013
Luis Daniel Ibáñez
 
Hive + Tez: A Performance Deep Dive
Hive + Tez: A Performance Deep DiveHive + Tez: A Performance Deep Dive
Hive + Tez: A Performance Deep Dive
DataWorks Summit
 

Semelhante a MongoDC - Location Aware Applications w/mongodb (20)

Geo-Indexing w/MongoDB
Geo-Indexing w/MongoDBGeo-Indexing w/MongoDB
Geo-Indexing w/MongoDB
 
LiveLinkedData - TransWebData - Nantes 2013
LiveLinkedData - TransWebData - Nantes 2013LiveLinkedData - TransWebData - Nantes 2013
LiveLinkedData - TransWebData - Nantes 2013
 
PRAFUL_HADOOP
PRAFUL_HADOOPPRAFUL_HADOOP
PRAFUL_HADOOP
 
PRAFUL_HADOOP
PRAFUL_HADOOPPRAFUL_HADOOP
PRAFUL_HADOOP
 
MongoDB Mobile - Bringing the Power of MongoDB to your Device
MongoDB Mobile - Bringing the Power of MongoDB to your DeviceMongoDB Mobile - Bringing the Power of MongoDB to your Device
MongoDB Mobile - Bringing the Power of MongoDB to your Device
 
MongoDB.local Berlin: MongoDB Mobile
MongoDB.local Berlin: MongoDB MobileMongoDB.local Berlin: MongoDB Mobile
MongoDB.local Berlin: MongoDB Mobile
 
MongoDB.local Atlanta: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local Atlanta: MongoDB Mobile: Bringing the Power of MongoDB to Your ...MongoDB.local Atlanta: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local Atlanta: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Json to hive_schema_generator
Json to hive_schema_generatorJson to hive_schema_generator
Json to hive_schema_generator
 
Hive + Tez: A Performance Deep Dive
Hive + Tez: A Performance Deep DiveHive + Tez: A Performance Deep Dive
Hive + Tez: A Performance Deep Dive
 
Hive+Tez: A performance deep dive
Hive+Tez: A performance deep diveHive+Tez: A performance deep dive
Hive+Tez: A performance deep dive
 
MongoDB Introduction and Data Modelling
MongoDB Introduction and Data Modelling MongoDB Introduction and Data Modelling
MongoDB Introduction and Data Modelling
 
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
 
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
 
Capstone Final
Capstone FinalCapstone Final
Capstone Final
 
Inroduction to Big Data
Inroduction to Big DataInroduction to Big Data
Inroduction to Big Data
 
Developing applications with Cloud Services #javaone 2012
Developing applications with Cloud Services  #javaone 2012Developing applications with Cloud Services  #javaone 2012
Developing applications with Cloud Services #javaone 2012
 
"Building Data Warehouse with Google Cloud Platform", Artem Nikulchenko
"Building Data Warehouse with Google Cloud Platform",  Artem Nikulchenko"Building Data Warehouse with Google Cloud Platform",  Artem Nikulchenko
"Building Data Warehouse with Google Cloud Platform", Artem Nikulchenko
 
The RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with OracleThe RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with Oracle
 
Differential Sync and JSON Patch @ SpringOne2GX 2014
Differential Sync and JSON Patch @ SpringOne2GX 2014Differential Sync and JSON Patch @ SpringOne2GX 2014
Differential Sync and JSON Patch @ SpringOne2GX 2014
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

MongoDC - Location Aware Applications w/mongodb

  • 1. Location Based Services Lalit Kapoor - @idefine Washington, DC Monday, June 27, 2011
  • 2. MongoDB Is Easy! Document Object Store JSON (BSON) Schema-less Multiple language support (c++ to python to nodejs) Easy-to-Scale (http://www.mongodb.org/display/DOCS/Production+Deployments) Support for geospatial indexing and queries
  • 3. Building Your First Location Aware App Pulse Mobile
  • 4. Pulse Help people in emergency situations Find the closest hospital Notify important contacts (immediate family, friends, primary care physician, etc) Extra features that would make this app rock! Provide real-time updates of your location to hospital and contacts Send pictures to hospital Get ER wait times (this data is available in some states) Notify hospital of important medical information: blood-type, allergies, current medications, EMR, etc (integrate with google health/careverge) Integrate with 3rd party devices (watches, wristbands, etc) that know your vitals such as: blood pressure and heart rate. Transmit to your smart phone and then to hospital and contacts
  • 5. LBS w/MongoDB Get or collect some location data (addresses are fine) Store it in mongoDB if data is in tsv/csv/json use mongoimport find lat/lng if you don’t already have it use Google’s MAP API to find lat/long if you have an address build a 2d index (lat/lng) db.collection.ensureIndex({field:”2d”}); let the geospatial queries begin!
  • 6. Get Some Data Location of Hospitals In The United States Medicare.gov has information about the quality of care at each hospital - this data also happens to include the address for over 4000 hospitals in the US
  • 7. Import into MongoDB mongoimport --headerline --type csv --drop --db mongodc --collection hospitals --file OutcomeofCareMeasures.csv
  • 8. Geospatial Indexing db.places.ensureIndex({loc:”2d”}); / (compounded indexes): db.places.ensureIndex( { loc : "2d" , category : 1 } ); Geohash is calculated and stored in a B-Tree Sharding Capable (as of 1.7.2 - Thanks Mathias - from 10gen) Current Limitations “Doesn’t currently handle wrapping at the poles or at the transition from -180° to +180° longitude, however we detect when a search would wrap and raise an error” (Resolved in 1.9+) Need to use geoNear command instead of $near for now when sharding (see JIRA SERVER-1981) - Proposed for resolution in 2011 geoNear not in the pymongoDrivers! Eval Hack - http://permalink.gmane.org/gmane.comp.db.mongodb.user/67 (Thanks smsfail on #mongodb) eval_result = db.eval('db.runCommand( { geoNear : "location" , near :[%s,%s], num : %s } );' % (lat, lon, num)) results = eval_result.get('results', []) Do not shard on a geo key - works, but inefficient. See JIRA SERVER-1982.
  • 9. Geospatial Querying geoNeargives you back the distance  (in radians if sphere=true) Results are sorted by distance away from points $near vs. $nearSphere (1.7.0) $within [box, center, polygon] instead of $near Not sorted by distance More examples and details on the wiki

Notas do Editor

  1. Today I’m going to be talking about building location aware applications with mongodb
  2. If you’re new to mongodb, there are various reasons for why you may want to choose it as your database, but today I’m going to focus on its support for working with geospatial data
  3. I was planning on just pulling up the mongo shell and going through some geo commandsBut that would be boring and you’d learn more from the wiki anyway, so I decided to actually build an app that would show case some of mongo’s geo capabilitiesI made a mobile app called Pulse that utilizes the technologies you see on this pageWe will touch up on how each of these is used later on
  4. I use to work for a healthcare startup in DC and so I wanted to build something around health that was immediately useful to the end user
  5. So, let’s get started with what it takes to build an app like pulse
  6. Ok, so back to pulse
  7. By geohashing we transform the 2d search problem back into a 1d search problem, which is what B-tree indexes are good at.The geo-index of MongoDB encodes a geohash on top of a standard MongoDB b-tree. Geohashing is a way to divide a coordinate system into hierarchical buckets of grid shape.It basically divides an area in two for every bit and so on.A drawback of geohashing is the wrapping (-180 and 179 are very close for example), this can be solved by doing a grid search after the initial scan. It’s a bit comparable by how google maps loads the map images, it starts with the center of the viewport and then the surrounding areas are downloaded.