topologicpy 0.7.5__py3-none-any.whl → 0.7.8__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
@@ -62,8 +62,6 @@ except:
62
62
  except:
63
63
  warnings.warn("Graph - Error: Could not import tqdm.")
64
64
 
65
-
66
-
67
65
  class _Tree:
68
66
  def __init__(self, node="", *children):
69
67
  self.node = node
@@ -94,7 +92,6 @@ class _Tree:
94
92
  return len(self.children)
95
93
 
96
94
 
97
-
98
95
  class _DrawTree(object):
99
96
  def __init__(self, tree, parent=None, depth=0, number=1):
100
97
  self.x = -1.0
@@ -539,25 +536,35 @@ class Graph:
539
536
 
540
537
  @staticmethod
541
538
  def BOTGraph(graph,
542
- bidirectional=False,
543
- includeAttributes=False,
544
- includeLabel=False,
545
- includeGeometry=False,
546
- siteLabel = "Site_0001",
547
- siteDictionary = None,
548
- buildingLabel = "Building_0001",
549
- buildingDictionary = None ,
550
- storeyPrefix = "Storey",
551
- floorLevels =[],
552
- labelKey="label",
553
- typeKey="type",
554
- geometryKey="brep",
555
- spaceType = "space",
556
- wallType = "wall",
557
- slabType = "slab",
558
- doorType = "door",
559
- windowType = "window",
560
- contentType = "content"
539
+ bidirectional: bool = False,
540
+ includeAttributes: bool = False,
541
+ includeLabel: bool = False,
542
+ includeGeometry: bool = False,
543
+ siteLabel: str = "Site_0001",
544
+ siteDictionary: dict = None,
545
+ buildingLabel: str = "Building_0001",
546
+ buildingDictionary: dict = None ,
547
+ storeyPrefix: str = "Storey",
548
+ floorLevels: list = [],
549
+ vertexLabelKey: str = "label",
550
+ typeKey: str = "type",
551
+ verticesKey: str = "vertices",
552
+ edgesKey: str = "edges",
553
+ edgeLabelKey: str = "",
554
+ sourceKey: str = "source",
555
+ targetKey: str = "target",
556
+ xKey: str = "hasX",
557
+ yKey: str = "hasY",
558
+ zKey: str = "hasZ",
559
+ geometryKey: str = "brep",
560
+ spaceType: str = "space",
561
+ wallType: str = "wall",
562
+ slabType: str = "slab",
563
+ doorType: str = "door",
564
+ windowType: str = "window",
565
+ contentType: str = "content",
566
+ namespace: str = "http://github.com/wassimj/topologicpy/resources",
567
+ mantissa: int = 6
561
568
  ):
