def build_hash_to_coord(paths):
if os.path.exists("comps/mobike/sol_carl/data/h2c.p") and os.path.exists("comps/mobike/sol_carl/data/c2h.p"):
return
h2c,c2h = {},{}
for path in paths:
for c,row in enumerate(csv.DictReader(open(path))):
for tag in ["geohashed_end_loc","geohashed_start_loc"]:
if tag not in row:
continue
h = row[tag]
if h not in h2c:
coord = str_coord(decode(h))
h2c[h] = coord
#lat,lon = int(lat+0.5),int(lon+0.5)
if coord not in c2h:
c2h[coord] = set()
c2h[coord].add(h)
if c>0 and c%100000 == 0:
print(path,c)
print(len(h2c),len(c2h))
pickle.dump(h2c,open("comps/mobike/sol_carl/data/h2c.p","wb"))
pickle.dump(c2h,open("comps/mobike/sol_carl/data/c2h.p","wb"))
评论列表
文章目录