topologicpy 0.5.5__py3-none-any.whl → 0.5.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
topologicpy/Graph.py CHANGED
@@ -541,11 +541,6 @@ class Graph:
541
541
  floorLevels =[],
542
542
  labelKey="label",
543
543
  typeKey="type",
544
- sourceKey="source",
545
- targetKey="target",
546
- xKey = "x",
547
- yKey = "y",
548
- zKey = "z",
549
544
  spaceType = "space",
550
545
  wallType = "wall",
551
546
  slabType = "slab",
@@ -578,33 +573,23 @@ class Graph:
578
573
  The desired prefixed to use for each building storey. The default is "Storey".
579
574
  floorLevels : list , optional
580
575
  The list of floor levels. This should be a numeric list, sorted from lowest to highest.
581
- If not provided, floorLevels will be computed automatically based on the nodes' 'z' attribute.
576
+ If not provided, floorLevels will be computed automatically based on the vertices' 'z' attribute.
582
577
  typeKey : str , optional
583
578
  The dictionary key to use to look up the type of the node. The default is "type".
584
579
  labelKey : str , optional
585
580
  The dictionary key to use to look up the label of the node. The default is "label".
586
- sourceKey : str , optional
587
- The desired dictionary key to use to store the source vertex. The default is "source".
588
- targetKey : str , optional
589
- The desired dictionary key to use to store the target vertex. The default is "target".
590
- xKey : str , optional
591
- The dictionary key to use to look up the x-coordinate of the node. The default is "x".
592
- yKey : str , optional
593
- The dictionary key to use to look up the y-coordinate of the node. The default is "y".
594
- zKey : str , optional
595
- The dictionary key to use to look up the z-coordinate of the node. The default is "z".
596
581
  spaceType : str , optional
597
- The dictionary string value to use to look up nodes of type "space". The default is "space".
582
+ The dictionary string value to use to look up vertices of type "space". The default is "space".
598
583
  wallType : str , optional
599
- The dictionary string value to use to look up nodes of type "wall". The default is "wall".
584
+ The dictionary string value to use to look up vertices of type "wall". The default is "wall".
600
585
  slabType : str , optional
601
- The dictionary string value to use to look up nodes of type "slab". The default is "slab".
586
+ The dictionary string value to use to look up vertices of type "slab". The default is "slab".
602
587
  doorType : str , optional
603
- The dictionary string value to use to look up nodes of type "door". The default is "door".
588
+ The dictionary string value to use to look up vertices of type "door". The default is "door".
604
589
  windowType : str , optional
605
- The dictionary string value to use to look up nodes of type "window". The default is "window".
590
+ The dictionary string value to use to look up vertices of type "window". The default is "window".
606
591
  contentType : str , optional
607
- The dictionary string value to use to look up nodes of type "content". The default is "contents".
592
+ The dictionary string value to use to look up vertices of type "content". The default is "contents".
608
593
 
609
594
  Returns
610
595
  -------
@@ -639,7 +624,7 @@ class Graph:
639
624
  floorLevels = []
640
625
  json_data = Graph.JSONData(graph, vertexLabelKey=labelKey)
641
626
  # Create an empty RDF graph
642
- rdf_graph = RDFGraph()
627
+ bot_graph = RDFGraph()
643
628
 
644
629
  # Define namespaces
645
630
  rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
@@ -647,127 +632,121 @@ class Graph:
647
632
  bot = Namespace("https://w3id.org/bot#")
648
633
 
649
634
  # Define a custom prefix mapping
650
- rdf_graph.namespace_manager.bind("bot", bot)
635
+ bot_graph.namespace_manager.bind("bot", bot)
651
636
 
652
637
  # Add site
653
638
  site_uri = URIRef(siteLabel)
654
- rdf_graph.add((site_uri, rdf.type, bot.Site))
639
+ bot_graph.add((site_uri, rdf.type, bot.Site))
655
640
  if includeLabel:
656
- rdf_graph.add((site_uri, RDFS.label, Literal("Site_0001")))
641
+ bot_graph.add((site_uri, RDFS.label, Literal(siteLabel)))
657
642
  if isinstance(siteDictionary, topologic.Dictionary):
658
643
  keys = Dictionary.Keys(siteDictionary)
659
644
  for key in keys:
660
645
  value = Dictionary.ValueAtKey(siteDictionary, key)
661
- if key == labelKey:
662
- if includeLabel:
663
- rdf_graph.add((site_uri, RDFS.label, Literal(value)))
664
- elif key != typeKey:
665
- rdf_graph.add((site_uri, bot[key], Literal(value)))
646
+ if not (key == labelKey) and not (key == typeKey):
647
+ bot_graph.add((site_uri, bot[key], Literal(value)))
666
648
  # Add building
667
649
  building_uri = URIRef(buildingLabel)
668
- rdf_graph.add((building_uri, rdf.type, bot.Building))
650
+ bot_graph.add((building_uri, rdf.type, bot.Building))
669
651
  if includeLabel:
670
- rdf_graph.add((building_uri, RDFS.label, Literal(buildingLabel)))
652
+ bot_graph.add((building_uri, RDFS.label, Literal(buildingLabel)))
671
653
  if isinstance(buildingDictionary, topologic.Dictionary):
672
654
  keys = Dictionary.Keys(buildingDictionary)
673
655
  for key in keys:
674
656
  value = Dictionary.ValueAtKey(buildingDictionary, key)
675
657
  if key == labelKey:
676
658
  if includeLabel:
677
- rdf_graph.add((building_uri, RDFS.label, Literal(value)))
659
+ bot_graph.add((building_uri, RDFS.label, Literal(value)))
678
660
  elif key != typeKey:
679
- rdf_graph.add((building_uri, bot[key], Literal(value)))
661
+ bot_graph.add((building_uri, bot[key], Literal(value)))
680
662
  # Add stories
681
663
  # if floor levels are not given, then need to be computed
682
664
  if len(floorLevels) == 0:
683
- for node, attributes in json_data['nodes'].items():
665
+ for node, attributes in json_data['vertices'].items():
684
666
  if slabType.lower() in attributes[typeKey].lower():
685
- floorLevels.append(attributes[zKey])
667
+ floorLevels.append(attributes["z"])
686
668
  floorLevels = list(set(floorLevels))
687
669
  floorLevels.sort()
670
+ floorLevels = floorLevels[:-1]
688
671
  storey_uris = []
689
672
  n = max(len(str(len(floorLevels))),4)
690
673
  for i, floor_level in enumerate(floorLevels):
691
674
  storey_uri = URIRef(storeyPrefix+"_"+str(i+1).zfill(n))
692
- rdf_graph.add((storey_uri, rdf.type, bot.Storey))
675
+ bot_graph.add((storey_uri, rdf.type, bot.Storey))
693
676
  if includeLabel:
694
- rdf_graph.add((storey_uri, RDFS.label, Literal(storeyPrefix+"_"+str(i+1).zfill(n))))
677
+ bot_graph.add((storey_uri, RDFS.label, Literal(storeyPrefix+"_"+str(i+1).zfill(n))))
695
678
  storey_uris.append(storey_uri)
696
679
 
697
680
  # Add triples to relate building to site and stories to building
698
- rdf_graph.add((site_uri, bot.hasBuilding, building_uri))
681
+ bot_graph.add((site_uri, bot.hasBuilding, building_uri))
699
682
  if bidirectional:
700
- rdf_graph.add((building_uri, bot.isPartOf, site_uri)) # might not be needed
683
+ bot_graph.add((building_uri, bot.isPartOf, site_uri)) # might not be needed
701
684
 
702
685
  for storey_uri in storey_uris:
703
- rdf_graph.add((building_uri, bot.hasStorey, storey_uri))
686
+ bot_graph.add((building_uri, bot.hasStorey, storey_uri))
704
687
  if bidirectional:
705
- rdf_graph.add((storey_uri, bot.isPartOf, building_uri)) # might not be needed
688
+ bot_graph.add((storey_uri, bot.isPartOf, building_uri)) # might not be needed
706
689
 
707
690
  # Add vertices as RDF resources
708
- for node, attributes in json_data['nodes'].items():
691
+ for node, attributes in json_data['vertices'].items():
709
692
  node_uri = URIRef(node)
710
693
  if spaceType.lower() in attributes[typeKey].lower():
711
- rdf_graph.add((node_uri, rdf.type, bot.Space))
694
+ bot_graph.add((node_uri, rdf.type, bot.Space))
712
695
  # Find the storey it is on
713
- z = attributes[zKey]
696
+ z = attributes["z"]
714
697
  level = Helper.Position(z, floorLevels)
715
698
  if level > len(storey_uris):
716
699
  level = len(storey_uris)
717
700
  storey_uri = storey_uris[level-1]
718
- rdf_graph.add((storey_uri, bot.hasSpace, node_uri))
701
+ bot_graph.add((storey_uri, bot.hasSpace, node_uri))
719
702
  if bidirectional:
720
- rdf_graph.add((node_uri, bot.isPartOf, storey_uri)) # might not be needed
703
+ bot_graph.add((node_uri, bot.isPartOf, storey_uri)) # might not be needed
721
704
  elif windowType.lower() in attributes[typeKey].lower():
722
- rdf_graph.add((node_uri, rdf.type, bot.Window))
705
+ bot_graph.add((node_uri, rdf.type, bot.Window))
723
706
  elif doorType.lower() in attributes[typeKey].lower():
724
- rdf_graph.add((node_uri, rdf.type, bot.Door))
707
+ bot_graph.add((node_uri, rdf.type, bot.Door))
725
708
  elif wallType.lower() in attributes[typeKey].lower():
726
- rdf_graph.add((node_uri, rdf.type, bot.Wall))
709
+ bot_graph.add((node_uri, rdf.type, bot.Wall))
727
710
  elif slabType.lower() in attributes[typeKey].lower():
728
- rdf_graph.add((node_uri, rdf.type, bot.Slab))
711
+ bot_graph.add((node_uri, rdf.type, bot.Slab))
729
712
  else:
730
- rdf_graph.add((node_uri, rdf.type, bot.Element))
713
+ bot_graph.add((node_uri, rdf.type, bot.Element))
731
714
 
732
715
  if includeAttributes:
733
716
  for key, value in attributes.items():
734
717
  if key == labelKey:
735
718
  if includeLabel:
736
- rdf_graph.add((node_uri, RDFS.label, Literal(value)))
719
+ bot_graph.add((node_uri, RDFS.label, Literal(value)))
737
720
  elif key != typeKey:
738
- rdf_graph.add((node_uri, bot[key], Literal(value)))
721
+ bot_graph.add((node_uri, bot[key], Literal(value)))
739
722
  if includeLabel:
740
723
  for key, value in attributes.items():
741
724
  if key == labelKey:
742
- rdf_graph.add((node_uri, RDFS.label, Literal(value)))
725
+ bot_graph.add((node_uri, RDFS.label, Literal(value)))
743
726
 
744
727
  # Add edges as RDF triples
745
728
  for edge, attributes in json_data['edges'].items():
746
- source = attributes[sourceKey]
747
- target = attributes[targetKey]
729
+ source = attributes["source"]
730
+ target = attributes["target"]
748
731
  source_uri = URIRef(source)
749
732
  target_uri = URIRef(target)
750
- if spaceType.lower() in json_data['nodes'][source][typeKey].lower() and spaceType.lower() in json_data['nodes'][target][typeKey].lower():
751
- rdf_graph.add((source_uri, bot.adjacentTo, target_uri))
733
+ if spaceType.lower() in json_data['vertices'][source][typeKey].lower() and spaceType.lower() in json_data['vertices'][target][typeKey].lower():
734
+ bot_graph.add((source_uri, bot.adjacentTo, target_uri))
752
735
  if bidirectional:
753
- rdf_graph.add((target_uri, bot.adjacentTo, source_uri))
754
- elif spaceType.lower() in json_data['nodes'][source][typeKey].lower() and wallType.lower() in json_data['nodes'][target][typeKey].lower():
755
- rdf_graph.add((target_uri, bot.interfaceOf, source_uri))
756
- elif spaceType.lower() in json_data['nodes'][source][typeKey].lower() and slabType.lower() in json_data['nodes'][target][typeKey].lower():
757
- rdf_graph.add((target_uri, bot.interfaceOf, source_uri))
758
- elif spaceType.lower() in json_data['nodes'][source][typeKey].lower() and contentType.lower() in json_data['nodes'][target][typeKey].lower():
759
- rdf_graph.add((source_uri, bot.containsElement, target_uri))
736
+ bot_graph.add((target_uri, bot.adjacentTo, source_uri))
737
+ elif spaceType.lower() in json_data['vertices'][source][typeKey].lower() and wallType.lower() in json_data['vertices'][target][typeKey].lower():
738
+ bot_graph.add((target_uri, bot.interfaceOf, source_uri))
739
+ elif spaceType.lower() in json_data['vertices'][source][typeKey].lower() and slabType.lower() in json_data['vertices'][target][typeKey].lower():
740
+ bot_graph.add((target_uri, bot.interfaceOf, source_uri))
741
+ elif spaceType.lower() in json_data['vertices'][source][typeKey].lower() and contentType.lower() in json_data['vertices'][target][typeKey].lower():
742
+ bot_graph.add((source_uri, bot.containsElement, target_uri))
760
743
  if bidirectional:
