Released cities-db, a database of ~32,000 cities (cities in the world with population > 15,000), compressed into a format suitable for auto-complete on web pages (~283 KB) or mobile apps.
The data is fetched from GeoNames.org, and processed into a custom format.
Why?
This library was created for findstarlink.com. It would be pretty expensive to use the Google Maps API for auto-complete, or host a dedicated API endpoint. And I don’t see why we need a remote service for this.
Bandwidth usage accounts for the majority of FindStarlink’s running costs (even after using a CDN). So it was pretty important to keep this library’s file size as small as possible.
What does this do?
Achieves significant compression through:
- Delta encoding for sorted geohashes
- Delta encoding for region/country IDs
- String tokenization for city/region/country names
- Binary format with minimal overhead
The naive approach is to store the data as an SQLite database, which results in a compressed file size of 1.4 MB (2.55 MB uncompressed). That’s not good for web pages.
This library produces a bundle size of just 283 KB (573 KB uncompressed), by using the methods described above.
This makes it quite useful for transferring over the web - for a fast, fully-local auto-complete dropdown of most of the major cities of the world.