562
569
  """
563
570
  Creates an RDF graph according to the BOT ontology. See https://w3c-lbd-cg.github.io/bot/.
@@ -586,9 +593,29 @@ class Graph:
586
593
  The desired prefixed to use for each building storey. The default is "Storey".
587
594
  floorLevels : list , optional
588
595
  The list of floor levels. This should be a numeric list, sorted from lowest to highest.
589
- If not provided, floorLevels will be computed automatically based on the vertices' 'z' attribute.
590
- labelKey : str , optional
591
- The dictionary key to use to look up the label of the node. The default is "label".
596
+ If not provided, floorLevels will be computed automatically based on the vertices' (zKey)) attribute. See below.
597
+ verticesKey : str , optional
598
+ The desired key name to call vertices. The default is "vertices".
599
+ edgesKey : str , optional
600
+ The desired key name to call edges. The default is "edges".
601
+ vertexLabelKey : str , optional
602
+ 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.
603
+ Note: If vertex labels are not unique, they will be forced to be unique.
604
+ edgeLabelKey : str , optional
605
+ 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.
606
+ Note: If edge labels are not unique, they will be forced to be unique.
607
+ sourceKey : str , optional
608
+ The dictionary key used to store the source vertex. The default is "source".
609
+ targetKey : str , optional
610
+ The dictionary key used to store the target vertex. The default is "target".
611
+ xKey : str , optional
612
+ The desired key name to use for x-coordinates. The default is "hasX".
613
+ yKey : str , optional
614
+ The desired key name to use for y-coordinates. The default is "hasY".
615
+ zKey : str , optional
616
+ The desired key name to use for z-coordinates. The default is "hasZ".
617
+ geometryKey : str , optional
618
+ The desired key name to use for geometry. The default is "brep".
592
619
  typeKey : str , optional
593
620
  The dictionary key to use to look up the type of the node. The default is "type".
594
621
  geometryKey : str , optional
@@ -605,7 +632,12 @@ class Graph:
605
632
  The dictionary string value to use to look up vertices of type "window". The default is "window".
606
633
  contentType : str , optional
607
634
  The dictionary string value to use to look up vertices of type "content". The default is "contents".
635
+ namespace : str , optional
636
+ The desired namespace to use in the BOT graph. The default is "http://github.com/wassimj/topologicpy/resources".
637
+ mantissa : int , optional
638
+ The desired length of the mantissa. The default is 6.
608
639
 
640
+
609
641
  Returns
610
642
  -------
611
643
  rdflib.graph.Graph
@@ -621,7 +653,7 @@ class Graph:
621
653
  try:
622
654
  from rdflib import Graph as RDFGraph
623
655
  from rdflib import URIRef, Literal, Namespace
624
- from rdflib.namespace import RDF, RDFS
656
+ from rdflib.namespace import RDF, RDFS, XSD
625
657
  except:
626
658
  print("Graph.BOTGraph - Information: Installing required rdflib library.")
627
659
  try:
@@ -639,16 +671,32 @@ class Graph:
639
671
 
640
672
  if floorLevels == None:
641
673
  floorLevels = []
642
- json_data = Graph.JSONData(graph, vertexLabelKey=labelKey)
674
+
675
+ json_data = Graph.JSONData(graph,
676
+ verticesKey=verticesKey,
677
+ edgesKey=edgesKey,
678
+ vertexLabelKey=vertexLabelKey,
679
+ edgeLabelKey=edgeLabelKey,
680
+ sourceKey=sourceKey,
681
+ targetKey=targetKey,
682
+ xKey=xKey,
683
+ yKey=yKey,
684
+ zKey=zKey,
685
+ geometryKey=geometryKey,
686
+ mantissa=mantissa)
687
+
643
688
  # Create an empty RDF graph
644
689
  bot_graph = RDFGraph()
645
690
 
646
691
  # Define namespaces
647
692
  rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
648
693
  bot = Namespace("https://w3id.org/bot#")
694
+ top = Namespace(namespace)
649
695
 
650
696
  # Define a custom prefix mapping
651
697
  bot_graph.namespace_manager.bind("bot", bot)
698
+ bot_graph.namespace_manager.bind("xsd", XSD)
699
+ bot_graph.namespace_manager.bind("top", top)
652
700
 
653
701
  # Add site
654
702
  site_uri = URIRef(siteLabel)
@@ -659,28 +707,41 @@ class Graph:
659
707
  keys = Dictionary.Keys(siteDictionary)
660
708
  for key in keys:
661
709
  value = Dictionary.ValueAtKey(siteDictionary, key)
662
- if not (key == labelKey) and not (key == typeKey):
663
- bot_graph.add((site_uri, bot[key], Literal(value)))
710
+ if not (key == vertexLabelKey) and not (key == typeKey):
711
+ if isinstance(value, float):
712
+ datatype = XSD.float
713
+ elif isinstance(value, bool):
714
+ datatype = XSD.boolean
715
+ elif isinstance(value, int):
716
+ datatype = XSD.integer
717
+ elif isinstance(value, str):
718
+ datatype = XSD.string
719
+ bot_graph.add((site_uri, top[key], Literal(value, datatype=datatype)))
664
720
  # Add building
665
721
  building_uri = URIRef(buildingLabel)
666
722
  bot_graph.add((building_uri, rdf.type, bot.Building))
667
723
  if includeLabel:
668
724
  bot_graph.add((building_uri, RDFS.label, Literal(buildingLabel)))
669
725
  if Topology.IsInstance(buildingDictionary, "Dictionary"):
670
- keys = Dictionary.Keys(buildingDictionary)
726
+ keys = Dictionary.Keys(siteDictionary)
671
727
  for key in keys:
672
- value = Dictionary.ValueAtKey(buildingDictionary, key)
673
- if key == labelKey:
674
- if includeLabel:
675
- bot_graph.add((building_uri, RDFS.label, Literal(value)))
676
- elif key != typeKey:
677
- bot_graph.add((building_uri, bot[key], Literal(value)))
728
+ value = Dictionary.ValueAtKey(siteDictionary, key)
729
+ if not (key == vertexLabelKey) and not (key == typeKey):
730
+ if isinstance(value, float):
731
+ datatype = XSD.float
732
+ elif isinstance(value, bool):
733
+ datatype = XSD.boolean
734
+ elif isinstance(value, int):
735
+ datatype = XSD.integer
736
+ elif isinstance(value, str):
737
+ datatype = XSD.string
738
+ bot_graph.add((building_uri, top[key], Literal(value, datatype=datatype)))
678
739
  # Add stories
679
740
  # if floor levels are not given, then need to be computed
680
741
  if len(floorLevels) == 0:
681
- for node, attributes in json_data['vertices'].items():
742
+ for node, attributes in json_data[verticesKey].items():
682
743
  if slabType.lower() in attributes[typeKey].lower():
683
- floorLevels.append(attributes["z"])
744
+ floorLevels.append(attributes[zKey])
684
745
  floorLevels = list(set(floorLevels))
685
746
  floorLevels.sort()
686
747
  floorLevels = floorLevels[:-1]
@@ -704,12 +765,12 @@ class Graph:
704
765
  bot_graph.add((storey_uri, bot.isPartOf, building_uri)) # might not be needed
705
766
 
706
767
  # Add vertices as RDF resources
707
- for node, attributes in json_data['vertices'].items():
708
- node_uri = URIRef(node)
768
+ for node, attributes in json_data[verticesKey].items():
769
+ node_uri = URIRef(top[node])
709
770
  if spaceType.lower() in attributes[typeKey].lower():
710
771
  bot_graph.add((node_uri, rdf.type, bot.Space))
711
772
  # Find the storey it is on
712
- z = attributes["z"]
773
+ z = attributes[zKey]
713
774
  level = Helper.Position(z, floorLevels)
714
775
  if level > len(storey_uris):
715
776
  level = len(storey_uris)
@@ -733,31 +794,39 @@ class Graph:
733
794
  if key == geometryKey:
734
795
  if includeGeometry:
735
796
  bot_graph.add((node_uri, bot.hasSimpleGeometry, Literal(value)))
736
- if key == labelKey:
797
+ if key == vertexLabelKey:
737
798
  if includeLabel:
738
799
  bot_graph.add((node_uri, RDFS.label, Literal(value)))
739
800
  elif key != typeKey and key != geometryKey:
740
- bot_graph.add((node_uri, bot[key], Literal(value)))
801
+ if isinstance(value, float):
802
+ datatype = XSD.float
803
+ elif isinstance(value, bool):
804
+ datatype = XSD.boolean
805
+ elif isinstance(value, int):
806
+ datatype = XSD.integer
807
+ elif isinstance(value, str):
808
+ datatype = XSD.string
809
+ bot_graph.add((node_uri, top[key], Literal(value, datatype=datatype)))
741
810
  if includeLabel:
742
811
  for key, value in attributes.items():
743
- if key == labelKey:
812
+ if key == vertexLabelKey:
744
813
  bot_graph.add((node_uri, RDFS.label, Literal(value)))
745
814
 
746
815
  # Add edges as RDF triples
747
- for edge, attributes in json_data['edges'].items():
748
- source = attributes["source"]
749
- target = attributes["target"]
750
- source_uri = URIRef(source)
751
- target_uri = URIRef(target)
752
- if spaceType.lower() in json_data['vertices'][source][typeKey].lower() and spaceType.lower() in json_data['vertices'][target][typeKey].lower():
816
+ for edge, attributes in json_data[edgesKey].items():
817
+ source = attributes[sourceKey]
818
+ target = attributes[targetKey]
819
+ source_uri = URIRef(top[source])
820
+ target_uri = URIRef(top[target])
821
+ if spaceType.lower() in json_data[verticesKey][source][typeKey].lower() and spaceType.lower() in json_data[verticesKey][target][typeKey].lower():
753
822
  bot_graph.add((source_uri, bot.adjacentTo, target_uri))
754
823
  if bidirectional:
755
824
  bot_graph.add((target_uri, bot.adjacentTo, source_uri))
756
- elif spaceType.lower() in json_data['vertices'][source][typeKey].lower() and wallType.lower() in json_data['vertices'][target][typeKey].lower():
825
+ elif spaceType.lower() in json_data[verticesKey][source][typeKey].lower() and wallType.lower() in json_data[verticesKey][target][typeKey].lower():
757
826
  bot_graph.add((target_uri, bot.interfaceOf, source_uri))
758
- elif spaceType.lower() in json_data['vertices'][source][typeKey].lower() and slabType.lower() in json_data['vertices'][target][typeKey].lower():
827
+ elif spaceType.lower() in json_data[verticesKey][source][typeKey].lower() and slabType.lower() in json_data['vertices'][target][typeKey].lower():
759
828
  bot_graph.add((target_uri, bot.interfaceOf, source_uri))
760
- elif spaceType.lower() in json_data['vertices'][source][typeKey].lower() and contentType.lower() in json_data['vertices'][target][typeKey].lower():
829
+ elif spaceType.lower() in json_data[verticesKey][source][typeKey].lower() and contentType.lower() in json_data[verticesKey][target][typeKey].lower():
761
830
  bot_graph.add((source_uri, bot.containsElement, target_uri))
762
831
  if bidirectional:
763
832
  bot_graph.add((target_uri, bot.isPartOf, source_uri))
@@ -769,26 +838,36 @@ class Graph:
769
838
 
770
839
  @staticmethod
771
840
  def BOTString(graph,
772
- format="turtle",
773
- bidirectional=False,
774
- includeAttributes=False,
775
- includeLabel=False,
776
- includeGeometry=False,
777
- siteLabel = "Site_0001",
778
- siteDictionary = None,
779
- buildingLabel = "Building_0001",
780
- buildingDictionary = None ,
781
- storeyPrefix = "Storey",
782
- floorLevels =[],
783
- labelKey="label",
784
- typeKey="type",
785
- geometryKey="brep",
786
- spaceType = "space",
787
- wallType = "wall",
788
- slabType = "slab",
789
- doorType = "door",
790
- windowType = "window",
791
- contentType = "content",
841
+ format="turtle",
842
+ bidirectional: bool = False,
843
+ includeAttributes: bool = False,
844
+ includeLabel: bool = False,
845
+ includeGeometry: bool = False,
846
+ siteLabel: str = "Site_0001",
847
+ siteDictionary: dict = None,
848
+ buildingLabel: str = "Building_0001",
849
+ buildingDictionary: dict = None ,
850
+ storeyPrefix: str = "Storey",
851
+ floorLevels: list = [],
852
+ vertexLabelKey: str = "label",
853
+ typeKey: str = "type",
854
+ verticesKey: str = "vertices",
855
+ edgesKey: str = "edges",
856
+ edgeLabelKey: str = "",
857
+ sourceKey: str = "source",
858
+ targetKey: str = "target",
859
+ xKey: str = "hasX",
860
+ yKey: str = "hasY",
861
+ zKey: str = "hasZ",
862
+ geometryKey: str = "brep",
863
+ spaceType: str = "space",
864
+ wallType: str = "wall",
865
+ slabType: str = "slab",
866
+ doorType: str = "door",
867
+ windowType: str = "window",
868
+ contentType: str = "content",
869
+ namespace: str = "http://github.com/wassimj/topologicpy/resources",
870
+ mantissa: int = 6
792
871
  ):
793
872
 
794
873
  """
