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

Geolocalização + E-Commerce

Geolocalização + E-Commerce

Apresentação sobre geolocalização realizada no iMasters DevCommerce 2016

63c59020e0d7efaef816653c853ecc05?s=128

Alexandre Gaigalas

June 08, 2016
Tweet

More Decks by Alexandre Gaigalas

Other Decks in Technology

Transcript

  1. Geolocalização + E-Commerce

  2. Alexandre Gaigalas

  3. Alexandre Gaigalas Iterador de CRUD Avançado

  4. None
  5. Powered by: PHP, MongoDB, MySQL, Redis, Kafka, ActiveMQ, Memcache, Amazon,

    Docker, etc.
  6. None
  7. Encontrando Veículos

  8. None
  9. None
  10. <?php $mongo->my_db->command([ 'geoNear' => 'my_collection', 'near' => [ -46.6579243, -23.5640367

    ], 'maxDistance' => '1' / 6378.1, 'spherical' => true, 'distanceMultiplier' => 6378.1 ]);
  11. <?php $mongo->my_db->ensureIndex([ 'location' => '2d' ]);

  12. None
  13. Tem um jeito melhor?

  14. None
  15. None
  16. Distâncias são relativas

  17. None
  18. None
  19. Easy Share: Compartilhamento de Corridas

  20. None
  21. None
  22. Lembra no colégio...

  23. None
  24. { "type": "MultiPolygon", "coordinates": [ [ [ [-109.25, 36.285596], [-109.27,

    40.962013], [-109.35, 36.285596] ], [ [-59.35, 36.285596], [-59.45, 40.962013], [-59.55, 36.285596] ] ] ] }
  25. <?php $mongo->my_db->ensureIndex([ 'location' => '2dsphere' ]);

  26. None
  27. None
  28. Multi-Pontos e Multi-Polígonos

  29. { "type": "MultiPoint", "coordinates": [ [-105.01621, 39.57422], [-80.6665134, 35.0539943] ]

    }
  30. $mongo->my_db->my_collection->find([ 'location' => [ '$geoWithin' => [ '$geometry' => [

    'type' => 'MultiPolygon', 'coordinates' => [ [ [ [-109.25, 36.285596], [-109.27, 40.962013], [-109.35, 36.285596] ], [ [-59.35, 36.285596], [-59.45, 40.962013], [-59.55, 36.285596] ] ] ] ] ] ] ]);
  31. Invertendo tudo...

  32. <?php $mongo->my_db->my_collection->find([ '$and' => [ [ 'location' => [ '$geoIntersects'

    => [ '$geometry' => $pointA ] ] ], [ 'location' => [ '$geoIntersects' => [ '$geometry' => $pointB ] ] ] ] ]);
  33. Obrigado!

  34. Perguntas?