Grid-based caching for map radius searches, and the edge cases at the poles and antimeridian
A business-campaign tool needs to load local places into its database for each customer's search area, and reloading for every request would be wasteful. The solution treats half-degree grid cells, rather than the circle itself, as the unit of work, so overlapping requests share cached data under common keys. Latitude conversion is straightforward, but longitude distance shrinks toward the poles, so the code scales by the cosine of latitude and caps the stretch to avoid division blow-ups near the pole. Whole countries are stored as a single area with a shared key and a bounding box, with a country-code filter to exclude places that fall outside the border. Missing cells are then grouped into two-degree blocks so that imports run in fewer batches.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in