761
- rdf_graph.add((target_uri, bot.isPartOf, source_uri))
744
+ bot_graph.add((target_uri, bot.isPartOf, source_uri))
762
745
  else:
763
- rdf_graph.add((source_uri, bot.connectsTo, target_uri))
746
+ bot_graph.add((source_uri, bot.connectsTo, target_uri))
764
747
  if bidirectional:
765
- rdf_graph.add((target_uri, bot.connectsTo, source_uri))
766
- #for key, value in attributes.items():
767
- #rdf_graph.add((source_uri, bot[key], Literal(value)))
768
- # Return serialized RDF graph
769
- #rdf_serialized = rdf_graph.serialize(format=format)
770
- return rdf_graph
748
+ bot_graph.add((target_uri, bot.connectsTo, source_uri))
749
+ return bot_graph
771
750
 
772
751
  @staticmethod
773
752
  def BOTString(graph,
@@ -783,11 +762,6 @@ class Graph:
783
762
  floorLevels =[],
784
763
  labelKey="label",
785
764
  typeKey="type",
786
- sourceKey="source",
787
- targetKey="target",
788
- xKey = "x",
789
- yKey = "y",
790
- zKey = "z",
791
765
  spaceType = "space",
792
766
  wallType = "wall",
793
767
  slabType = "slab",
@@ -831,33 +805,23 @@ class Graph:
831
805
  The desired prefixed to use for each building storey. The default is "Storey".
832
806
  floorLevels : list , optional
833
807
  The list of floor levels. This should be a numeric list, sorted from lowest to highest.
834
- If not provided, floorLevels will be computed automatically based on the nodes' 'z' attribute.
808
+ If not provided, floorLevels will be computed automatically based on the vertices' 'z' attribute.
835
809
  typeKey : str , optional
836
810
  The dictionary key to use to look up the type of the node. The default is "type".
837
811
  labelKey : str , optional
838
812
  The dictionary key to use to look up the label of the node. The default is "label".
839
- sourceKey : str , optional
840
- The desired dictionary key to use to store the source vertex. The default is "source".
841
- targetKey : str , optional
842
- The desired dictionary key to use to store the target vertex. The default is "target".
843
- xKey : str , optional
844
- The dictionary key to use to look up the x-coordinate of the node. The default is "x".
845
- yKey : str , optional
846
- The dictionary key to use to look up the y-coordinate of the node. The default is "y".
847
- zKey : str , optional
848
- The dictionary key to use to look up the z-coordinate of the node. The default is "z".
849
813
  spaceType : str , optional
850
- The dictionary string value to use to look up nodes of type "space". The default is "space".
814
+ The dictionary string value to use to look up vertices of type "space". The default is "space".
851
815
  wallType : str , optional
852
- The dictionary string value to use to look up nodes of type "wall". The default is "wall".
816
+ The dictionary string value to use to look up vertices of type "wall". The default is "wall".
853
817
  slabType : str , optional
854
- The dictionary string value to use to look up nodes of type "slab". The default is "slab".
818
+ The dictionary string value to use to look up vertices of type "slab". The default is "slab".
855
819
  doorType : str , optional
856
- The dictionary string value to use to look up nodes of type "door". The default is "door".
820
+ The dictionary string value to use to look up vertices of type "door". The default is "door".
857
821
  windowType : str , optional
858
- The dictionary string value to use to look up nodes of type "window". The default is "window".
822
+ The dictionary string value to use to look up vertices of type "window". The default is "window".
859
823
  contentType : str , optional
860
- The dictionary string value to use to look up nodes of type "content". The default is "contents".
824
+ The dictionary string value to use to look up vertices of type "content". The default is "contents".
861
825
 
862
826
 
863
827
  Returns
@@ -878,11 +842,6 @@ class Graph:
878
842
  floorLevels=floorLevels,
879
843
  labelKey=labelKey,
880
844
  typeKey=typeKey,
881
- sourceKey=sourceKey,
882
- targetKey=targetKey,
883
- xKey=xKey,
884
- yKey=yKey,
885
- zKey=zKey,
886
845
  spaceType = spaceType,
887
846
  wallType = wallType,
888
847
  slabType = slabType,
@@ -4112,9 +4071,6 @@ class Graph:
4112
4071
  typeKey="type",
4113
4072
  sourceKey="source",
4114
4073
  targetKey="target",
4115
- xKey = "x",
4116
- yKey = "y",
4117
- zKey = "z",
4118
4074
  spaceType = "space",
4119
4075
  wallType = "wall",
4120
4076
  slabType = "slab",
@@ -4167,16 +4123,6 @@ class Graph:
4167
4123
  The dictionary key to use to look up the type of the node. The default is "type".
4168
4124
  labelKey : str , optional
4169
4125
  The dictionary key to use to look up the label of the node. The default is "label".
4170
- sourceKey : str , optional
4171
- The desired dictionary key to use to store the source vertex. The default is "source".
4172
- targetKey : str , optional
4173
- The desired dictionary key to use to store the target vertex. The default is "target".
4174
- xKey : str , optional
4175
- The dictionary key to use to look up the x-coordinate of the node. The default is "x".
4176
- yKey : str , optional
4177
- The dictionary key to use to look up the y-coordinate of the node. The default is "y".
4178
- zKey : str , optional
4179
- The dictionary key to use to look up the z-coordinate of the node. The default is "z".
4180
4126
  spaceType : str , optional
4181
4127
  The dictionary string value to use to look up nodes of type "space". The default is "space".
4182
4128
  wallType : str , optional
@@ -4218,11 +4164,6 @@ class Graph:
4218
4164
  floorLevels=floorLevels,
4219
4165
  labelKey=labelKey,
4220
4166
  typeKey=typeKey,
4221
- sourceKey=sourceKey,
4222
- targetKey=targetKey,
4223
- xKey=xKey,
4224
- yKey=yKey,
4225
- zKey=zKey,
4226
4167
  spaceType = spaceType,
4227
4168
  wallType = wallType,
4228
4169
  slabType = slabType,
@@ -4975,7 +4916,7 @@ class Graph:
4975
4916
  return True
4976
4917
 
4977
4918
  @staticmethod
4978
- def ExportToJSON(graph, path, vertexLabelKey="", edgeLabelKey="", indent=4, sortKeys=False, mantissa=6, overwrite=False):
4919
+ def ExportToJSON(graph, path, verticesKey="vertices", edgesKey="edges", vertexLabelKey="", edgeLabelKey="", xKey="x", yKey="y", zKey="z", indent=4, sortKeys=False, mantissa=6, overwrite=False):
4979
4920
  """
4980
4921
  Exports the input graph to a JSON file.
4981
4922
 
@@ -4985,12 +4926,22 @@ class Graph:
4985
4926
  The input graph.
4986
4927
  path : str
4987
4928
  The path to the JSON file.
4929
+ verticesKey : str , optional
4930
+ The desired key name to call vertices. The default is "vertices".
4931
+ edgesKey : str , optional
4932
+ The desired key name to call edges. The default is "edges".
4988
4933
  vertexLabelKey : str , optional
4989
4934
  If set to a valid string, the vertex label will be set to the value at this key. Otherwise it will be set to Vertex_XXXX where XXXX is a sequential unique number.
4990
4935
  Note: If vertex labels are not unique, they will be forced to be unique.
4991
4936
  edgeLabelKey : str , optional
4992
4937
  If set to a valid string, the edge label will be set to the value at this key. Otherwise it will be set to Edge_XXXX where XXXX is a sequential unique number.
4993
4938
  Note: If edge labels are not unique, they will be forced to be unique.
4939
+ xKey : str , optional
4940
+ The desired key name to use for x-coordinates. The default is "x".
4941
+ yKey : str , optional
4942
+ The desired key name to use for y-coordinates. The default is "y".
4943
+ zKey : str , optional
4944
+ The desired key name to use for z-coordinates. The default is "z".
4994
4945
  indent : int , optional
4995
4946
  The desired amount of indent spaces to use. The default is 4.
4996
4947
  sortKeys : bool , optional
@@ -5024,7 +4975,7 @@ class Graph:
5024
4975
  except:
5025
4976
  raise Exception("Graph.ExportToJSON - Error: Could not create a new file at the following location: "+path)
5026
4977
  if (f):
5027
- jsondata = Graph.JSONData(graph, vertexLabelKey=vertexLabelKey, edgeLabelKey=edgeLabelKey, mantissa=mantissa)
4978
+ jsondata = Graph.JSONData(graph, verticesKey=verticesKey, edgesKey=edgesKey, vertexLabelKey=vertexLabelKey, edgeLabelKey=edgeLabelKey, xKey=xKey, yKey=yKey, zKey=zKey, mantissa=mantissa)
5028
4979
  if jsondata != None:
5029
4980
  json.dump(jsondata, f, indent=indent, sort_keys=sortKeys)
5030
4981
  f.close()
@@ -5679,7 +5630,17 @@ class Graph:
5679
5630
  return vertices
5680
5631
 
5681
5632
  @staticmethod
5682
- def JSONData(graph, vertexLabelKey="", edgeLabelKey="", sourceKey="source", targetKey="target", mantissa=6):
5633
+ def JSONData(graph,
5634
+ verticesKey="vertices",
5635
+ edgesKey="edges",
5636
+ vertexLabelKey="",
5637
+ edgeLabelKey="",
5638
+ sourceKey="source",
5639
+ targetKey="target",
5640
+ xKey="x",
5641
+ yKey="y",
5642
+ zKey="z",
5643
+ mantissa=6):
5683
5644
  """
5684
5645
  Converts the input graph into JSON data.
5685
5646
 
@@ -5687,6 +5648,10 @@ class Graph:
5687
5648
  ----------
5688
5649
  graph : topologic.Graph
5689
5650
  The input graph.
5651
+ verticesKey : str , optional
5652
+ The desired key name to call vertices. The default is "vertices".
5653
+ edgesKey : str , optional
5654
+ The desired key name to call edges. The default is "edges".
5690
5655
  vertexLabelKey : str , optional
5691
5656
  If set to a valid string, the vertex label will be set to the value at this key. Otherwise it will be set to Vertex_XXXX where XXXX is a sequential unique number.
5692
5657
  Note: If vertex labels are not unique, they will be forced to be unique.
@@ -5697,6 +5662,12 @@ class Graph:
5697
5662
  The dictionary key used to store the source vertex. The default is "source".
5698
5663
  targetKey : str , optional
5699
5664
  The dictionary key used to store the target vertex. The default is "source".
5665
+ xKey : str , optional
5666
+ The desired key name to use for x-coordinates. The default is "x".
5667
+ yKey : str , optional
5668
+ The desired key name to use for y-coordinates. The default is "y".
5669
+ zKey : str , optional
5670
+ The desired key name to use for z-coordinates. The default is "z".
5700
5671
  mantissa : int , optional
5701
5672
  The desired length of the mantissa. The default is 6.
5702
5673
 
@@ -5714,16 +5685,16 @@ class Graph:
5714
5685
 
5715
5686
  vertices = Graph.Vertices(graph)
5716
5687
  j_data = {}
5717
- j_data['nodes'] = {}
5718
- j_data['edges'] = {}
5688
+ j_data[verticesKey] = {}
5689
+ j_data[edgesKey] = {}
5719
5690
  n = max(len(str(len(vertices))), 4)
5720
5691
  v_labels = []
5721
5692
  v_dicts = []
5722
5693
  for i, v in enumerate(vertices):
5723
5694
  d = Topology.Dictionary(v)
5724
- d = Dictionary.SetValueAtKey(d, "x", Vertex.X(v, mantissa=mantissa))
5725
- d = Dictionary.SetValueAtKey(d, "y", Vertex.Y(v, mantissa=mantissa))
5726
- d = Dictionary.SetValueAtKey(d, "z", Vertex.Z(v, mantissa=mantissa))
5695
+ d = Dictionary.SetValueAtKey(d, xKey, Vertex.X(v, mantissa=mantissa))
5696
+ d = Dictionary.SetValueAtKey(d, yKey, Vertex.Y(v, mantissa=mantissa))
5697
+ d = Dictionary.SetValueAtKey(d, zKey, Vertex.Z(v, mantissa=mantissa))
5727
5698
  v_dict = Dictionary.PythonDictionary(d)
5728
5699
  v_label = Dictionary.ValueAtKey(d, vertexLabelKey)
5729
5700
  if isinstance(v_label, str):
@@ -5734,7 +5705,7 @@ class Graph:
5734
5705
  v_dicts.append(v_dict)
5735
5706
  v_labels = Helper.MakeUnique(v_labels)
5736
5707
  for i, v_label in enumerate(v_labels):
5737
- j_data['nodes'][v_label] = v_dicts[i]
5708
+ j_data[verticesKey][v_label] = v_dicts[i]
5738
5709
 
5739
5710
  edges = Graph.Edges(graph)
5740
5711
  n = len(str(len(edges)))
@@ -5761,12 +5732,22 @@ class Graph:
5761
5732
  e_dicts.append(e_dict)
5762
5733
  e_labels = Helper.MakeUnique(e_labels)
5763
5734
  for i, e_label in enumerate(e_labels):
5764
- j_data['edges'][e_label] = e_dicts[i]
5735
+ j_data[edgesKey][e_label] = e_dicts[i]
5765
5736
 
5766
5737
  return j_data
5767
5738
 
5768
5739
  @staticmethod
5769
- def JSONString(graph, vertexLabelKey="", edgeLabelKey="", indent=4, sortKeys=False, mantissa=6):
5740
+ def JSONString(graph,
5741
+ verticesKey="vertices",
5742
+ edgesKey="edges",
5743
+ vertexLabelKey="",
5744
+ edgeLabelKey="",
5745
+ xKey = "x",
5746
+ yKey = "y",
5747
+ zKey = "z",
5748
+ indent=4,
5749
+ sortKeys=False,
5750
+ mantissa=6):
5770
5751
  """
5771
5752
  Converts the input graph into JSON data.
5772
5753
 
@@ -5774,12 +5755,22 @@ class Graph:
5774
5755
  ----------
5775
5756
  graph : topologic.Graph
5776
5757
  The input graph.
5758
+ verticesKey : str , optional
5759
+ The desired key name to call vertices. The default is "vertices".
5760
+ edgesKey : str , optional
5761
+ The desired key name to call edges. The default is "edges".
5777
5762
  vertexLabelKey : str , optional
5778
5763
  If set to a valid string, the vertex label will be set to the value at this key. Otherwise it will be set to Vertex_XXXX where XXXX is a sequential unique number.
5779
5764
  Note: If vertex labels are not unique, they will be forced to be unique.
5780
5765
  edgeLabelKey : str , optional
5781
5766
  If set to a valid string, the edge label will be set to the value at this key. Otherwise it will be set to Edge_XXXX where XXXX is a sequential unique number.
5782
5767
  Note: If edge labels are not unique, they will be forced to be unique.
5768
+ xKey : str , optional
5769
+ The desired key name to use for x-coordinates. The default is "x".
5770
+ yKey : str , optional
5771
+ The desired key name to use for y-coordinates. The default is "y".
5772
+ zKey : str , optional
5773
+ The desired key name to use for z-coordinates. The default is "z".
5783
5774
  indent : int , optional
5784
5775
  The desired amount of indent spaces to use. The default is 4.
5785
5776
  sortKeys : bool , optional
@@ -5794,7 +5785,7 @@ class Graph:
5794
5785
 
5795
5786
  """
5796
5787
  import json
5797
- json_data = Graph.JSONData(graph, vertexLabelKey=vertexLabelKey, edgeLabelKey=edgeLabelKey, mantissa=mantissa)
5788
+ json_data = Graph.JSONData(graph, verticesKey=verticesKey, edgesKey=edgesKey, vertexLabelKey=vertexLabelKey, edgeLabelKey=edgeLabelKey, xKey=xKey, yKey=yKey, zKey=zKey, mantissa=mantissa)
5798
5789
  json_string = json.dumps(json_data, indent=indent, sort_keys=sortKeys)
5799
5790
  return json_string
5800
5791
 
topologicpy/__init__.py CHANGED
@@ -18,7 +18,7 @@ import sys
18
18
  import os, re
19
19
  from sys import platform
20
20
 
21
- __version__ = '0.5.5'
21
+ __version__ = '0.5.6'
22
22
  __version_info__ = tuple([ int(num) for num in __version__.split('.')])
23
23
 
24
24
  if platform == 'win32':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: topologicpy
3
- Version: 0.5.5
3
+ Version: 0.5.6
4
4
  Summary: An Advanced Spatial Modelling and Analysis Software Library for Architecture, Engineering, and Construction.
5
5
  Author-email: Wassim Jabi <wassim.jabi@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/wassimj/TopologicPy
@@ -27,6 +27,7 @@ Requires-Dist: plotly
27
27
  Requires-Dist: pyvis
28
28
  Requires-Dist: lark
29
29
  Requires-Dist: webcolors
30
+ Requires-Dist: rdflib
30
31
 
31
32
  # topologicpy
32
33
 
@@ -9,7 +9,7 @@ topologicpy/Dictionary.py,sha256=vGhiXPu7e7GsgQyTsX6rZBncnnrDlcYfM9xRb9h-l3U,247
9
9
  topologicpy/Edge.py,sha256=ZWR2icdFd7dMe8v-RPLAvg1C29hFFsMDBDlp85hluQk,50261
10
10
  topologicpy/EnergyModel.py,sha256=VPWkMP2uhJORiVqEomb2Dlx5VgKcVUbqnZBZX1IpF_Y,51771
11
11
  topologicpy/Face.py,sha256=H1D232WC410G4IeZ7NJS0pmHS1ASnuTQaQqjV84-UlI,90509
12
- topologicpy/Graph.py,sha256=XLpbHTOZ-_8XA7hVyOHPG8qpWALHIw1Y1qZMX7jpa4Q,360306
12
+ topologicpy/Graph.py,sha256=CPODfbTli_vsZnTQTg5Jl9keuPijontjBCzEBSf-f9c,359645
13
13
  topologicpy/Grid.py,sha256=5Wi7nF6axNqhr4WrWk1c1fb7nftG02-BzxTYneeGr88,17389
14
14
  topologicpy/Helper.py,sha256=dsMU4BAt6zKsYG-YiT_OE4kX2rq3dtl3AqMMd35-6DA,18250
15
15
  topologicpy/Honeybee.py,sha256=p5OZi8tGPxUNH91_8peChEkYJdg5vpRyeqHVz8S9OS0,20356
@@ -23,7 +23,7 @@ topologicpy/Topology.py,sha256=WbQJbDx966YzbwujFoapnccRCkZvWUtQCP4GvS8gacQ,30619
23
23
  topologicpy/Vector.py,sha256=3GayjTGJDhg6yuchN86yHWUV9hTyu-kp_HaWuBXu6fc,30476
24
24
  topologicpy/Vertex.py,sha256=Te0RmdRQba1I21FcrAqlbJblUzJ07Xk44FKJiNtlgkw,66492
25
25
  topologicpy/Wire.py,sha256=bD8uhOzsH6_NWgDtGtW84PNKWscsVOpmbYul9k8ShfU,131871
26
- topologicpy/__init__.py,sha256=qtnnVqxIDx_8rLgf89Tudvfgt_hXTDALrAPAgdzWpqs,1444
26
+ topologicpy/__init__.py,sha256=2KUp5ucRuCUEOySyMek-SaQ3QUrSADNEEQXUbkKQjZY,1444
27
27
  topologicpy/bin/linux/topologic/__init__.py,sha256=XlFReDf3FWlYdM9uXtanYPIafgPb6GVTQczS_xJAXD0,60
28
28
  topologicpy/bin/linux/topologic/libTKBO-6bdf205d.so.7.7.0,sha256=ANok9DQKcnWcLd9T_LAt-i-X4nsYYy16q9kQlcTre1E,2996488
29
29
  topologicpy/bin/linux/topologic/libTKBRep-2960a069.so.7.7.0,sha256=OJ3XesL79du8LeBHrsleGPXub6OpJdOilxha0mwjqQo,1378768
@@ -84,8 +84,8 @@ topologicpy/bin/windows/topologic/topologic.cp310-win_amd64.pyd,sha256=F0sPLuMpD
84
84
  topologicpy/bin/windows/topologic/topologic.cp311-win_amd64.pyd,sha256=aBAJQj3OmJ58MOAF1ZIFybL_5fFK7FNR9hrIps6b6pc,1551872
85
85
  topologicpy/bin/windows/topologic/topologic.cp38-win_amd64.pyd,sha256=aLgNf54nbJmGc7Tdmkuy-V0m6B9zLxabIbpRwAy7cBA,1551360
86
86
  topologicpy/bin/windows/topologic/topologic.cp39-win_amd64.pyd,sha256=_8cp205hiRxkFHtzQQOweA4DhCPk8caH4kTVLWGQeVw,1411584
87
- topologicpy-0.5.5.dist-info/LICENSE,sha256=RUmXeeqj63bBySLJjEfhwb9OE7M8h9K6HuOBF3ASVyI,35697
88
- topologicpy-0.5.5.dist-info/METADATA,sha256=Zg-lNeE1SElPUOV9zgzMRJtzE2vQPYbhZUigOM__VZE,7283
89
- topologicpy-0.5.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
90
- topologicpy-0.5.5.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
91
- topologicpy-0.5.5.dist-info/RECORD,,
87
+ topologicpy-0.5.6.dist-info/LICENSE,sha256=RUmXeeqj63bBySLJjEfhwb9OE7M8h9K6HuOBF3ASVyI,35697
88
+ topologicpy-0.5.6.dist-info/METADATA,sha256=vLO1U1dmObzRag-UAlRFpReaaBtLOUnhse1uiL5H3Vo,7306
89
+ topologicpy-0.5.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
90
+ topologicpy-0.5.6.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
91
+ topologicpy-0.5.6.dist-info/RECORD,,