@@ -828,11 +907,33 @@ class Graph:
828
907
  The desired prefixed to use for each building storey. The default is "Storey".
829
908
  floorLevels : list , optional
830
909
  The list of floor levels. This should be a numeric list, sorted from lowest to highest.
831
- If not provided, floorLevels will be computed automatically based on the vertices' 'z' attribute.
910
+ If not provided, floorLevels will be computed automatically based on the vertices' (zKey)) attribute. See below.
911
+ verticesKey : str , optional
912
+ The desired key name to call vertices. The default is "vertices".
913
+ edgesKey : str , optional
914
+ The desired key name to call edges. The default is "edges".
915
+ vertexLabelKey : str , optional
916
+ 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.
917
+ Note: If vertex labels are not unique, they will be forced to be unique.
918
+ edgeLabelKey : str , optional
919
+ 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.
920
+ Note: If edge labels are not unique, they will be forced to be unique.
921
+ sourceKey : str , optional
922
+ The dictionary key used to store the source vertex. The default is "source".
923
+ targetKey : str , optional
924
+ The dictionary key used to store the target vertex. The default is "target".
925
+ xKey : str , optional
926
+ The desired key name to use for x-coordinates. The default is "hasX".
927
+ yKey : str , optional
928
+ The desired key name to use for y-coordinates. The default is "hasY".
929
+ zKey : str , optional
930
+ The desired key name to use for z-coordinates. The default is "hasZ".
931
+ geometryKey : str , optional
932
+ The desired key name to use for geometry. The default is "brep".
832
933
  typeKey : str , optional
833
934
  The dictionary key to use to look up the type of the node. The default is "type".
834
- labelKey : str , optional
835
- The dictionary key to use to look up the label of the node. The default is "label".
935
+ geometryKey : str , optional
936
+ The dictionary key to use to look up the geometry of the node. The default is "brep".
836
937
  spaceType : str , optional
837
938
  The dictionary string value to use to look up vertices of type "space". The default is "space".
838
939
  wallType : str , optional
@@ -845,6 +946,10 @@ class Graph:
845
946
  The dictionary string value to use to look up vertices of type "window". The default is "window".
846
947
  contentType : str , optional
847
948
  The dictionary string value to use to look up vertices of type "content". The default is "contents".
949
+ namespace : str , optional
950
+ The desired namespace to use in the BOT graph. The default is "http://github.com/wassimj/topologicpy/resources".
951
+ mantissa : int , optional
952
+ The desired length of the mantissa. The default is 6.
848
953
 
849
954
 
850
955
  Returns
@@ -853,27 +958,36 @@ class Graph:
853
958
  The rdf graph serialized string using the BOT ontology.
854
959
  """
855
960
 
856
- bot_graph = Graph.BOTGraph(graph,
857
- bidirectional=bidirectional,
858
- includeAttributes=includeAttributes,
859
- includeLabel=includeLabel,
860
- includeGeometry=includeGeometry,
861
- siteLabel=siteLabel,
862
- siteDictionary=siteDictionary,
863
- buildingLabel=buildingLabel,
864
- buildingDictionary=buildingDictionary,
865
- storeyPrefix=storeyPrefix,
866
- floorLevels=floorLevels,
867
- labelKey=labelKey,
868
- typeKey=typeKey,
869
- geometryKey=geometryKey,
870
- spaceType = spaceType,
871
- wallType = wallType,
872
- slabType = slabType,
873
- doorType = doorType,
874
- windowType = windowType,
875
- contentType = contentType
876
- )
961
+ bot_graph = Graph.BOTGraph(graph= graph,
962
+ bidirectional= bidirectional,
963
+ includeAttributes= includeAttributes,
964
+ includeLabel= includeLabel,
965
+ includeGeometry= includeGeometry,
966
+ siteLabel= siteLabel,
967
+ siteDictionary= siteDictionary,
968
+ buildingLabel= buildingLabel,
969
+ buildingDictionary= buildingDictionary,
970
+ storeyPrefix= storeyPrefix,
971
+ floorLevels= floorLevels,
972
+ vertexLabelKey= vertexLabelKey,
973
+ typeKey= typeKey,
974
+ verticesKey= verticesKey,
975
+ edgesKey= edgesKey,
976
+ edgeLabelKey= edgeLabelKey,
977
+ sourceKey= sourceKey,
978
+ targetKey= targetKey,
979
+ xKey= xKey,
980
+ yKey= yKey,
981
+ zKey= zKey,
982
+ geometryKey= geometryKey,
983
+ spaceType= spaceType,
984
+ wallType= wallType,
985
+ slabType= slabType,
986
+ doorType= doorType,
987
+ windowType= windowType,
988
+ contentType= contentType,
989
+ namespace= namespace,
990
+ mantissa= mantissa)
877
991
  return bot_graph.serialize(format=format)
878
992
 
879
993
  @staticmethod
@@ -2007,7 +2121,21 @@ class Graph:
2007
2121
  return Graph.ByVerticesEdges(g_vertices, g_edges)
2008
2122
 
2009
2123
  @staticmethod
2010
- def ByTopology(topology, direct=True, directApertures=False, viaSharedTopologies=False, viaSharedApertures=False, toExteriorTopologies=False, toExteriorApertures=False, toContents=False, toOutposts=False, idKey="TOPOLOGIC_ID", outpostsKey="outposts", useInternalVertex=True, storeBREP=False, tolerance=0.0001):
2124
+ def ByTopology(topology,
2125
+ direct: bool = True,
2126
+ directApertures: bool = False,
2127
+ viaSharedTopologies: bool = False,
2128
+ viaSharedApertures: bool = False,
2129
+ toExteriorTopologies: bool = False,
2130
+ toExteriorApertures: bool = False,
2131
+ toContents: bool = False,
2132
+ toOutposts: bool = False,
2133
+ idKey: str = "TOPOLOGIC_ID",
2134
+ outpostsKey: str = "outposts",
2135
+ useInternalVertex: bool =True,
2136
+ storeBREP: bool =False,
2137
+ mantissa: int = 6,
2138
+ tolerance: float = 0.0001):
2011
2139
  """
2012
2140
  Creates a graph.See https://en.wikipedia.org/wiki/Graph_(discrete_mathematics).
2013
2141
 
@@ -2339,7 +2467,7 @@ class Graph:
2339
2467
  else:
2340
2468
  vst2 = content.CenterOfMass()
2341
2469
  d1 = content.GetDictionary()
2342
- vst2 = Vertex.ByCoordinates(vst2.X(), vst2.Y(), vst2.Z())
2470
+ vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa), Vertex.Y(vst2, mantissa=mantissa), Vertex.Z(vst2, mantissa=mantissa))
2343
2471
  if storeBREP:
2344
2472
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
2345
2473
  d3 = mergeDictionaries2([d1, d2])
@@ -2359,7 +2487,7 @@ class Graph:
2359
2487
  else:
2360
2488
  vsa = sharedAp.CenterOfMass()
2361
2489
  d1 = sharedAp.GetDictionary()
2362
- vsa = Vertex.ByCoordinates(vsa.X()+(tolerance*100), vsa.Y()+(tolerance*100), vsa.Z()+(tolerance*100))
2490
+ vsa = Vertex.ByCoordinates(Vertex.X(vsa, mantissa=mantissa)+(tolerance*100), Vertex.Y(vsa, mantissa=mantissa)+(tolerance*100), Vertex.Z(vsa, mantissa=mantissa)+(tolerance*100))
2363
2491
  if storeBREP:
2364
2492
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedAp), Topology.Type(sharedAp), Topology.TypeAsString(sharedAp)])
2365
2493
  d3 = mergeDictionaries2([d1, d2])
@@ -2401,7 +2529,7 @@ class Graph:
2401
2529
  else:
2402
2530
  vst2 = content.CenterOfMass()
2403
2531
  d1 = content.GetDictionary()
2404
- vst2 = Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
2532
+ vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
2405
2533
  if storeBREP:
2406
2534
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
2407
2535
  d3 = mergeDictionaries2([d1, d2])
@@ -2421,7 +2549,7 @@ class Graph:
2421
2549
  else:
2422
2550
  vea = exTop.CenterOfMass()
2423
2551
  d1 = exTop.GetDictionary()
2424
- vea = Vertex.ByCoordinates(vea.X()+(tolerance*100), vea.Y()+(tolerance*100), vea.Z()+(tolerance*100))
2552
+ vea = Vertex.ByCoordinates(Vertex.X(vea, mantissa=mantissa)+(tolerance*100), Vertex.Y(vea, mantissa=mantissa)+(tolerance*100), Vertex.Z(vea, mantissa=mantissa)+(tolerance*100))
2425
2553
  if storeBREP:
2426
2554
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
2427
2555
  d3 = mergeDictionaries2([d1, d2])
@@ -2443,7 +2571,7 @@ class Graph:
2443
2571
  vcn = Topology.InternalVertex(content, tolerance)
2444
2572
  else:
2445
2573
  vcn = content.CenterOfMass()
2446
- vcn = Vertex.ByCoordinates(vcn.X()+(tolerance*100), vcn.Y()+(tolerance*100), vcn.Z()+(tolerance*100))
2574
+ vcn = Vertex.ByCoordinates(Vertex.X(vcn, mantissa=mantissa)+(tolerance*100), Vertex.Y(vcn, mantissa=mantissa)+(tolerance*100), Vertex.Z(vcn, mantissa=mantissa)+(tolerance*100))
2447
2575
  d1 = content.GetDictionary()
2448
2576
  if storeBREP:
2449
2577
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
@@ -2549,7 +2677,7 @@ class Graph:
2549
2677
  vst2 = Topology.InternalVertex(content, tolerance)
2550
2678
  else:
2551
2679
  vst2 = content.CenterOfMass()
2552
- vst2 = Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
2680
+ vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
2553
2681
  d1 = content.GetDictionary()
2554
2682
  if storeBREP:
2555
2683
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
@@ -2570,7 +2698,7 @@ class Graph:
2570
2698
  else:
2571
2699
  vst = exTop.CenterOfMass()
2572
2700
  d1 = exTop.GetDictionary()
2573
- vst = Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
2701
+ vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
2574
2702
  if storeBREP:
2575
2703
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
2576
2704
  d3 = mergeDictionaries2([d1, d2])
@@ -2592,7 +2720,7 @@ class Graph:
2592
2720
  vst = Topology.InternalVertex(content, tolerance)
2593
2721
  else:
2594
2722
  vst = content.CenterOfMass()
2595
- vst = Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
2723
+ vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
2596
2724
  d1 = content.GetDictionary()
2597
2725
  if storeBREP:
2598
2726
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
@@ -2747,7 +2875,7 @@ class Graph:
2747
2875
  vst2 = Topology.InternalVertex(content, tolerance)
2748
2876
  else:
2749
2877
  vst2 = content.CenterOfMass()
2750
- vst2 = Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
2878
+ vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
2751
2879
  d1 = content.GetDictionary()
2752
2880
  if storeBREP:
2753
2881
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
@@ -2768,7 +2896,7 @@ class Graph:
2768
2896
  else:
2769
2897
  vst = sharedAp.CenterOfMass()
2770
2898
  d1 = sharedAp.GetDictionary()
2771
- vst = Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
2899
+ vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
2772
2900
  if storeBREP:
2773
2901
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedAp), Topology.Type(sharedAp), Topology.TypeAsString(sharedAp)])
2774
2902
  d3 = mergeDictionaries2([d1, d2])
@@ -2808,7 +2936,7 @@ class Graph:
2808
2936
  vst2 = Topology.InternalVertex(content, tolerance)
2809
2937
  else:
2810
2938
  vst2 = content.CenterOfMass()
2811
- vst2 = Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
2939
+ vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
2812
2940
  d1 = content.GetDictionary()
2813
2941
  if storeBREP:
2814
2942
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
@@ -2829,7 +2957,7 @@ class Graph:
2829
2957
  else:
2830
2958
  vst = exTop.CenterOfMass()
2831
2959
  d1 = exTop.GetDictionary()
2832
- vst = Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
2960
+ vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
2833
2961
  if storeBREP:
2834
2962
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
2835
2963
  d3 = mergeDictionaries2([d1, d2])
@@ -2851,7 +2979,7 @@ class Graph:
2851
2979
  vst = Topology.InternalVertex(content, tolerance)
2852
2980
  else:
2853
2981
  vst = content.CenterOfMass()
2854
- vst = Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
2982
+ vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
2855
2983
  d1 = content.GetDictionary()
2856
2984
  if storeBREP:
2857
2985
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
@@ -2997,7 +3125,7 @@ class Graph:
2997
3125
  vst2 = Topology.InternalVertex(content, tolerance)
2998
3126
  else:
2999
3127
  vst2 = content.CenterOfMass()
3000
- vst2 = Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
3128
+ vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
3001
3129
  d1 = content.GetDictionary()
3002
3130
  if storeBREP:
3003
3131
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
@@ -3018,7 +3146,7 @@ class Graph:
3018
3146
  else:
3019
3147
  vst = exTop.CenterOfMass()
3020
3148
  d1 = exTop.GetDictionary()
3021
- vst = Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
3149
+ vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
3022
3150
  if storeBREP:
3023
3151
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
3024
3152
  d3 = mergeDictionaries2([d1, d2])
@@ -3040,7 +3168,7 @@ class Graph:
3040
3168
  vst = Topology.InternalVertex(content, tolerance)
3041
3169
  else:
3042
3170
  vst = content.CenterOfMass()
3043
- vst = Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
3171
+ vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
3044
3172
  d1 = content.GetDictionary()
3045
3173
  if storeBREP:
3046
3174
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
@@ -3203,7 +3331,7 @@ class Graph:
3203
3331
  vst2 = Topology.InternalVertex(content, tolerance)
3204
3332
  else:
3205
3333
  vst2 = content.CenterOfMass()
3206
- vst2 = Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
3334
+ vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
3207
3335
  d1 = content.GetDictionary()
3208
3336
  if storeBREP:
3209
3337
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
@@ -3224,7 +3352,7 @@ class Graph:
3224
3352
  else:
3225
3353
  vst = sharedAp.CenterOfMass()
3226
3354
  d1 = sharedAp.GetDictionary()
3227
- vst = Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
3355
+ vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
3228
3356
  if storeBREP:
3229
3357
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedAp), Topology.Type(sharedAp), Topology.TypeAsString(sharedAp)])
3230
3358
  d3 = mergeDictionaries2([d1, d2])
@@ -3254,7 +3382,7 @@ class Graph:
3254
3382
  vst2 = Topology.InternalVertex(content, tolerance)
3255
3383
  else:
3256
3384
  vst2 = content.CenterOfMass()
3257
- vst2 = Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
3385
+ vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
3258
3386
  d1 = content.GetDictionary()
3259
3387
  if storeBREP:
3260
3388
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
@@ -3275,7 +3403,7 @@ class Graph:
3275
3403
  else:
3276
3404
  vst = exTop.CenterOfMass()
3277
3405
  d1 = exTop.GetDictionary()
3278
- vst = Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
3406
+ vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
3279
3407
  if storeBREP:
3280
3408
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
3281
3409
  d3 = mergeDictionaries2([d1, d2])
@@ -3297,7 +3425,7 @@ class Graph:
3297
3425
  vst = Topology.InternalVertex(content, tolerance)
3298
3426
  else:
3299
3427
  vst = content.CenterOfMass()
3300
- vst = Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
3428
+ vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
3301
3429
  d1 = content.GetDictionary()
3302
3430
  if storeBREP:
3303
3431
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
@@ -3449,7 +3577,7 @@ class Graph:
3449
3577
  vst2 = Topology.InternalVertex(content, tolerance)
3450
3578
  else:
3451
3579
  vst2 = content.CenterOfMass()
3452
- vst2 = Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
3580
+ vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
3453
3581
  d1 = content.GetDictionary()
3454
3582
  if storeBREP:
3455
3583
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
@@ -3470,7 +3598,7 @@ class Graph:
3470
3598
  else:
3471
3599
  vst = exTop.CenterOfMass()
3472
3600
  d1 = exTop.GetDictionary()
3473
- vst = Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
3601
+ vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
3474
3602
  if storeBREP:
3475
3603
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
3476
3604
  d3 = mergeDictionaries2([d1, d2])
@@ -3502,7 +3630,7 @@ class Graph:
3502
3630
  else:
3503
3631
  vst = content.CenterOfMass()
3504
3632
  d1 = content.GetDictionary()
3505
- vst = Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
3633
+ vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
3506
3634
  if storeBREP:
3507
3635
  d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
3508
3636
  d3 = mergeDictionaries2([d1, d2])
@@ -4345,37 +4473,49 @@ class Graph:
4345
4473
 
4346
4474
  @staticmethod
