Recherche
Géospatiale


Dans MongoDb


@HugoCrd

De + en + de données

Géolocalisées

Quelles données

Ici ?

Quelles données

Autour d'ici ?

Combiner la recherche à

d'autres critères

Quelles solutions pour le

développeur

Faire soi-même

Les cartes sont plates, la terre est ronde

Solr

Hibernate Search

Indexent des données existantes

NEO4J, PostGreSQL+PostGIS
Microsoft SQL Server, MongoDb

Indexation native

MongoDb

noSql

Orienté Document

Orienté Document


{
name:'HumanDude',
loves:['code','beer']
}
					

Requêtage en Json


db.collection.find( {name:'HumanDude'} )
					

Représentation géographique


{
name:'HumanDude',
loves:['code','beer'],
loc:{lat:42.432,lng:2.324}
}
					

Définition de l'index


db.collection.ensureIndex( { loc : "2d" } )
					

$near et $within


//Résultats trié
db.collection.find({loc : { $near : [50,50] , $maxDistance : 5 }})

					

//Résultats non trié
db.collection.find({loc : {$within : {$center : [50,50], 5] }}})
db.collection.find({loc : {$within : {$box : [[40, 50], [10, 20]]}}})
db.collection.find({loc : {$within : {$polygon : [[10, 20], [10, 40], [30, 40], [30, 20]]}}})

					

La terre est ronde


db.collection.find( {loc: {$nearSphere : [0,0]}})
					

db.collection.find( {loc: {$within : {$centerSphere : {[0,0], 10}}}})
					
Les distances sont alors en radians

Avantages

  • Out of the box
  • Sharding
  • Multi-location

Cas d'utilisation

Human Map

@HugoCrd
http://humanmap.cloudfoundry.com
https://github.com/HugoCrd/HumanMap