def get_sbwstops(o_lat, o_lng, d_lat, d_lng, dis): #设置最远阈值1000米范围内 o_dmin = [dis, None] d_dmin = [dis, None] ominlat, omaxlat, ominlng, omaxlng = get_area(o_lat, o_lng, dis / 1000) dminlat, dmaxlat, dminlng, dmaxlng = get_area(d_lat, d_lng, dis / 1000) for key in sbwstation: [t_lat, t_lng] = sbwstation[key].get_location() if t_lat > ominlat and t_lat < omaxlat and t_lng > ominlng and t_lng < omaxlng: o_d = get_distance(o_lat, o_lng, sbwstation[key].get_location()[0], sbwstation[key].get_location()[1]) o_dmin = ([o_d, key] if o_d < o_dmin[0] else o_dmin) if t_lat > dminlat and t_lat < dmaxlat and t_lng > dminlng and t_lng < dmaxlng: d_d = get_distance(d_lat, d_lng, sbwstation[key].get_location()[0], sbwstation[key].get_location()[1]) d_dmin = ([d_d, key] if d_d < d_dmin[0] else d_dmin) return o_dmin, d_dmin
lat = sdata[key][k][i]['latitude'] lng = sdata[key][k][i]['longitude'] if lat < 100: location = [lat, lng] else: location = [lng, lat] sline = copy.deepcopy(stopline[name]) ydstation[name] = Station(id, name, location, sline) num += 1 # 站点半径500米内其他站点定义为周边站点【0】,获取周边站点集合并添加到对应站点类中 nearby_stops = {} for i in stop: nearby_stops[i] = [] [c_lat, c_lng] = ydstation[i].get_location() minlat, maxlat, minlng, maxlng = get_area(c_lat, c_lng, 0.5) n_stops = {} for j in stop: [t_lat, t_lng] = ydstation[j].get_location() if t_lat > minlat and t_lat < maxlat and t_lng > minlng and t_lng < maxlng: n_stops[j] = get_distance(c_lat, c_lng, t_lat, t_lng) n_stops.pop(i) nearby_stops[i] = copy.deepcopy(n_stops) for key in ydstation: stopsdict = {0: copy.deepcopy(nearby_stops[key])} ydstation[key].set_stops(stopsdict) # DICT SBWSTATION # 将获取到的地铁json站点数据整理成站点类的形式,存在key为地铁站点id,value为站点类的字典中 sbwstation = {} for i in range(len(sbw_sdata)):