Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Recherche Géospatiale dans MongoDB

Recherche Géospatiale dans MongoDB

Avatar for Hugo Cordier

Hugo Cordier

December 12, 2012
Tweet

More Decks by Hugo Cordier

Other Decks in Programming

Transcript

  1. ORIENTÉ DOCUMENT { n a m e : ' H

    u m a n D u d e ' , l o v e s : [ ' c o d e ' , ' b e e r ' ] }
  2. REQUÊTAGE EN JSON d b . c o l l

    e c t i o n . f i n d ( { n a m e : ' H u m a n D u d e ' } )
  3. REPRÉSENTATION GÉOGRAPHIQUE { n a m e : ' H

    u m a n D u d e ' , l o v e s : [ ' c o d e ' , ' b e e r ' ] , l o c : { l a t : 4 2 . 4 3 2 , l n g : 2 . 3 2 4 } }
  4. DÉFINITION DE L'INDEX d b . c o l l

    e c t i o n . e n s u r e I n d e x ( { l o c : " 2 d " } )
  5. $NEAR ET $WITHIN / / R é s u l

    t a t s t r i é d b . c o l l e c t i o n . f i n d ( { l o c : { $ n e a r : [ 5 0 , 5 0 ] , $ m a x D i s t a n c e : 5 } } ) / / R é s u l t a t s n o n t r i é d b . c o l l e c t i o n . f i n d ( { l o c : { $ w i t h i n : { $ c e n t e r : [ 5 0 , 5 0 ] , 5 ] } } } ) d b . c o l l e c t i o n . f i n d ( { l o c : { $ w i t h i n : { $ b o x : [ [ 4 0 , 5 0 ] , [ 1 0 , 2 0 ] ] } } } ) d b . c o l l e c t i o n . f i n d ( { l o c : { $ w i t h i n : { $ p o l y g o n : [ [ 1 0 , 2 0 ] , [ 1 0 , 4 0 ] , [ 3 0 , 4 0 ] , [ 3 0 , 2 0 ] ] } } } )
  6. LA TERRE EST RONDE L es di s t a

    nces s ont a l or s en r a di a ns d b . c o l l e c t i o n . f i n d ( { l o c : { $ n e a r S p h e r e : [ 0 , 0 ] } } ) d b . c o l l e c t i o n . f i n d ( { l o c : { $ w i t h i n : { $ c e n t e r S p h e r e : { [ 0 , 0 ] , 1 0 } } } } )
  7. AVANTAGES O ut of t he box Sha r di

    ng M ul t i - l oca t i on