davidmoten/geo — pull request #14 by niqueco (2014-12-11 02:07:54+00:00)
Title: Faster coverBoundingBox() by using longs as geohashes internally

Hi, I have another patch =)

By internally representing hashes as longs I could make coverBoundingBox() faster. In my laptop I could speeed that function from 5.8 µs to 2.6 µs (123 % faster). (In an Android app times are significantly higher, of course)

The long representation I use for geohashes is directly tied to the algorithm and it's incompatible with the representation used in Base32.

This representation is: Starting from the most significant bits I use each 5-bit group as each geohash character and I use the remaining 4 least significant bits to encode the hash length. That allows for hashes upto 12 characters (because 12 * 5 + 4 = 64). I think this representation is also well suited to dababases, as the ordering is the same as the string values.

I had to add a CoverageLongs class, but it's not public (it could be at some point, I think).

Thanks!