4347
4475
  def ExportToBOT(graph,
4348
- path,
4349
- format="turtle",
4350
- overwrite = False,
4351
- bidirectional=False,
4352
- includeAttributes=False,
4353
- includeLabel=False,
4354
- includeGeometry=False,
4355
- siteLabel = "Site_0001",
4356
- siteDictionary = None,
4357
- buildingLabel = "Building_0001",
4358
- buildingDictionary = None ,
4359
- storeyPrefix = "Storey",
4360
- floorLevels =[],
4361
- labelKey="label",
4362
- typeKey="type",
4363
- geometryKey="brep",
4364
- spaceType = "space",
4365
- wallType = "wall",
4366
- slabType = "slab",
4367
- doorType = "door",
4368
- windowType = "window",
4369
- contentType = "content",
4476
+ path: str,
4477
+ format: str = "turtle",
4478
+ overwrite: bool = False,
4479
+ bidirectional: bool = False,
4480
+ includeAttributes: bool = False,
4481
+ includeLabel: bool = False,
4482
+ includeGeometry: bool = False,
4483
+ siteLabel: str = "Site_0001",
4484
+ siteDictionary: dict = None,
4485
+ buildingLabel: str = "Building_0001",
4486
+ buildingDictionary: dict = None ,
4487
+ storeyPrefix: str = "Storey",
4488
+ floorLevels: list = [],
4489
+ vertexLabelKey: str = "label",
4490
+ typeKey: str = "type",
4491
+ verticesKey: str = "vertices",
4492
+ edgesKey: str = "edges",
4493
+ edgeLabelKey: str = "",
4494
+ sourceKey: str = "source",
4495
+ targetKey: str = "target",
4496
+ xKey: str = "hasX",
4497
+ yKey: str = "hasY",
4498
+ zKey: str = "hasZ",
4499
+ geometryKey: str = "brep",
4500
+ spaceType: str = "space",
4501
+ wallType: str = "wall",
4502
+ slabType: str = "slab",
4503
+ doorType: str = "door",
4504
+ windowType: str = "window",
4505
+ contentType: str = "content",
4506
+ namespace: str = "http://github.com/wassimj/topologicpy/resources",
4507
+ mantissa: int = 6
4370
4508
  ):
4371
4509
 
4372
4510
  """
4373
- Returns an RDF graph serialized string according to the BOT ontology. See https://w3c-lbd-cg.github.io/bot/.
4511
+ Exports the input graph to an RDF graph serialized according to the BOT ontology. See https://w3c-lbd-cg.github.io/bot/.
4374
4512
 
4375
4513
  Parameters
4376
4514
  ----------
4377
4515
  graph : topologic_core.Graph
4378
4516
  The input graph.
4517
+ path : str
4518
+ The desired path to where the RDF/BOT file will be saved.
4379
4519
  format : str , optional
4380
4520
  The desired output format, the options are listed below. Thde default is "turtle".
4381
4521
  turtle, ttl or turtle2 : Turtle, turtle2 is just turtle with more spacing & linebreaks
@@ -4386,8 +4526,6 @@ class Graph:
4386
4526
  trig : Trig , Turtle-like format for RDF triples + context (RDF quads) and thus multiple graphs
4387
4527
  trix : Trix , RDF/XML-like format for RDF quads
4388
4528
  nquads : N-Quads , N-Triples-like format for RDF quads
4389
- path : str
4390
- The desired path to where the RDF/BOT file will be saved.
4391
4529
  overwrite : bool , optional
4392
4530
  If set to True, any existing file is overwritten. Otherwise, it is not. The default is False.
4393
4531
  bidirectional : bool , optional
@@ -4397,7 +4535,7 @@ class Graph:
4397
4535
  includeLabel : bool , optional
4398
4536
  If set to True, a label is attached to each node. Otherwise, it is not. The default is False.
4399
4537
  includeGeometry : bool , optional
4400
- If set to True, the geometry associated with vertices in the graph are written out. Otherwise, it is not. The default is False.
4538
+ If set to True, the geometry associated with vertices in the graph are written out. Otherwise, they are not. The default is False.
4401
4539
  siteLabel : str , optional
4402
4540
  The desired site label. The default is "Site_0001".
4403
4541
  siteDictionary : dict , optional
@@ -4410,35 +4548,49 @@ class Graph:
4410
4548
  The desired prefixed to use for each building storey. The default is "Storey".
4411
4549
  floorLevels : list , optional
4412
4550
  The list of floor levels. This should be a numeric list, sorted from lowest to highest.
4413
- If not provided, floorLevels will be computed automatically based on the nodes' 'z' attribute.
4551
+ If not provided, floorLevels will be computed automatically based on the vertices' (zKey)) attribute. See below.
4552
+ verticesKey : str , optional
4553
+ The desired key name to call vertices. The default is "vertices".
4554
+ edgesKey : str , optional
4555
+ The desired key name to call edges. The default is "edges".
4556
+ vertexLabelKey : str , optional
4557
+ 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.
4558
+ Note: If vertex labels are not unique, they will be forced to be unique.
4559
+ edgeLabelKey : str , optional
4560
+ 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.
4561
+ Note: If edge labels are not unique, they will be forced to be unique.
4562
+ sourceKey : str , optional
4563
+ The dictionary key used to store the source vertex. The default is "source".
4564
+ targetKey : str , optional
4565
+ The dictionary key used to store the target vertex. The default is "target".
4566
+ xKey : str , optional
4567
+ The desired key name to use for x-coordinates. The default is "hasX".
4568
+ yKey : str , optional
4569
+ The desired key name to use for y-coordinates. The default is "hasY".
4570
+ zKey : str , optional
4571
+ The desired key name to use for z-coordinates. The default is "hasZ".
4572
+ geometryKey : str , optional
4573
+ The desired key name to use for geometry. The default is "brep".
4414
4574
  typeKey : str , optional
4415
4575
  The dictionary key to use to look up the type of the node. The default is "type".
4416
- labelKey : str , optional
4417
- The dictionary key to use to look up the label of the node. The default is "label".
4418
4576
  geometryKey : str , optional
4419
- The dictionary key to use to look up the label of the node. The default is "brep".
4577
+ The dictionary key to use to look up the geometry of the node. The default is "brep".
4420
4578
  spaceType : str , optional
4421
- The dictionary string value to use to look up nodes of type "space". The default is "space".
4579
+ The dictionary string value to use to look up vertices of type "space". The default is "space".
4422
4580
  wallType : str , optional
4423
- The dictionary string value to use to look up nodes of type "wall". The default is "wall".
4581
+ The dictionary string value to use to look up vertices of type "wall". The default is "wall".
4424
4582
  slabType : str , optional
4425
- The dictionary string value to use to look up nodes of type "slab". The default is "slab".
4583
+ The dictionary string value to use to look up vertices of type "slab". The default is "slab".
4426
4584
  doorType : str , optional
4427
- The dictionary string value to use to look up nodes of type "door". The default is "door".
4585
+ The dictionary string value to use to look up vertices of type "door". The default is "door".
4428
4586
  windowType : str , optional
4429
- The dictionary string value to use to look up nodes of type "window". The default is "window".
4587
+ The dictionary string value to use to look up vertices of type "window". The default is "window".
4430
4588
  contentType : str , optional
4431
- The dictionary string value to use to look up nodes of type "content". The default is "contents".
4432
- format : str , optional
4433
- The desired output format, the options are listed below. Thde default is "turtle".
4434
- turtle, ttl or turtle2 : Turtle, turtle2 is just turtle with more spacing & linebreaks
4435
- xml or pretty-xml : RDF/XML, Was the default format, rdflib < 6.0.0
4436
- json-ld : JSON-LD , There are further options for compact syntax and other JSON-LD variants
4437
- ntriples, nt or nt11 : N-Triples , nt11 is exactly like nt, only utf8 encoded
4438
- n3 : Notation-3 , N3 is a superset of Turtle that also caters for rules and a few other things
4439
- trig : Trig , Turtle-like format for RDF triples + context (RDF quads) and thus multiple graphs
4440
- trix : Trix , RDF/XML-like format for RDF quads
4441
- nquads : N-Quads , N-Triples-like format for RDF quads
4589
+ The dictionary string value to use to look up vertices of type "content". The default is "contents".
4590
+ namespace : str , optional
4591
+ The desired namespace to use in the BOT graph. The default is "http://github.com/wassimj/topologicpy/resources".
4592
+ mantissa : int , optional
4593
+ The desired length of the mantissa. The default is 6.
4442
4594
 
4443
4595
  Returns
4444
4596
  -------
@@ -4446,27 +4598,37 @@ class Graph:
4446
4598
  The rdf graph serialized string using the BOT ontology.
4447
4599
  """
4448
4600
  from os.path import exists
4449
- bot_graph = Graph.BOTGraph(graph,
4450
- bidirectional=bidirectional,
4451
- includeAttributes=includeAttributes,
4452
- includeLabel=includeLabel,
4453
- includeGeometry=includeGeometry,
4454
- siteLabel=siteLabel,
4455
- siteDictionary=siteDictionary,
4456
- buildingLabel=buildingLabel,
4457
- buildingDictionary=buildingDictionary,
4458
- storeyPrefix=storeyPrefix,
4459
- floorLevels=floorLevels,
4460
- labelKey=labelKey,
4461
- typeKey=typeKey,
4462
- geometryKey=geometryKey,
4463
- spaceType = spaceType,
4464
- wallType = wallType,
4465
- slabType = slabType,
4466
- doorType = doorType,
4467
- windowType = windowType,
4468
- contentType = contentType
4469
- )
4601
+ bot_graph = Graph.BOTGraph(graph= graph,
4602
+ bidirectional= bidirectional,
4603
+ includeAttributes= includeAttributes,
4604
+ includeLabel= includeLabel,
4605
+ includeGeometry= includeGeometry,
4606
+ siteLabel= siteLabel,
4607
+ siteDictionary= siteDictionary,
4608
+ buildingLabel= buildingLabel,
4609
+ buildingDictionary= buildingDictionary,
4610
+ storeyPrefix= storeyPrefix,
4611
+ floorLevels= floorLevels,
4612
+ vertexLabelKey= vertexLabelKey,
4613
+ typeKey= typeKey,
4614
+ verticesKey= verticesKey,
4615
+ edgesKey= edgesKey,
4616
+ edgeLabelKey= edgeLabelKey,
4617
+ sourceKey= sourceKey,
4618
+ targetKey= targetKey,
4619
+ xKey= xKey,
4620
+ yKey= yKey,
4621
+ zKey= zKey,
4622
+ geometryKey= geometryKey,
4623
+ spaceType= spaceType,
4624
+ wallType= wallType,
4625
+ slabType= slabType,
4626
+ doorType= doorType,
4627
+ windowType= windowType,
4628
+ contentType= contentType,
4629
+ namespace= namespace,
4630
+ mantissa= mantissa)
4631
+
4470
4632
  if "turtle" in format.lower() or "ttl" in format.lower() or "turtle2" in format.lower():
4471
4633
  ext = ".ttl"
4472
4634
  elif "xml" in format.lower() or "pretty=xml" in format.lower() or "rdf/xml" in format.lower():
@@ -4759,7 +4921,7 @@ class Graph:
4759
4921
  node_features = node_features + ","+ str(round(float(Dictionary.ValueAtKey(nd, node_feature_key)),mantissa))
4760
4922
  else:
4761
4923
  node_features = str(round(float(Dictionary.ValueAtKey(nd, node_feature_key)),mantissa))
4762
- single_node_data = [graph_id, i, vLabel, train_mask, validate_mask, test_mask, node_features, round(float(Vertex.X(v)),mantissa), round(float(Vertex.Y(v)),mantissa), round(float(Vertex.Z(v)),mantissa)]
4924
+ single_node_data = [graph_id, i, vLabel, train_mask, validate_mask, test_mask, node_features, float(Vertex.X(v, mantissa=mantissa)), float(Vertex.Y(v,mantissa)), float(Vertex.Z(v,mantissa))]
4763
4925
  node_data.append(single_node_data)
4764
4926
 
4765
4927
  # Write Node Data to CSV file
@@ -4871,11 +5033,11 @@ class Graph:
4871
5033
  return True
4872
5034
 
4873
5035
  @staticmethod
