def fetch(): road_data1 = load_model2road('./road/center.txt') road_data = load_model2road('./road_2/center.txt') for road in road_data: if main_road(road.name): road_data1.append(road) save_road2model('./road/center_.txt', road_data1)
def into_test(): road_data = load_model2road('./road_main/center1.txt') test_data = [] for road in road_data: if road.rid == 671: test_data.append(road) save_road2model('./road_test/center1.txt', test_data)
def save(): ret_list = [] data_list1 = load_oracle_road() data_list2 = load_double_road() ret_list.extend(data_list1) ret_list.extend(data_list2) # data1 = load_double_road() save_road2model('../road_test/center.txt', ret_list)
def center_mark(): road_data = load_model2road('./road_new/center1.txt') # minx, maxx, miny, maxy = 1e10, 0, 1e10, 0 for road in road_data: xylist = road.point_list grid_set = set() for pt in xylist: grid_set.add(grid(pt.px, pt.py)) road.set_grid_set(grid_set) save_road2model('./road_new/center1.txt', road_data)
def center_8(): """ delete roads :return: """ road_data = load_model2road('./road_new/center1.txt') save_data = [] for road in road_data: if road.rid != 730 and road.rid != 706 and road.rid != 1197: save_data.append(road) save_road2model('./road_new/center1.txt', save_data)
def par_mark(): road_data = load_model2road('./road_new/par.txt') # minx, maxx, miny, maxy = 1e10, 0, 1e10, 0 for road in road_data: par_simplify(road) xylist = road.point_list grid_set = set() for pt in xylist: grid_set.add(grid(pt.px, pt.py)) road.set_grid_set(extend_grid(grid_set)) save_road2model('./road_new/par.txt', road_data)
def center1(): """ split into small segments """ center_road = load_model2road('./road/center1.txt') new_center_road = [] for road in center_road: new_center_road.extend(center_split3(road)) for i, road in enumerate(new_center_road): road.set_rid(i) save_road2model('./road/center_1.txt', new_center_road)
def center_4(): """ 合并道路 :return: """ road_data = load_model2road('./road/center0.txt') link = {u'登云路': u'古翠路'} for road0 in road_data: for road1 in road_data: name0, name1 = road0.name, road1.name if name0 in link.keys() and name1 == link[name0]: print name0, name1 center_one_merge(road0, road1) save_road2model('./road/center.txt', road_data)
def center_7(): """ 连接两条center :return: """ road_data = load_model2road('./road_new/center1.txt') for road in road_data: if road.rid == 4439: br0 = road elif road.rid == 4698: er0 = road pt = copy(er0.point_list[0]) br0.point_list.append(pt) save_road2model('./road_new/center2.txt', road_data)
def par1(): """ 切路口 :return: """ road_data = load_model2road('./road/par0.txt') for i, road0 in enumerate(road_data): for j, road1 in enumerate(road_data): if i < j and road0.name != road1.name and road_near(road0, road1): par_cross(road0, road1) # 切掉路口那段 for road in road_data: par_cut(road) save_road2model('./road/par1.txt', road_data)
def center2(): """ 中心线最后分隔 :return: """ center_road = load_model2road('./road/center1.txt') new_center_road = center_road[:] center_road = [] for road in new_center_road: center_road.append(center_simplify(road)) new_center_road = [] for road in center_road: new_center_road.extend(center_split3(road)) # rid for i, road in enumerate(new_center_road): road.set_rid(i) save_road2model('./road/center2.txt', new_center_road)
def par0(): """ 对平行线的优化, 组成可以使用的路网 :return: """ road_data = load_model2road_by_grid('./road/par.txt', 740) for i, road0 in enumerate(road_data): for j, road1 in enumerate(road_data): if i < j and road_near(road0, road1): par_divide(road0, road1) print "par_divide 0" # 偏移终点起点的路口 for i, road0 in enumerate(road_data): for j, road1 in enumerate(road_data): if road0.name == road1.name or not road_near(road0, road1): continue par_offset(road0, road1) print "par offset" for road in road_data: par_simplify(road) # 再做divide前需要清空 for road in road_data: road.cross_list = [] for i, road0 in enumerate(road_data): for j, road1 in enumerate(road_data): if road0.name == road1.name: continue if i < j and road_near(road0, road1): par_divide(road0, road1) for road in road_data: par_insert_cross(road) for road in road_data: par_check(road) save_road2model('./road/par0.txt', road_data) print "par0"
def par0(): """ 对平行线的优化, 组成可以使用的路网 :return: """ road_data = load_model2road('./road_main/par.txt') # for i, road0 in enumerate(road_data): # for j, road1 in enumerate(road_data): # if i < j: # par_divide(road0, road1) # print "par_divide 0" # # 偏移终点起点的路口 # for i, road0 in enumerate(road_data): # for j, road1 in enumerate(road_data): # if road0.name == road1.name: # continue # par_offset(road0, road1) # print "par offset" for road in road_data: par_simplify(road) # 再做divide前需要清空 for road in road_data: road.cross_list = [] for i, road0 in enumerate(road_data): for j, road1 in enumerate(road_data): if road0.name == road1.name: continue if i < j: par_divide(road0, road1) for road in road_data: par_insert_cross(road) for road in road_data: par_check(road) save_road2model('./road_main/par0.txt', road_data) print "par0"
def check(): road_data = load_model2road('./road_new/center.txt') for road in road_data: center_dup(road) save_road2model('./road_new/center1.txt', road_data)
def center0(): """ 中心线的优化,切分 :return: """ center_road = load_model2road('./road/center.txt') # 合并平行连接的道路 for i, road0 in enumerate(center_road): for j, road1 in enumerate(center_road): if j < i: center_merge(road0, road1) # 交叉点 for i, road0 in enumerate(center_road): for j, road1 in enumerate(center_road): if i != j and road_near(road0, road1): try: center_cross(road0, road1) except ZeroDivisionError: print road0.name, road1.name # 预防多插点 for road in center_road: center_dup(road) for i, road0 in enumerate(center_road): for j, road1 in enumerate(center_road): if j < i and road_near(road0, road1): try: center_divide(road0, road1) except ZeroDivisionError: print road0.name, road1.name print "divide 1" # 端点落到道路 for i, road0 in enumerate(center_road): for j, road1 in enumerate(center_road): if i != j and road_near(road0, road1): center_offset(road0, road1) print "center offset" for road in center_road: center_simplify(road) save_road2model('./road/center0.txt', center_road) # 为防止精度不必要的损失,在一个程序内完成 for road in center_road: road.cross_list = [] for i, road0 in enumerate(center_road): for j, road1 in enumerate(center_road): if i < j and road_near(road0, road1): center_divide(road0, road1) print "divide 2" for road in center_road: center_insert_cross(road) save_road2model('./road/center01.txt', center_road) new_center_road = [] for road in center_road: new_center_road.extend(center_split(road)) for i, road in enumerate(new_center_road): road.set_rid(i) save_road2model('./road/center1.txt', new_center_road)