A world of hashes ... geo-hashes
The jts-discretizer is a tiny Java 8 library able to convert JTS geometries to a set of GeoHashes with arbitrary precision (<12).
A GeoHash-based Mallorca discretization looks like:
The smallest geo-hashes are of length 7. Notice that the resulted geo-hash set is optimized, if all children of a certain geo-hash are present in the original set, the children are replaced with the parent.
How to use it?
<dependency>
<groupId>io.github.adrianulbona</groupId>
<artifactId>jts-discretizer</artifactId>
<version>0.1.0</version>
</dependency>
Geometry geometry = ...
DiscretizerFactory factory = new DiscretizerFactoryImpl();
Set<GeoHash> geoHashes = factory.discretizer(geometry).apply(geometry, 7);