4874
- def ExportToGEXF(graph, path, graphWidth=20, graphLength=20, graphHeight=20,
4875
- defaultVertexColor="black", defaultVertexSize=3,
4876
- vertexLabelKey=None, vertexColorKey=None, vertexSizeKey=None,
4877
- defaultEdgeColor="black", defaultEdgeWeight=1, defaultEdgeType="undirected",
4878
- edgeLabelKey=None, edgeColorKey=None, edgeWeightKey=None, overwrite=False):
5036
+ def ExportToGEXF(graph, path: str = None, graphWidth: float = 20, graphLength: float = 20, graphHeight: float = 20,
5037
+ defaultVertexColor: str = "black", defaultVertexSize: float = 3,
5038
+ vertexLabelKey: str = None, vertexColorKey: str = None, vertexSizeKey: str = None,
5039
+ defaultEdgeColor: str = "black", defaultEdgeWeight: float = 1, defaultEdgeType: str = "undirected",
5040
+ edgeLabelKey: str = None, edgeColorKey: str = None, edgeWeightKey: str = None, overwrite: bool = False, mantissa: int = 6):
4879
5041
  """
4880
5042
  Exports the input graph to a Graph Exchange XML (GEXF) file format. See https://gexf.net/
4881
5043
 
@@ -4921,6 +5083,8 @@ class Graph:
4921
5083
  the edge weight is set to the value defined by defaultEdgeWeight parameter. The default is None.
4922
5084
  overwrite : bool , optional
4923
5085
  If set to True, any existing file is overwritten. Otherwise, it is not. The default is False.
5086
+ mantissa : int , optional
5087
+ The desired length of the mantissa. The default is 6.
4924
5088
 
4925
5089
  Returns
4926
5090
  -------
@@ -5049,9 +5213,9 @@ class Graph:
5049
5213
  'size': 'double'}
5050
5214
  nodes = {}
5051
5215
  # Resize the graph
5052
- xList = [Vertex.X(v) for v in g_vertices]
5053
- yList = [Vertex.Y(v) for v in g_vertices]
5054
- zList = [Vertex.Z(v) for v in g_vertices]
5216
+ xList = [Vertex.X(v, mantissa=mantissa) for v in g_vertices]
5217
+ yList = [Vertex.Y(v, mantissa=mantissa) for v in g_vertices]
5218
+ zList = [Vertex.Z(v, mantissa=mantissa) for v in g_vertices]
5055
5219
  xMin = min(xList)
5056
5220
  xMax = max(xList)
5057
5221
  yMin = min(yList)
@@ -5073,9 +5237,9 @@ class Graph:
5073
5237
  d = Topology.Dictionary(v)
5074
5238
  keys = Dictionary.Keys(d)
5075
5239
  values = Dictionary.Values(d)
5076
- x = (Vertex.X(v) - x_avg)*x_sf + x_avg
5077
- y = (Vertex.Y(v) - y_avg)*y_sf + y_avg
5078
- z = (Vertex.Z(v) - z_avg)*z_sf + z_avg
5240
+ x = (Vertex.X(v, mantissa=mantissa) - x_avg)*x_sf + x_avg
5241
+ y = (Vertex.Y(v, mantissa=mantissa) - y_avg)*y_sf + y_avg
5242
+ z = (Vertex.Z(v, mantissa=mantissa) - z_avg)*z_sf + z_avg
5079
5243
  node_dict['x'] = x
5080
5244
  node_dict['y'] = y
5081
5245
  node_dict['z'] = z
@@ -5944,17 +6108,17 @@ class Graph:
5944
6108
 
5945
6109
  @staticmethod
5946
6110
  def JSONData(graph,
5947
- verticesKey="vertices",
5948
- edgesKey="edges",
5949
- vertexLabelKey="",
5950
- edgeLabelKey="",
5951
- sourceKey="source",
5952
- targetKey="target",
5953
- xKey="x",
5954
- yKey="y",
5955
- zKey="z",
5956
- geometryKey="brep",
5957
- mantissa=6):
6111
+ verticesKey: str = "vertices",
6112
+ edgesKey: str = "edges",
6113
+ vertexLabelKey: str = "",
6114
+ edgeLabelKey: str = "",
6115
+ sourceKey: str = "source",
6116
+ targetKey: str = "target",
6117
+ xKey: str = "x",
6118
+ yKey: str = "y",
6119
+ zKey: str = "z",
6120
+ geometryKey: str = "brep",
6121
+ mantissa: int = 6):
5958
6122
  """
5959
6123
  Converts the input graph into JSON data.
5960
6124
 
@@ -5975,7 +6139,7 @@ class Graph:
5975
6139
  sourceKey : str , optional
5976
6140
  The dictionary key used to store the source vertex. The default is "source".
5977
6141
  targetKey : str , optional
5978
- The dictionary key used to store the target vertex. The default is "source".
6142
+ The dictionary key used to store the target vertex. The default is "target".
5979
6143
  xKey : str , optional
5980
6144
  The desired key name to use for x-coordinates. The default is "x".
5981
6145
  yKey : str , optional
@@ -6013,7 +6177,7 @@ class Graph:
6013
6177
  d = Dictionary.SetValueAtKey(d, zKey, Vertex.Z(v, mantissa=mantissa))
6014
6178
  if geometryKey:
6015
6179
  v_d = Topology.Dictionary(v)
6016
- brep = Dictionary.ValueAtKey(v_d,"brep")
6180
+ brep = Dictionary.ValueAtKey(v_d, geometryKey)
6017
6181
  if brep:
6018
6182
  d = Dictionary.SetValueAtKey(d, geometryKey, brep)
6019
6183
  v_dict = Dictionary.PythonDictionary(d)
@@ -6709,7 +6873,7 @@ class Graph:
6709
6873
  return nearestVertex
6710
6874
 
6711
6875
  @staticmethod
6712
- def NetworkXGraph(graph, tolerance=0.0001):
6876
+ def NetworkXGraph(graph, mantissa: int = 6, tolerance: float = 0.0001):
6713
6877
  """
6714
6878
  converts the input graph into a NetworkX Graph. See http://networkx.org
6715
6879
 
@@ -6717,6 +6881,10 @@ class Graph:
6717
6881
  ----------
6718
6882
  graph : topologic_core.Graph
6719
6883
  The input graph.
6884
+ mantissa : int , optional
6885
+ The desired length of the mantissa. The default is 6.
6886
+ tolerance : float , optional
6887
+ The desired tolerance. The default is 0.0001.
6720
6888
 
6721
6889
  Returns
6722
6890
  -------
@@ -6763,7 +6931,7 @@ class Graph:
6763
6931
  values = []
6764
6932
  keys += ["x","y","z"]
6765
6933
  import random
6766
- values += [Vertex.X(v), Vertex.Y(v), Vertex.Z(v)]
6934
+ values += [Vertex.X(v, mantissa=mantissa), Vertex.Y(v, mantissa=mantissa), Vertex.Z(v, mantissa=mantissa)]
6767
6935
  d = Dictionary.ByKeysValues(keys,values)
6768
6936
  pythonD = Dictionary.PythonDictionary(d)
6769
6937
  nodes.append((i, pythonD))
@@ -6776,7 +6944,7 @@ class Graph:
6776
6944
  for adjVertex in adjVertices:
6777
6945
  adjIndex = Vertex.Index(vertex=adjVertex, vertices=vertices, strict=True, tolerance=tolerance)
6778
6946
  if not adjIndex == None:
6779
- nxGraph.add_edge(i,adjIndex, length=(Vertex.Distance(v, adjVertex)))
6947
+ nxGraph.add_edge(i,adjIndex, length=(Vertex.Distance(v, adjVertex, mantissa=mantissa)))
6780
6948
 
6781
6949
  pos=nx.spring_layout(nxGraph, k=0.2)
6782
6950
  nx.set_node_attributes(nxGraph, pos, "pos")