There are 249 countries with an iso code; so 8 bits might be enough. So it's not that bad. But even at 32 bits it would probably be fine and you could cram in some more data.
There are many similar things of course but nothing that was multiplatform, which I needed. I actually created a multiplatform kotlin library for working with language and country codes a few months ago: https://github.com/jillesvangurp/ko-iso
It seems we have some shared interests. I'll check out your library.
What you describe is nice strategy for indexing things. I've done some similar things. Another library (jillesvangurp/geogeometry) I maintain allows you to figure out which map tiles cover a polygon cover a polygon. Map tiles are nice because they are basically quad tree paths. I have a similar algorithm that does that with geohashes. You could use both for indexing geospatial stuff.
Slicing up the polygons sounds interesting. I've been meaning to have a go at intersect/union type operations on geometries. I added a boolean intersects recently to check whether geometries intersect each other. I already had containment check.
> There are 249 countries with an iso code; so 8 bits might be enough.
There are 249 ISO 3166-1 country codes:
* https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
But 193 sovereign states recognized by the UN:
* https://en.wikipedia.org/wiki/Member_states_of_the_United_Na...
Some of the discrepancy can be accounted for by "legacy" codes like .su for the Soviet Union.