Skip to content

Instantly share code, notes, and snippets.

@myok12
Forked from DeaconDesperado/gist:5396884
Created April 17, 2013 12:44
Show Gist options
  • Save myok12/5403937 to your computer and use it in GitHub Desktop.
Save myok12/5403937 to your computer and use it in GitHub Desktop.
coords = (
(41.2863,-73.78689),
(41.2864,-73.78690),
(41.2869,-73.78698),
)
from math import floor
def gen_hash(coords):
pro_lat = floor(coords[0]*1000.0)
pro_lon = floor(coords[1]*1000.0)
mod_lat = pro_lat%4.0
mod_lon = pro_lon%4.0
return 'SERVER_NAME#%s|%s:%s|%s' % (pro_lat,mod_lat,pro_lon,mod_lon)
assert(gen_hash(coords[0])==gen_hash(coords[1]))
assert(gen_hash(coords[0])==gen_hash(coords[2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment