scgraph 3.2.3__tar.gz → 3.3.0__tar.gz

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.
Files changed (27) hide show
  1. {scgraph-3.2.3 → scgraph-3.3.0}/PKG-INFO +1 -1
  2. {scgraph-3.2.3 → scgraph-3.3.0}/pyproject.toml +1 -1
  3. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/geograph.py +113 -11
  4. {scgraph-3.2.3 → scgraph-3.3.0}/CMakeLists.txt +0 -0
  5. {scgraph-3.2.3 → scgraph-3.3.0}/LICENSE +0 -0
  6. {scgraph-3.2.3 → scgraph-3.3.0}/README.md +0 -0
  7. {scgraph-3.2.3 → scgraph-3.3.0}/build/cp314-cp314-linux_x86_64/CMakeFiles/CheckCXX/CMakeLists.txt +0 -0
  8. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/__init__.py +0 -0
  9. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/contraction_hierarchies.py +0 -0
  10. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/cpp/bindings/graph_bindings.cpp +0 -0
  11. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/cpp/src/bmssp.hpp +0 -0
  12. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/cpp/src/contraction_hierarchies.cpp +0 -0
  13. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/cpp/src/contraction_hierarchies.hpp +0 -0
  14. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/cpp/src/graph.cpp +0 -0
  15. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/cpp/src/graph.hpp +0 -0
  16. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/cpp/src/graph_utils.cpp +0 -0
  17. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/cpp/src/graph_utils.hpp +0 -0
  18. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/cpp/src/transit_node_routing.cpp +0 -0
  19. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/cpp/src/transit_node_routing.hpp +0 -0
  20. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/graph.py +0 -0
  21. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/graph_utils.py +0 -0
  22. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/grid.py +0 -0
  23. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/helpers/__init__.py +0 -0
  24. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/helpers/geojson.py +0 -0
  25. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/helpers/visvalingam.py +0 -0
  26. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/transit_node_routing.py +0 -0
  27. {scgraph-3.2.3 → scgraph-3.3.0}/scgraph/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scgraph
3
- Version: 3.2.3
3
+ Version: 3.3.0
4
4
  Summary: Determine an approximate distance and route between two points on earth.
5
5
  Author-Email: Connor Makowski <conmak@mit.edu>
6
6
  License-Expression: MIT
@@ -26,7 +26,7 @@ include = [
26
26
 
27
27
  [project]
28
28
  name = "scgraph"
29
- version = "3.2.3"
29
+ version = "3.3.0"
30
30
  description = "Determine an approximate distance and route between two points on earth."
31
31
  authors = [
32
32
  {name="Connor Makowski", email="conmak@mit.edu"}
@@ -737,6 +737,107 @@ class GeoGraphModifiers:
737
737
  symmetric=symmetric,
738
738
  )
739
739
 
740
+ def add_coord_edge(
741
+ self,
742
+ origin_coord_dict: dict[str, float | int],
743
+ destination_coord_dict: dict[str, float | int],
744
+ symmetric: bool = True,
745
+ distance: float | int | None = None,
746
+ circuity: float | int = 1,
747
+ ) -> None:
748
+ """
749
+ Function:
750
+
751
+ - Add an edge to the graph between two nodes specified by their coordinates
752
+ - Finds the closest nodes in the graph to the provided coordinates and adds an edge between them
753
+
754
+ Required Arguments:
755
+
756
+ - `origin_coord_dict`
757
+ - Type: dict
758
+ - What: A dictionary with the keys 'latitude' and 'longitude' for the origin node
759
+ - Note: The function will find the closest node in the graph to these coordinates and use that as the origin node for the edge
760
+ - `destination_coord_dict`
761
+ - Type: dict
762
+ - What: A dictionary with the keys 'latitude' and 'longitude' for the destination node
763
+ - Note: The function will find the closest node in the graph to these coordinates and use that as the destination node for the edge
764
+
765
+ Optional Arguments:
766
+
767
+ - `symmetric`
768
+ - Type: bool
769
+ - What: Whether to add the edge in both directions
770
+ - Default: True
771
+ - `distance`
772
+ - Type: int | float | None
773
+ - What: The distance to use for the edge. If None, the haversine distance between the origin and destination nodes (the closest nodes to the provided ones) will be used (with circuity applied)
774
+ - Default: None
775
+ - `circuity`
776
+ - Type: int | float
777
+ - What: The circuity to apply to the distance calculation if distance is None
778
+ - Default: 1
779
+ """
780
+ assert isinstance(
781
+ origin_coord_dict, dict
782
+ ), "Origin node must be a dictionary"
783
+ assert isinstance(
784
+ destination_coord_dict, dict
785
+ ), "Destination node must be a dictionary"
786
+ assert (
787
+ "latitude" in origin_coord_dict.keys()
788
+ ), "Origin node must have a latitude"
789
+ assert (
790
+ "longitude" in origin_coord_dict.keys()
791
+ ), "Origin node must have a longitude"
792
+ assert (
793
+ "latitude" in destination_coord_dict.keys()
794
+ ), "Destination node must have a latitude"
795
+ assert (
796
+ "longitude" in destination_coord_dict.keys()
797
+ ), "Destination node must have a longitude"
798
+ assert (
799
+ origin_coord_dict["latitude"] >= -90
800
+ and origin_coord_dict["latitude"] <= 90
801
+ ), "Origin latitude must be between -90 and 90"
802
+ assert (
803
+ origin_coord_dict["longitude"] >= -180
804
+ and origin_coord_dict["longitude"] <= 180
805
+ ), "Origin longitude must be between -180 and 180"
806
+ assert (
807
+ destination_coord_dict["latitude"] >= -90
808
+ and destination_coord_dict["latitude"] <= 90
809
+ ), "Destination latitude must be between -90 and 90"
810
+ assert (
811
+ destination_coord_dict["longitude"] >= -180
812
+ and destination_coord_dict["longitude"] <= 180
813
+ ), "Destination longitude must be between -180 and 180"
814
+ origin_node = [
815
+ origin_coord_dict["latitude"],
816
+ origin_coord_dict["longitude"],
817
+ ]
818
+ destination_node = [
819
+ destination_coord_dict["latitude"],
820
+ destination_coord_dict["longitude"],
821
+ ]
822
+ closest_origin_idx = self.geokdtree.closest_idx(point=origin_node)
823
+ closest_destination_idx = self.geokdtree.closest_idx(
824
+ point=destination_node
825
+ )
826
+ if distance is None:
827
+ distance = (
828
+ haversine(
829
+ self.nodes[closest_origin_idx],
830
+ self.nodes[closest_destination_idx],
831
+ )
832
+ * circuity
833
+ )
834
+ self.add_edge(
835
+ origin_id=closest_origin_idx,
836
+ destination_id=closest_destination_idx,
837
+ distance=distance,
838
+ symmetric=symmetric,
839
+ )
840
+
740
841
  def add_coord_node(
741
842
  self,
742
843
  coord_dict: dict[str, float | int],
@@ -819,7 +920,7 @@ class GeoGraphModifiers:
819
920
  ), "Longitude must be between -180 and 180"
820
921
  node = [coord_dict["latitude"], coord_dict["longitude"]]
821
922
  if auto_edge:
822
- assert circuity > 1, "Circuity must be greater than 1"
923
+ assert circuity >= 1, "Circuity must be greater than or equal to 1"
823
924
  assert node_addition_type in [
824
925
  "quadrant",
825
926
  "all",
@@ -901,8 +1002,8 @@ class GeoGraphModifiers:
901
1002
  self.graph_object.graph
902
1003
  ), "Destination node does not exist"
903
1004
  self.add_edge(
904
- origin_idx=origin_idx,
905
- destination_idx=destination_idx,
1005
+ origin_id=origin_idx,
1006
+ destination_id=destination_idx,
906
1007
  distance=haversine(
907
1008
  self.nodes[origin_idx], self.nodes[destination_idx]
908
1009
  ),
@@ -1943,15 +2044,16 @@ class GeoGraph(
1943
2044
  except Exception as e:
1944
2045
  # Cleanup temp nodes from the graph
1945
2046
  self.__cleanup_temp_nodes__()
1946
- print("An error occurred while calculating the shortest path:")
1947
- print("This is likely caused by a disconnect in the graph.")
1948
- print(
1949
- "You can ensure a solution by setting destination_node_addition_type='all' and setting your lat_lon_bound=180."
1950
- )
1951
- print(
1952
- "This will, however, result in a much longer runtime per shortest path query."
2047
+ print_console(
2048
+ (
2049
+ "An error occurred while calculating the shortest path:\n"
2050
+ "This is likely caused by a disconnect in the graph.\n"
2051
+ "You can ensure a solution by setting destination_node_addition_type='all' and setting your lat_lon_bound=180.\n"
2052
+ "This will, however, result in a much longer runtime per shortest path query.\n"
2053
+ "If not in an exception block, see the stacktrace below for more details:\n"
2054
+ ),
2055
+ silent=silent,
1953
2056
  )
1954
- print("See the stacktrace below for more details:")
1955
2057
  raise e
1956
2058
 
1957
2059
  def distance_matrix(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes