jxing 4 years ago
parent
commit
8d61ed9e67

+ 5 - 2
src/affected_space/affected_space.py

@@ -32,8 +32,11 @@ def is_include(polygon1, poly2):
 def is_sub_outline_overlap(polygon1, polygon2):
     poly1 = get_polygon(polygon1[0])
     poly2 = get_polygon(polygon2[0])
-    if poly1.overlaps(poly2) or poly1.equals(poly2):
-        return True
+    try:
+        if poly1.overlaps(poly2) or poly1.equals(poly2):
+            return True
+    except Exception as e:
+        return False
     if poly1.contains(poly2) or poly1.equals(poly2):
         return is_include(polygon1, poly2)
     if poly2.contains(poly1) or poly2.equals(poly1):

File diff suppressed because it is too large
+ 80 - 0
src/affected_space/draw_polygon.py


+ 5 - 4
src/affected_space/test.py

@@ -32,8 +32,10 @@ def get_data(sql):
         connection = psycopg2.connect(
             database='datacenter',
             user='postgres',
-            password='123456',
-            host='192.168.20.234',
+            # password='123456',
+            password='123qwe!@#',
+            # host='192.168.20.234',
+            host='47.94.89.44',
             port='5432'
         )
         cursor = connection.cursor()
@@ -62,7 +64,6 @@ 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
 
@@ -79,7 +80,7 @@ if __name__ == '__main__':
     # print(poly1.almost_equals(poly2, -10))
     # print(poly1.almost_equals(poly2, 2))
     # print(poly1.almost_equals(poly2, 0.0001))
-    floor_id = '7893fe0c6cd511ea83548fd73aa29e85'
+    floor_id = '16900f297e2911ea88f503a5b7a176d7'
     floor_str = "SELECT id FROM public.floor where model_id = '{0}'".format(floor_id)
 
     floor_data = get_data(floor_str)