Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Geolocalização + E-Commerce
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Alexandre Gaigalas
June 08, 2016
Technology
2
150
Geolocalização + E-Commerce
Apresentação sobre geolocalização realizada no iMasters DevCommerce 2016
Alexandre Gaigalas
June 08, 2016
Tweet
Share
More Decks by Alexandre Gaigalas
See All by Alexandre Gaigalas
Passos em Direção à Glória do REST
alganet
0
540
Porrada no Wordpress!
alganet
2
440
Microframeworks vs. Frameworks
alganet
4
360
Dados!
alganet
2
310
Domine Validação de Dados em 45min
alganet
6
480
Criação de Software para Durar
alganet
4
540
REST in PaaS
alganet
6
1.2k
Linked Data e Web Semântica
alganet
1
500
Armazenamento de Dados para Web Semântica
alganet
4
400
Other Decks in Technology
See All in Technology
品質を経営にどう語るか #jassttokyo / Communicating the Strategic Value of Quality to Executive Leadership
kyonmm
PRO
2
480
スクリプトの先へ!AIエージェントと組み合わせる モバイルE2Eテスト
error96num
0
180
AI実装による「レビューボトルネック」を解消する仕様駆動開発(SDD)/ ai-sdd-review-bottleneck
rakus_dev
0
150
AI駆動AI普及活動 ~ 社内AI活用の「何から始めれば?」をAIで突破する
oracle4engineer
PRO
1
110
システム標準化PMOから ガバメントクラウドCoEへ
techniczna
1
130
ガバメントクラウドにおけるAWSの長期継続割引について
takeda_h
2
5.2k
Sansanでの認証基盤内製化と移行
sansantech
PRO
0
560
決済サービスを支えるElastic Cloud - Elastic Cloudの導入と推進、決済サービスのObservability
suzukij
2
660
2026年もソフトウェアサプライチェーンのリスクに立ち向かうために / Product Security Square #3
flatt_security
1
640
"作る"から"使われる"へ:Backstage 活用の現在地
sbtechnight
0
180
AlloyDB 奮闘記
hatappi
0
150
PMとしての意思決定とAI活用状況について
lycorptech_jp
PRO
0
140
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
150
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
860
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
340
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.4k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
290
Become a Pro
speakerdeck
PRO
31
5.8k
What's in a price? How to price your products and services
michaelherold
247
13k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
490
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
180
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
Transcript
Geolocalização + E-Commerce
Alexandre Gaigalas
Alexandre Gaigalas Iterador de CRUD Avançado
None
Powered by: PHP, MongoDB, MySQL, Redis, Kafka, ActiveMQ, Memcache, Amazon,
Docker, etc.
None
Encontrando Veículos
None
None
<?php $mongo->my_db->command([ 'geoNear' => 'my_collection', 'near' => [ -46.6579243, -23.5640367
], 'maxDistance' => '1' / 6378.1, 'spherical' => true, 'distanceMultiplier' => 6378.1 ]);
<?php $mongo->my_db->ensureIndex([ 'location' => '2d' ]);
None
Tem um jeito melhor?
None
None
Distâncias são relativas
None
None
Easy Share: Compartilhamento de Corridas
None
None
Lembra no colégio...
None
{ "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] ] ] ] }
<?php $mongo->my_db->ensureIndex([ 'location' => '2dsphere' ]);
None
None
Multi-Pontos e Multi-Polígonos
{ "type": "MultiPoint", "coordinates": [ [-105.01621, 39.57422], [-80.6665134, 35.0539943] ]
}
$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] ] ] ] ] ] ] ]);
Invertendo tudo...
<?php $mongo->my_db->my_collection->find([ '$and' => [ [ 'location' => [ '$geoIntersects'
=> [ '$geometry' => $pointA ] ] ], [ 'location' => [ '$geoIntersects' => [ '$geometry' => $pointB ] ] ] ] ]);
Obrigado!
Perguntas?