Location, Location, Location...
Or how to provide the illusion of having mapped every entertainment venue in the world.
As part of my recent work on CueCam, I was asked to incorporate location metadata in the recorded images and videos. An expectation of any camera app these days, and mimicing the native iPhone Camera experience.
What's in a name?
But then I thought about how we use this data. You don't bring a show into 55.864995777, -4.268400519, you brought it to the Kings Theatre.
If I want to find photos from a tour, it would be so much more helpful to be able to search for the venue than try and find it in a map view.
So what I basically need is a lookup ... from GPS to "nearest venue", something that seems easy enough, but needs to scale. And needs to work globally.

Redis GEOSEARCH
My go-to for such tasks is Redis, it's crazily fast and easy to use. All you need is a database and a simple query will return all venues within 2 miles;
GEOSEARCH venues FROMLONLAT 55.864995777 -4.268400519 BYRADIUS 2 MI ASC WITHDIST
So, now all I need is a Redis dataset with every venue in the world in it!
Our little island
The UK is small, by most definitions, and it was easy enough to just populate this with every venue in the UK. I used the excellent Overpass Turbo to run a query with a box drawn around the UK. The final version adds a few more amenity types and some filters, but this gets us most of them.
[out:json][timeout:600];nwr["amenity"~"^(theatre|arts_centre|community_centre|events_venue)$"]({{bbox}});out center;
Now we've got about 21,000 buildings around the UK and 1,600 or so theatres in the 2Mb database and it works exactly as expected.
Anywhere in the UK, it should identify the venue you're in.
The world is a bit bigger...
But this isn't a UK app, and even my beta test community spans parts of the USA, Canada, Europe, Australia, and New Zealand. So a database of UK theatres isn't much use for the rest of them.
Likewise, it's simply not practical to try and map every venue in the world.
So, we turn to a system pioneered by Gustavo Niemeyer, the GeoHash which divides the entire planet up into simple rectangles and, significantly, allows us to easily find adjacent rectangles.
If we get a request for an area that we have no data for, we translate this to a Geohash, retrieve the data for that Geohash, and then also queue requests for many of the surrounding blocks.
This allows the database to remain small, but evolve as the application grows to include more and more venues close to where people are using CueCam. Of course, you can always enter your own location directly.
The Edinburgh Festival Fringe
The Edinburgh Festival Fringe is the world's largest arts festival, with around 4000 shows across almost 300 venues. We manually added all of these venues to the CueCam database so we could make CueCam free to use at the Edinburgh Fringe!