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:

alt tag

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?

Geometry geometry = ...
DiscretizerFactory factory = new DiscretizerFactoryImpl();
Set<GeoHash> geoHashes = factory.discretizer(geometry).apply(geometry, 7);