Explorar o código

modify data format

chenhaiyang %!s(int64=5) %!d(string=hai) anos
pai
achega
7757a56130

+ 2 - 0
.idea/.gitignore

@@ -0,0 +1,2 @@
+# Default ignored files
+/workspace.xml

+ 7 - 0
.idea/dictionaries/highing.xml

@@ -0,0 +1,7 @@
+<component name="ProjectDictionaryState">
+  <dictionary name="highing">
+    <words>
+      <w>revit</w>
+    </words>
+  </dictionary>
+</component>

+ 6 - 0
.idea/inspectionProfiles/profiles_settings.xml

@@ -0,0 +1,6 @@
+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="USE_PROJECT_PROFILE" value="false" />
+    <version value="1.0" />
+  </settings>
+</component>

+ 7 - 0
.idea/misc.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="JavaScriptSettings">
+    <option name="languageLevel" value="ES6" />
+  </component>
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (fry)" project-jdk-type="Python SDK" />
+</project>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/relations.iml" filepath="$PROJECT_DIR$/.idea/relations.iml" />
+    </modules>
+  </component>
+</project>

+ 11 - 0
.idea/relations.iml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="jdk" jdkName="Python 3.7 (fry)" jdkType="Python SDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+  <component name="TestRunnerService">
+    <option name="PROJECT_TEST_RUNNER" value="Unittests" />
+  </component>
+</module>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 20 - 2
adjacent.py

@@ -7,12 +7,16 @@ from operator import itemgetter
 import numpy as np
 import vg
 
-from utils import BinaryRelationItem, BinaryRelationCollection
+from .utils import BinaryRelationItem, BinaryRelationCollection
 
 np.seterr(divide='ignore', invalid='ignore')
 
 
 def calc_adjacent_relation(columns, segments, v_walls, walls):
+    columns = list(map(load_location, columns))
+    segments = list(map(load_curve, segments))
+    v_walls = list(map(load_location, v_walls))
+    walls = list(map(load_location, walls))
     columns_dic = list_to_dict(columns)
     v_walls_dic = list_to_dict(v_walls)
     walls_dic = list_to_dict(walls)
@@ -36,7 +40,11 @@ def calc_adjacent_relation(columns, segments, v_walls, walls):
                         binary_space_relations = BinaryRelationItem(space1, space2)
                         space_relation.update(binary_space_relations)
 
-    return space_relation
+    relations = []
+    for relation in relations:
+        relations.append(relation)
+
+    return relations
 
 
 def group_segments(segments, units):
@@ -123,3 +131,13 @@ def are_adjacent(segment1, segment2, units):
             return projection1_max > projection2_min and projection2_max > projection1_min
 
     return False
+
+
+def load_location(x):
+    x['location'] = json.loads(x['location'])
+    return x
+
+
+def load_curve(x):
+    x['curve'] = json.loads(x['curve'])
+    return x

+ 1 - 1
test.py

@@ -117,4 +117,4 @@ if __name__ == '__main__':
         columns=columns_data
     )
     for item in test_result:
-        print('SideSpace:', item)
+        print('SideSpace:', item, type(item))