def getseeds(datapoint,radius,theta):
chosen = []; seeds = [];
# random.shuffle(datapoint)
periodsampl = 500000
for p in datapoint:
chosen.append(p);
for j,p in enumerate(chosen):
ok = -1;
if j<periodsampl:
for q in seeds:
if taxidist(p,q,theta)<radius:
ok = 1
break;
if ok <1:
seeds.append(p)
else:
if j%periodsampl == 0:# and (is_power2(int(j/1000))):
# print(j,time.time()-start)
S = [(lonconst * xx[0], latconst * xx[1], theta / 180 * (xx[2]+45)) for xx in seeds];
nbrs = NearestNeighbors(n_neighbors=1, algorithm='ball_tree').fit(S)
X = [(lonconst * xx[0], latconst * xx[1], theta / 180 * (xx[2]+45)) for xx in chosen[j:min(len(chosen),j+periodsampl)]];
distances, indices = nbrs.kneighbors(X)
if distances[j%periodsampl][0] >radius:
seeds.append(p)
print('seeds: ', len(seeds))
return (seeds)
评论列表
文章目录