|
@@ -1,4 +1,4 @@
|
|
|
-
|
|
|
+import json
|
|
|
|
|
|
def check_grid_upright(model_list, grid_data_dict):
|
|
|
grid_data_dict = dict(grid_data_dict)
|
|
@@ -7,12 +7,13 @@ def check_grid_upright(model_list, grid_data_dict):
|
|
|
for model_id, all_grid in grid_data_dict.items():
|
|
|
name_dict = dict()
|
|
|
for data_row in all_grid:
|
|
|
- name_dict[data_row.get('name')] = data_row.get('location')
|
|
|
+ name_dict[data_row.get('name')] = str(data_row.get('location')).replace('\'', '"')
|
|
|
+ # name_dict[data_row.get('name')] = data_row.get('location')
|
|
|
calc_dict[model_id] = name_dict
|
|
|
for model_id, name_location_dict in calc_dict.items():
|
|
|
# 判断并插入分组
|
|
|
insert_group(group, model_id, calc_dict)
|
|
|
- print(group)
|
|
|
+ # print(group)
|
|
|
index = 0
|
|
|
group_dict = dict()
|
|
|
for model_id_list in group:
|
|
@@ -21,10 +22,14 @@ def check_grid_upright(model_list, grid_data_dict):
|
|
|
group_dict[tmp_model_id] = index
|
|
|
for floor in model_list:
|
|
|
if floor.get('fid') in group_dict:
|
|
|
- floor['group'] = group_dict.get(floor.get('fid'))
|
|
|
- print(model_list)
|
|
|
+ floor['group_id'] = group_dict.get(floor.get('fid'))
|
|
|
+ else:
|
|
|
+ floor['group_id'] = 0
|
|
|
+ # print(model_list)
|
|
|
return True
|
|
|
|
|
|
+# def process_location(grids):
|
|
|
+# for name, location in grids.items()
|
|
|
|
|
|
def insert_group(group, model_id, calc_dict):
|
|
|
# 如果第一次往group里添加元素, 直接添加
|
|
@@ -54,12 +59,19 @@ def insert_group(group, model_id, calc_dict):
|
|
|
# 返回False是没冲突, True是有冲突
|
|
|
def has_conflict(base, compare):
|
|
|
for name, location in base.items():
|
|
|
+ if isinstance(location, str):
|
|
|
+ location = json.loads(location)
|
|
|
+ base[name] = location
|
|
|
if name in compare:
|
|
|
type1 = location.get('Type')
|
|
|
- type2 = compare.get(name).get('Type')
|
|
|
+ location2 = compare.get(name)
|
|
|
+ if isinstance(location2, str):
|
|
|
+ location2 = json.loads(location2)
|
|
|
+ compare[name] = location2
|
|
|
+ type2 = location2.get('Type')
|
|
|
if type1 in type2:
|
|
|
if 'Line' in type1:
|
|
|
- if not is_same_line(location.get('Points'), compare.get(name).get('Points')):
|
|
|
+ if not is_same_line(location.get('Points'), location2.get('Points')):
|
|
|
return True
|
|
|
else:
|
|
|
return True
|