Benjamin Peterson | 206e307 | 2008-10-19 14:07:49 +0000 | [diff] [blame] | 1 | |
| 2 | import webbrowser |
Raymond Hettinger | b1614a7 | 2009-06-03 17:21:17 +0000 | [diff] [blame] | 3 | import hashlib |
Benjamin Peterson | 206e307 | 2008-10-19 14:07:49 +0000 | [diff] [blame] | 4 | |
Christian Heimes | a4961e5 | 2016-09-16 13:48:10 +0200 | [diff] [blame] | 5 | webbrowser.open("https://xkcd.com/353/") |
Raymond Hettinger | b1614a7 | 2009-06-03 17:21:17 +0000 | [diff] [blame] | 6 | |
| 7 | def geohash(latitude, longitude, datedow): |
| 8 | '''Compute geohash() using the Munroe algorithm. |
| 9 | |
| 10 | >>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68') |
| 11 | 37.857713 -122.544543 |
| 12 | |
| 13 | ''' |
觉 | 83df50e | 2018-09-14 13:45:00 +0800 | [diff] [blame] | 14 | # https://xkcd.com/426/ |
Raymond Hettinger | b1614a7 | 2009-06-03 17:21:17 +0000 | [diff] [blame] | 15 | h = hashlib.md5(datedow).hexdigest() |
| 16 | p, q = [('%f' % float.fromhex('0.' + x)) for x in (h[:16], h[16:32])] |
| 17 | print('%d%s %d%s' % (latitude, p[1:], longitude, q[1:])) |