DEV Community

Cover image for The Hexagonal Code: How Uber Finds You Fast!
Sanket Kalekar
Sanket Kalekar

Posted on

The Hexagonal Code: How Uber Finds You Fast!

Have you ever wondered how Uber magically finds a driver near you within seconds of booking a ride?πŸ€”

where my night 2AM brain cells are decoding this after some of research i got this:

So suppose this is you🧍and these are the drivers around you

Image description

Uber uses a thing called hexagonal index So what it does is it divides the entire map into hexagons So you are in a hexagon So it will search in all the hexagons that are near you to see if it finds a driver or not

Image description

Now it is possible that you are covering a lot of area and we have to find more drivers nearby So what it does is it breaks these hexagons into smaller hexagons so that it will be able to find very close drivers,

Image description

So simply you can imagine how it will be suppose we first looked at the big hexagons to see how many are there around you this is how it works.

but still in confuse why hexagons why not did we use triangles and squares?

Image description

if you look at one hexagon, the adjacent hexagon the distance will be equidistant if you look at it from the center but this doesn't happen in a square or triangle now how are these hexagons stored?

Top comments (0)