🔥 🔥 🔥 This year starting a new ad-hoc section of the newsletter: Quick Bites which will cover small technical and product topics. Plan is to learn a lot of new things without going significantly deeper into them. If you would like to dive deeper into any of these bites further, feel free to drop me a note! 👇
What is GeoHashing? 🧐
Every location on the earth can be written using latitude and longitude but that becomes extremely large to store these information efficiently. Hence, every geographical address (that includes street address, zip code, etc.) is converted into latitude and longitude ( This process is called geocoding). This geocoded address is then encoded into even shorter form comprising of strings and/or digits using GeoHashing.
Internals of GeoHashing 💫
Geohashing uses what’s called base-32 encoding using alphabets (doesn’t uses the characters ‘A’, ‘I‘, ‘L‘, ‘O‘)
The earth’s surface area is divided into 32 cells where each cell will be further divided into 32 grids and so on. The size of a grid is directly dependent on the number of characters in the hash. For eg: if the factor of 1 is considered, the entire surface area of earth can be divided into 32 grids. Each grid will contain several locations and in order to precisely mark a location, keep increasing the characters in hash. That will help in dividing the grids further and precisely identifying the location.
I found this image that helps in visualizing the geo-hashing in works!
Common Use Cases 🏆
Social Media Applications to find nearby friends/people
Insider Tip 🤫
This is one of the core concepts that gets asked as part of Software Engineering design interviews such as “Design a Yelp” or “Design Uber like service”. Using this concept to formulate the design answer will give a good edge to any candidate.
If you like the post, share and subscribe to the newsletter to stay up to date with tech/product musings.
(The contents of this blog are of my personal opinion and/or self-reading a bunch of articles and in no way influenced by my employer.)