Back to index

python3.2  3.2.2
Functions
antigravity Namespace Reference

Functions

def geohash

Function Documentation

def antigravity.geohash (   latitude,
  longitude,
  datedow 
)
Compute geohash() using the Munroe algorithm.

>>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68')
37.857713 -122.544543

Definition at line 7 of file antigravity.py.

00007 
00008 def geohash(latitude, longitude, datedow):
00009     '''Compute geohash() using the Munroe algorithm.
00010 
00011     >>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68')
00012     37.857713 -122.544543
00013 
00014     '''
00015     # http://xkcd.com/426/
00016     h = hashlib.md5(datedow).hexdigest()
00017     p, q = [('%f' % float.fromhex('0.' + x)) for x in (h[:16], h[16:32])]
00018     print('%d%s %d%s' % (latitude, p[1:], longitude, q[1:]))