|
@@ -6,35 +6,27 @@ import psycopg2
|
|
|
from shapely.geometry import Polygon
|
|
|
import sys
|
|
|
|
|
|
+from src.affected_space.affected_space import get_affected_spaced
|
|
|
from src.grid.check_grid import check_grid_upright
|
|
|
|
|
|
-involved_space = [
|
|
|
- 'id',
|
|
|
- 'floor_name',
|
|
|
- 'project_id',
|
|
|
- 'folder_id',
|
|
|
- 'fid',
|
|
|
- 'accept_time',
|
|
|
- 'version',
|
|
|
- 'note',
|
|
|
- 'user_id',
|
|
|
- 'user_name',
|
|
|
- 'log',
|
|
|
- 'url',
|
|
|
- 'md5',
|
|
|
- 'status'
|
|
|
+space_keys = [
|
|
|
+ 'floor_id',
|
|
|
+ 'space_id',
|
|
|
+ 'outline'
|
|
|
]
|
|
|
|
|
|
-grid_keys = [
|
|
|
- 'id',
|
|
|
- 'model_id',
|
|
|
- 'name',
|
|
|
- 'type',
|
|
|
- 'last_update',
|
|
|
- 'create_time',
|
|
|
+model_keys = [
|
|
|
+ 'id'
|
|
|
+]
|
|
|
+
|
|
|
+floor_keys = [
|
|
|
+ 'current_model_id',
|
|
|
+ 'bind_floor_ids'
|
|
|
+]
|
|
|
+
|
|
|
+ispace_keys = [
|
|
|
'revit_id',
|
|
|
- 'source_id',
|
|
|
- 'location',
|
|
|
+ 'outline'
|
|
|
]
|
|
|
|
|
|
|
|
@@ -71,21 +63,82 @@ def loads_curve(x):
|
|
|
x['curve'] = json.loads(x['curve'])
|
|
|
return x
|
|
|
|
|
|
+def transform_outline(obj):
|
|
|
+ column_outline = 'outline'
|
|
|
+ for space in obj:
|
|
|
+ outline = space.get(column_outline)
|
|
|
+ print(type(outline))
|
|
|
+ outline_str = str(outline).replace('\'', '"')
|
|
|
+ space[column_outline] = outline_str
|
|
|
+
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
- points1 = [(0, 0), (0, 1), (1, 1), (1, 0)]
|
|
|
- points2 = [(0, 0), (0.00, 0.5), (0, 1), (1, 1), (1, 0)]
|
|
|
- poly1 = Polygon(points1)
|
|
|
- poly2 = Polygon(points2)
|
|
|
+ # points1 = [(0, 0), (0, 1), (1, 1), (1, 0)]
|
|
|
+ # points2 = [(0, 0), (0.00, 0.5), (0, 1), (1, 1), (1, 0)]
|
|
|
+ # poly1 = Polygon(points1)
|
|
|
+ # poly2 = Polygon(points2)
|
|
|
+ #
|
|
|
+ # print(poly1.equals(poly2))
|
|
|
+ # print(poly1.almost_equals(poly2, 0.99))
|
|
|
+ # print(poly1.almost_equals(poly2, 0))
|
|
|
+ # print(poly1.almost_equals(poly2, -10))
|
|
|
+ # print(poly1.almost_equals(poly2, 2))
|
|
|
+ # print(poly1.almost_equals(poly2, 0.0001))
|
|
|
+
|
|
|
+ floor_str = "SELECT current_model_id, bind_floor_ids FROM revit.model_floor where id = '7893fe0c6cd511ea83548fd73aa29e85'"
|
|
|
+
|
|
|
+ floor_data = get_data(floor_str)
|
|
|
+
|
|
|
+ floor_list = [dict(zip(floor_keys, item)) for item in floor_data]
|
|
|
+
|
|
|
+ if len(floor_list) == 0:
|
|
|
+ print("no floor")
|
|
|
+ sys.exit(0)
|
|
|
+ print(type(floor_list[0]['bind_floor_ids']))
|
|
|
+ strs = str(floor_list[0]['bind_floor_ids']).replace('\'', '"')
|
|
|
+ print(strs)
|
|
|
+ floor_arr = json.loads(strs)
|
|
|
+ if len(floor_arr) == 0:
|
|
|
+ print("no binding floor")
|
|
|
+ sys.exit(0)
|
|
|
+ floor_str = ""
|
|
|
+ for fl in floor_arr:
|
|
|
+ floor_str = (floor_str + "'" + fl + "',")
|
|
|
+ floor_str = floor_str.strip(',')
|
|
|
+ model_str = "select id from revit.model_file where model_floor_id = '7893fe0c6cd511ea83548fd73aa29e85' and removed = false and status = 4 and version is not null order by version desc limit 2"
|
|
|
+ model_data = get_data(model_str)
|
|
|
+ model_list = [dict(zip(model_keys, item)) for item in model_data]
|
|
|
+
|
|
|
+ if len(model_list) != 2 :
|
|
|
+ print("no prev model")
|
|
|
+ sys.exit(0)
|
|
|
+
|
|
|
+ space_str = "select rel.floor_id, rel.space_id, sp.outline from r_sp_in_fl rel left join zone_space_base sp on rel.space_id = sp.id where rel.floor_id in (" + floor_str + ")"
|
|
|
+ space_data = get_data(space_str)
|
|
|
+ space_list = [dict(zip(space_keys, item)) for item in space_data]
|
|
|
+
|
|
|
+ if len(space_list) == 0:
|
|
|
+ print("no space")
|
|
|
+ sys.exit(0)
|
|
|
+
|
|
|
+ new_ispace_str = "select revit_id, outline from revit.space where model_id = '{0}'".format(model_list[0]['id'])
|
|
|
+ prev_ispace_str = "select revit_id, outline from revit.space where model_id = '" + model_list[1]['id'] + "'"
|
|
|
+
|
|
|
+ new_ispace_data = get_data(new_ispace_str)
|
|
|
+ prev_ispace_data = get_data(prev_ispace_str)
|
|
|
+
|
|
|
+ new_ispace_list = [dict(zip(ispace_keys, item)) for item in new_ispace_data]
|
|
|
+ prev_ispace_list = [dict(zip(ispace_keys, item)) for item in prev_ispace_data]
|
|
|
+
|
|
|
+
|
|
|
+ transform_outline(space_list)
|
|
|
+ transform_outline(new_ispace_list)
|
|
|
+ transform_outline(prev_ispace_list)
|
|
|
|
|
|
- print(poly1.equals(poly2))
|
|
|
- print(poly1.almost_equals(poly2, 0.99))
|
|
|
- print(poly1.almost_equals(poly2, 0))
|
|
|
- print(poly1.almost_equals(poly2, -10))
|
|
|
- print(poly1.almost_equals(poly2, 2))
|
|
|
- print(poly1.almost_equals(poly2, 0.0001))
|
|
|
|
|
|
+ affected_space_ids = get_affected_spaced(space_list, new_ispace_list, prev_ispace_list)
|
|
|
|
|
|
+ print(affected_space_ids)
|
|
|
|
|
|
# involved_space = "select * from where folder_id = " \
|
|
|
# "'bbe510dbe26011e999b69b669ea08505' and status in (3, 31, 4) "
|