Mobile 2: What's My Place in the Universe? Using Geo-Indexing to Solve Existential Dilemmas
-
Upload
mongodb -
Category
Technology
-
view
178 -
download
2
Transcript of Mobile 2: What's My Place in the Universe? Using Geo-Indexing to Solve Existential Dilemmas
- 1. Whats My Place in the Universe? Using Geo Indexes to Solve Existential Crises Building a Mobile App with MongoDB Part 2
- 2. 2 The Scavenger Hunt App Users create scavenger hunts by pinning waypoints
- 3. 3 The Scavenger Hunt App Players search for a scavenger hunt near their current position
- 4. 4 The Scavenger Hunt App Basic Requirements
- 5. 5 The Scavenger Hunt App Basic Requirements Mark target points
- 6. 6 The Scavenger Hunt App Basic Requirements Mark target points Identify our users
- 7. 7 The Scavenger Hunt App Basic Requirements Mark target points Identify our users Mark users progress during hunts
- 8. 8 Waypoint { _id: ObjectId(), user: UUID, tour: UUDI name: "Doug's Dogs", desc: "The best hot-dog", clues: [ "Hungry for a Coney Island?", "Ask for Dr. Frankenfurter", "Look for the hot dog stand" ], "geometry": { "type": "Point", "coordinates": [125.6, 10.1] } };
- 9. 9 Waypoint { _id: ObjectId(), user: UUID, tour: UUDI name: "Doug's Dogs", desc: "The best hot-dog", clues: [ "Hungry for a Coney Island?", "Ask for Dr. Frankenfurter", "Look for the hot dog stand" ], "geometry": { "type": "Point", "coordinates": [125.6, 10.1] } }; Geospacial Index: ensureIndex( { geometry: 2dsphere } )
- 10. 10 Waypoint db.waypoints.find( { geometry: { $near:{ { type : "Point" , coordinates : [ -173, 40.7 ] }, $maxDistance : 100 } }});
- 11. 11 GEOJSON Point MultiPoint LineString MultiLineString Polygon MultiPolygon GeometryCollection http://geojson.org/
- 12. Crisis 1: The sense of being alone and isolated in the world
- 13. 13 The Checkpoint Document { _id: ObjectId(), user: UUID, huntId: UUID, timestamp: ISODate(), geometry: { type: "Point", coordinates: [125.6, 10.1] } }
- 14. 14 The Checkpoint Document { _id: ObjectId(), user: UUID, huntId: UUID, timestamp: ISODate(), geometry: { type: "Point", coordinates: [125.6, 10.1] } } db.checkpoints.ensureIndex( timestamp: -1, geometry: 2dsphere );
- 15. 15 The Checkpoint Document db.checkpoints.find( { date: {$gt: } geometry: { $near:{ { type : "Point" , coordinates : [ -173, 40.7 ] }, $maxDistance : 100 } }}); { _id: ObjectId(), user: UUID, huntId: UUID, timestamp: ISODate(), geometry: { type: "Point", coordinates: [125.6, 10.1] } }
- 16. 16 The Checkpoint Document db.checkpoints.find( { date: {$gt: } geometry: { $near:{ { type : "Point" , coordinates : [ -173, 40.7 ] }, $maxDistance : 100 } }}); { _id: ObjectId(), user: UUID, huntId: UUID, timestamp: ISODate(), geometry: { type: "Point", coordinates: [125.6, 10.1] } }
- 17. 17 The Scavenger Hunt App
- 18. 18 Polygon
- 19. 19 Polygon Data Driven Decision How many people live around this area How many of my customers are around this distribution center What time of the day do they actually get in front of the shop Where are my competitors located How much time does it take get from A -> B
- 20. 20 Polygon { "type": "Polygon", "coordinates" : [ [ [ -73.969581, 40.760331 ], [ -73.974487, 40.762245 ], [ -73.977692, 40.763598], [ -73.979508, 40.761269 ], [ -73.982364, 40.762358 ], [ -73.983692, 40.760497 ], [ -73.972821, 40.755861 ], [ -73.969581, 40.760331 ] ] ] } Defines a business service area
- 21. 21 Polygon Defines a business service area { "type": "Polygon", "coordinates" : [ [ [ -73.969581, 40.760331 ], [ -73.974487, 40.762245 ], [ -73.977692, 40.763598], [ -73.979508, 40.761269 ], [ -73.982364, 40.762358 ], [ -73.983692, 40.760497 ], [ -73.972821, 40.755861 ], [ -73.969581, 40.760331 ] ] ] }
- 22. 22 Polygon
- 23. 23 $geowithin { geometry: { $geoWithin: { $geometry : { 'type': "Polygon", 'coordinates': [ [ [ -73.975181, 40.758494 ], [ -73.973336, 40.760965 ], [ -73.974924, 40.761663 ], [ -73.976748, 40.759160 ], [ -73.975181, 40.758494 ] ] ] }}}}
- 24. 24 $geoIntersects { $geoIntersects: { $geometry: { "type": "Point", "coordinates": [ -73.975010, 40.760071 ] } } }
- 25. 25 Complex Polygons
- 26. 26 Complex Polygons { "type": "Polygon", "coordinates" : [ [ [ -73.969581, 40.760331 ], [ -73.974487, 40.762245 ], [ -73.977692, 40.763598], [ -73.979508, 40.761269 ], [ -73.982364, 40.762358 ], [ -73.983692, 40.760497 ], [ -73.972821, 40.755861 ], [ -73.969581, 40.760331 ] ], [[ -73.975181, 40.758494 ], [ -73.973336, 40.760965 ], [ -73.974924, 40.761663 ], [ -73.976748, 40.759160 ], [ -73.975181, 40.758494 ]] ] }
- 27. 27 Complex Polygons
- 28. 28 Complex Polygons { $geoIntersects: { $geometry: { "type": "Point", "coordinates": [ -73.975010, 40.760071 ] } } }
- 29. 29 Rendering Geo Elements { type: "GeometryCollection", geometries: [ { type: "Point", coordinates: [ -73.975010, 40.760071 ] }, { type: "Polygon", coordinates: [[ [-73.975181, 40.758494 ], [-73.973336, 40.760965 ], [-73.974924, 40.761663 ], [-73.976748, 40.75916 ], [-73.975181, 40.758494 ] ]] } ] }
- 30. 30 Complex Polygons
- 31. 31 Complex Polygons { "type": "Polygon", "coordinates" : [ [ [ -73.969581, 40.760331 ], [ -73.974487, 40.762245 ], [ -73.977692, 40.763598], ], [ [ -73.975181, 40.758494 ], [ -73.973336, 40.760965 ], [ -73.974924, 40.761663 ], .. ], [ [ -73.979437, 40.755390 ], [ -73.976953, 40.754362 ], [ -73.978364, 40.752448 ], ] ] }
- 32. 32 Complex Polygons { "type": "Polygon", "coordinates" : [ [ [ -73.969581, 40.760331 ], [ -73.974487, 40.762245 ], [ -73.977692, 40.763598], ], [ [ -73.975181, 40.758494 ], [ -73.973336, 40.760965 ], [ -73.974924, 40.761663 ], .. ], [ [ -73.979437, 40.755390 ], [ -73.976953, 40.754362 ], [ -73.978364, 40.752448 ], ] ] } $err : Can't canonicalize query BadValue Secondary loops not contained by first exterior loop - secondary loops must be holes
- 33. 33 Complex Polygons { "type": "Polygon", "coordinates" : [ [ [ -73.969581, 40.760331 ], [ -73.974487, 40.762245 ], [ -73.977692, 40.763598], ], [ [ -73.975181, 40.758494 ], [ -73.973336, 40.760965 ], [ -73.974924, 40.761663 ], .. ], [ [ -73.979437, 40.755390 ], [ -73.976953, 40.754362 ], [ -73.978364, 40.752448 ], ] ] } $err : Can't canonicalize query BadValue Secondary loops not contained by first exterior loop - secondary loops must be holes
- 34. 34 { "type": "Polygon", "coordinates" : [ [ [ -73.969581, 40.760331 ], [ -73.974487, 40.762245 ], [ -73.977692, 40.763598], ], ] } { "type": "Polygon", "coordinates" : [ [ [ [ -73.979437, 40.755390 ], [ -73.976953, 40.754362 ], [ -73.978364, 40.752448 ], ] ] } Complex Polygons
- 35. 35 Complex Polygons $or : [ { "geometry" : { "$geoWithin" : { "$geometry" : { "type" : "Polygon", "coordinates" : [ ... ] }, { "geometry" : { "$geoWithin" : { "$geometry" : { "type" : "Polygon", "coordinates" : [ ... ] }
- 36. 36 Complex Polygons
- 37. 37 Complex Polygons { $geoIntersects: { $geometry: { "type": "LineString", "coordinates": [ [-73.979543, 40.761132], [-73.974715, 40.759127], [-73.973363, 40.760969], [-73.970059, 40.759600] ] } }
- 38. Crisis 2: Shattering of one's sense of reality, or how the world is.
- 39. 39 Honolulu to Tokyo
- 40. 40 Honolulu to Tokyo
- 41. 41 Honolulu to Tokyo
- 42. 42 Honolulu to Tokyo
- 43. 43 Coordinate Reference System A system to locate geographical entities WGS84 datum Geoid - the shape of the surface of the oceans EGM96 gravitational model "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }
- 44. 44 Geoid Credit: ESA
- 45. 45 Am I inside or outside the box?
- 46. 46 The Correct Interpretation
- 47. 47 Right Hand Rule
- 48. Crisis 3: Anew-found grasp or appreciation of one's mortality.
- 49. 49 BigPolygon in Action
- 50. 50 BigPolygon in Action
- 51. 51 BigPolygon in Action
- 52. Crisis 4: Awareness of one's freedom and the consequences of accepting freedom.
- 53. Questions?
- 54. Thanks! { name: Bryan Reinero, title: Developer Advocate, twitter: @blimpyacht, code: github.com/breinero email: [email protected] }