scgraph 2.4.0__tar.gz → 2.4.1__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.
- {scgraph-2.4.0/scgraph.egg-info → scgraph-2.4.1}/PKG-INFO +22 -22
- {scgraph-2.4.0 → scgraph-2.4.1}/README.md +21 -21
- {scgraph-2.4.0 → scgraph-2.4.1}/pyproject.toml +1 -1
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph/__init__.py +24 -21
- {scgraph-2.4.0 → scgraph-2.4.1/scgraph.egg-info}/PKG-INFO +22 -22
- {scgraph-2.4.0 → scgraph-2.4.1}/setup.cfg +1 -1
- {scgraph-2.4.0 → scgraph-2.4.1}/LICENSE +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph/cache.py +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph/core.py +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph/geographs/__init__.py +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph/geographs/marnet.py +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph/geographs/north_america_rail.py +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph/geographs/oak_ridge_maritime.py +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph/geographs/us_freeway.py +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph/grid.py +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph/helpers/__init__.py +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph/helpers/shape_mover_utils.py +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph/spanning.py +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph/utils.py +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph.egg-info/SOURCES.txt +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph.egg-info/dependency_links.txt +0 -0
- {scgraph-2.4.0 → scgraph-2.4.1}/scgraph.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scgraph
|
|
3
|
-
Version: 2.4.
|
|
3
|
+
Version: 2.4.1
|
|
4
4
|
Summary: Determine an approximate route between two points on earth.
|
|
5
5
|
Author-email: Connor Makowski <conmak@mit.edu>
|
|
6
6
|
Project-URL: Homepage, https://github.com/connor-makowski/scgraph
|
|
@@ -57,7 +57,7 @@ Low Level: https://connor-makowski.github.io/scgraph/scgraph/core.html
|
|
|
57
57
|
- Grid based graphs
|
|
58
58
|
- Cached shortest path calculations for very fast repetative calculations to or from the same point in a graph.
|
|
59
59
|
- Note: Geographs are not yet supported for this feature
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
|
|
62
62
|
## Setup
|
|
63
63
|
|
|
@@ -73,7 +73,7 @@ pip install scgraph
|
|
|
73
73
|
|
|
74
74
|
## Use with Google Colab
|
|
75
75
|
|
|
76
|
-
- [Getting Started](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/getting_started.ipynb)
|
|
76
|
+
- [Getting Started](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/getting_started.ipynb)
|
|
77
77
|
- [Creating A Multi Path Geojson](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/multi_path_geojson.ipynb)
|
|
78
78
|
- [Modifying A Geograph](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/geograph_modifications.ipynb)
|
|
79
79
|
|
|
@@ -89,9 +89,9 @@ In this case, calculate the shortest maritime path between Shanghai, China and S
|
|
|
89
89
|
# Use a maritime network geograph
|
|
90
90
|
from scgraph.geographs.marnet import marnet_geograph
|
|
91
91
|
|
|
92
|
-
# Get the shortest path between
|
|
92
|
+
# Get the shortest path between
|
|
93
93
|
output = marnet_geograph.get_shortest_path(
|
|
94
|
-
origin_node={"latitude": 31.23,"longitude": 121.47},
|
|
94
|
+
origin_node={"latitude": 31.23,"longitude": 121.47},
|
|
95
95
|
destination_node={"latitude": 32.08,"longitude": -81.09},
|
|
96
96
|
output_units='km'
|
|
97
97
|
)
|
|
@@ -101,8 +101,8 @@ print('Length: ',output['length']) #=> Length: 19596.4653
|
|
|
101
101
|
In the above example, the `output` variable is a dictionary with three keys: `length` and `coordinate_path`.
|
|
102
102
|
|
|
103
103
|
- `length`: The distance between the passed origin and destination when traversing the graph along the shortest path
|
|
104
|
-
- Notes:
|
|
105
|
-
- This will be in the units specified by the `output_units` parameter.
|
|
104
|
+
- Notes:
|
|
105
|
+
- This will be in the units specified by the `output_units` parameter.
|
|
106
106
|
- `output_units` options:
|
|
107
107
|
- `km` (kilometers - default)
|
|
108
108
|
- `m` (meters)
|
|
@@ -149,7 +149,7 @@ For more examples including viewing the output on a map, see the [example notebo
|
|
|
149
149
|
|
|
150
150
|
Example:
|
|
151
151
|
- Create a grid of 20x100 cells.
|
|
152
|
-
- This creates a grid based graph with connections to all 8 neighbors for each grid item.
|
|
152
|
+
- This creates a grid based graph with connections to all 8 neighbors for each grid item.
|
|
153
153
|
- Each grid item has 4 cardinal connections at length 1 and 4 diagonal connections at length sqrt(2)
|
|
154
154
|
- Create a wall from (10,5) to (10,99).
|
|
155
155
|
- This would foce any path to go to the bottom of the graph to get around the wall.
|
|
@@ -177,7 +177,7 @@ output = gridGraph.get_shortest_path(
|
|
|
177
177
|
destination_node={"x": 18, "y": 10},
|
|
178
178
|
# Optional: Specify the output coodinate format (default is 'list_of_dicts)
|
|
179
179
|
output_coordinate_path="list_of_lists",
|
|
180
|
-
# Optional: Cache the origin point spanning_tree for faster calculations on future calls
|
|
180
|
+
# Optional: Cache the origin point spanning_tree for faster calculations on future calls
|
|
181
181
|
cache=True,
|
|
182
182
|
# Optional: Specify the node to cache the spanning tree for (default is the origin node)
|
|
183
183
|
# Note: This first call will be slower, but future calls using this origin node will be substantially faster
|
|
@@ -197,7 +197,7 @@ from scgraph_data.world_railways import world_railways_geograph
|
|
|
197
197
|
|
|
198
198
|
# Get the shortest path between Kalamazoo Michigan and Detroit Michigan by Train
|
|
199
199
|
output = world_railways_geograph.get_shortest_path(
|
|
200
|
-
origin_node={"latitude": 42.29,"longitude": -85.58},
|
|
200
|
+
origin_node={"latitude": 42.29,"longitude": -85.58},
|
|
201
201
|
destination_node={"latitude": 42.33,"longitude": -83.05}
|
|
202
202
|
)
|
|
203
203
|
```
|
|
@@ -210,7 +210,7 @@ from scgraph.utils import get_line_path
|
|
|
210
210
|
|
|
211
211
|
# Get the shortest sea path between Sri Lanka and Somalia
|
|
212
212
|
output = marnet_geograph.get_shortest_path(
|
|
213
|
-
origin_node={"latitude": 7.87,"longitude": 80.77},
|
|
213
|
+
origin_node={"latitude": 7.87,"longitude": 80.77},
|
|
214
214
|
destination_node={"latitude": 5.15,"longitude": 46.20}
|
|
215
215
|
)
|
|
216
216
|
# Write the output to a geojson file
|
|
@@ -226,7 +226,7 @@ You can specify your own custom graphs for direct access to the solving algorith
|
|
|
226
226
|
from scgraph import Graph
|
|
227
227
|
|
|
228
228
|
# Define an arbitrary graph
|
|
229
|
-
# See the graph definitions here:
|
|
229
|
+
# See the graph definitions here:
|
|
230
230
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
231
231
|
graph = [
|
|
232
232
|
{1: 5, 2: 1},
|
|
@@ -251,7 +251,7 @@ You can also use a slightly higher level `GeoGraph` class to work with latitude
|
|
|
251
251
|
from scgraph import GeoGraph
|
|
252
252
|
|
|
253
253
|
# Define nodes
|
|
254
|
-
# See the nodes definitions here:
|
|
254
|
+
# See the nodes definitions here:
|
|
255
255
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
256
256
|
nodes = [
|
|
257
257
|
# London
|
|
@@ -268,7 +268,7 @@ nodes = [
|
|
|
268
268
|
[38.7223, -9.1393]
|
|
269
269
|
]
|
|
270
270
|
# Define a graph
|
|
271
|
-
# See the graph definitions here:
|
|
271
|
+
# See the graph definitions here:
|
|
272
272
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
273
273
|
graph = [
|
|
274
274
|
# From London
|
|
@@ -279,9 +279,9 @@ graph = [
|
|
|
279
279
|
# From Paris
|
|
280
280
|
{
|
|
281
281
|
# To London
|
|
282
|
-
0: 311,
|
|
282
|
+
0: 311,
|
|
283
283
|
# To Berlin
|
|
284
|
-
2: 878,
|
|
284
|
+
2: 878,
|
|
285
285
|
# To Rome
|
|
286
286
|
3: 1439,
|
|
287
287
|
# To Madrid
|
|
@@ -289,7 +289,7 @@ graph = [
|
|
|
289
289
|
},
|
|
290
290
|
# From Berlin
|
|
291
291
|
{
|
|
292
|
-
# To Paris
|
|
292
|
+
# To Paris
|
|
293
293
|
1: 878,
|
|
294
294
|
# To Rome
|
|
295
295
|
3: 1181,
|
|
@@ -340,12 +340,12 @@ output = my_geograph.get_shortest_path(
|
|
|
340
340
|
)
|
|
341
341
|
print(output)
|
|
342
342
|
# {
|
|
343
|
-
# 'length': 1799.4323,
|
|
343
|
+
# 'length': 1799.4323,
|
|
344
344
|
# 'coordinate_path': [
|
|
345
|
-
# [52.4862, -1.8904],
|
|
346
|
-
# [51.5074, -0.1278],
|
|
347
|
-
# [48.8566, 2.3522],
|
|
348
|
-
# [40.4168, -3.7038],
|
|
345
|
+
# [52.4862, -1.8904],
|
|
346
|
+
# [51.5074, -0.1278],
|
|
347
|
+
# [48.8566, 2.3522],
|
|
348
|
+
# [40.4168, -3.7038],
|
|
349
349
|
# [41.6488, -0.8891]
|
|
350
350
|
# ]
|
|
351
351
|
# }
|
|
@@ -41,7 +41,7 @@ Low Level: https://connor-makowski.github.io/scgraph/scgraph/core.html
|
|
|
41
41
|
- Grid based graphs
|
|
42
42
|
- Cached shortest path calculations for very fast repetative calculations to or from the same point in a graph.
|
|
43
43
|
- Note: Geographs are not yet supported for this feature
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
|
|
46
46
|
## Setup
|
|
47
47
|
|
|
@@ -57,7 +57,7 @@ pip install scgraph
|
|
|
57
57
|
|
|
58
58
|
## Use with Google Colab
|
|
59
59
|
|
|
60
|
-
- [Getting Started](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/getting_started.ipynb)
|
|
60
|
+
- [Getting Started](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/getting_started.ipynb)
|
|
61
61
|
- [Creating A Multi Path Geojson](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/multi_path_geojson.ipynb)
|
|
62
62
|
- [Modifying A Geograph](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/geograph_modifications.ipynb)
|
|
63
63
|
|
|
@@ -73,9 +73,9 @@ In this case, calculate the shortest maritime path between Shanghai, China and S
|
|
|
73
73
|
# Use a maritime network geograph
|
|
74
74
|
from scgraph.geographs.marnet import marnet_geograph
|
|
75
75
|
|
|
76
|
-
# Get the shortest path between
|
|
76
|
+
# Get the shortest path between
|
|
77
77
|
output = marnet_geograph.get_shortest_path(
|
|
78
|
-
origin_node={"latitude": 31.23,"longitude": 121.47},
|
|
78
|
+
origin_node={"latitude": 31.23,"longitude": 121.47},
|
|
79
79
|
destination_node={"latitude": 32.08,"longitude": -81.09},
|
|
80
80
|
output_units='km'
|
|
81
81
|
)
|
|
@@ -85,8 +85,8 @@ print('Length: ',output['length']) #=> Length: 19596.4653
|
|
|
85
85
|
In the above example, the `output` variable is a dictionary with three keys: `length` and `coordinate_path`.
|
|
86
86
|
|
|
87
87
|
- `length`: The distance between the passed origin and destination when traversing the graph along the shortest path
|
|
88
|
-
- Notes:
|
|
89
|
-
- This will be in the units specified by the `output_units` parameter.
|
|
88
|
+
- Notes:
|
|
89
|
+
- This will be in the units specified by the `output_units` parameter.
|
|
90
90
|
- `output_units` options:
|
|
91
91
|
- `km` (kilometers - default)
|
|
92
92
|
- `m` (meters)
|
|
@@ -133,7 +133,7 @@ For more examples including viewing the output on a map, see the [example notebo
|
|
|
133
133
|
|
|
134
134
|
Example:
|
|
135
135
|
- Create a grid of 20x100 cells.
|
|
136
|
-
- This creates a grid based graph with connections to all 8 neighbors for each grid item.
|
|
136
|
+
- This creates a grid based graph with connections to all 8 neighbors for each grid item.
|
|
137
137
|
- Each grid item has 4 cardinal connections at length 1 and 4 diagonal connections at length sqrt(2)
|
|
138
138
|
- Create a wall from (10,5) to (10,99).
|
|
139
139
|
- This would foce any path to go to the bottom of the graph to get around the wall.
|
|
@@ -161,7 +161,7 @@ output = gridGraph.get_shortest_path(
|
|
|
161
161
|
destination_node={"x": 18, "y": 10},
|
|
162
162
|
# Optional: Specify the output coodinate format (default is 'list_of_dicts)
|
|
163
163
|
output_coordinate_path="list_of_lists",
|
|
164
|
-
# Optional: Cache the origin point spanning_tree for faster calculations on future calls
|
|
164
|
+
# Optional: Cache the origin point spanning_tree for faster calculations on future calls
|
|
165
165
|
cache=True,
|
|
166
166
|
# Optional: Specify the node to cache the spanning tree for (default is the origin node)
|
|
167
167
|
# Note: This first call will be slower, but future calls using this origin node will be substantially faster
|
|
@@ -181,7 +181,7 @@ from scgraph_data.world_railways import world_railways_geograph
|
|
|
181
181
|
|
|
182
182
|
# Get the shortest path between Kalamazoo Michigan and Detroit Michigan by Train
|
|
183
183
|
output = world_railways_geograph.get_shortest_path(
|
|
184
|
-
origin_node={"latitude": 42.29,"longitude": -85.58},
|
|
184
|
+
origin_node={"latitude": 42.29,"longitude": -85.58},
|
|
185
185
|
destination_node={"latitude": 42.33,"longitude": -83.05}
|
|
186
186
|
)
|
|
187
187
|
```
|
|
@@ -194,7 +194,7 @@ from scgraph.utils import get_line_path
|
|
|
194
194
|
|
|
195
195
|
# Get the shortest sea path between Sri Lanka and Somalia
|
|
196
196
|
output = marnet_geograph.get_shortest_path(
|
|
197
|
-
origin_node={"latitude": 7.87,"longitude": 80.77},
|
|
197
|
+
origin_node={"latitude": 7.87,"longitude": 80.77},
|
|
198
198
|
destination_node={"latitude": 5.15,"longitude": 46.20}
|
|
199
199
|
)
|
|
200
200
|
# Write the output to a geojson file
|
|
@@ -210,7 +210,7 @@ You can specify your own custom graphs for direct access to the solving algorith
|
|
|
210
210
|
from scgraph import Graph
|
|
211
211
|
|
|
212
212
|
# Define an arbitrary graph
|
|
213
|
-
# See the graph definitions here:
|
|
213
|
+
# See the graph definitions here:
|
|
214
214
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
215
215
|
graph = [
|
|
216
216
|
{1: 5, 2: 1},
|
|
@@ -235,7 +235,7 @@ You can also use a slightly higher level `GeoGraph` class to work with latitude
|
|
|
235
235
|
from scgraph import GeoGraph
|
|
236
236
|
|
|
237
237
|
# Define nodes
|
|
238
|
-
# See the nodes definitions here:
|
|
238
|
+
# See the nodes definitions here:
|
|
239
239
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
240
240
|
nodes = [
|
|
241
241
|
# London
|
|
@@ -252,7 +252,7 @@ nodes = [
|
|
|
252
252
|
[38.7223, -9.1393]
|
|
253
253
|
]
|
|
254
254
|
# Define a graph
|
|
255
|
-
# See the graph definitions here:
|
|
255
|
+
# See the graph definitions here:
|
|
256
256
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
257
257
|
graph = [
|
|
258
258
|
# From London
|
|
@@ -263,9 +263,9 @@ graph = [
|
|
|
263
263
|
# From Paris
|
|
264
264
|
{
|
|
265
265
|
# To London
|
|
266
|
-
0: 311,
|
|
266
|
+
0: 311,
|
|
267
267
|
# To Berlin
|
|
268
|
-
2: 878,
|
|
268
|
+
2: 878,
|
|
269
269
|
# To Rome
|
|
270
270
|
3: 1439,
|
|
271
271
|
# To Madrid
|
|
@@ -273,7 +273,7 @@ graph = [
|
|
|
273
273
|
},
|
|
274
274
|
# From Berlin
|
|
275
275
|
{
|
|
276
|
-
# To Paris
|
|
276
|
+
# To Paris
|
|
277
277
|
1: 878,
|
|
278
278
|
# To Rome
|
|
279
279
|
3: 1181,
|
|
@@ -324,12 +324,12 @@ output = my_geograph.get_shortest_path(
|
|
|
324
324
|
)
|
|
325
325
|
print(output)
|
|
326
326
|
# {
|
|
327
|
-
# 'length': 1799.4323,
|
|
327
|
+
# 'length': 1799.4323,
|
|
328
328
|
# 'coordinate_path': [
|
|
329
|
-
# [52.4862, -1.8904],
|
|
330
|
-
# [51.5074, -0.1278],
|
|
331
|
-
# [48.8566, 2.3522],
|
|
332
|
-
# [40.4168, -3.7038],
|
|
329
|
+
# [52.4862, -1.8904],
|
|
330
|
+
# [51.5074, -0.1278],
|
|
331
|
+
# [48.8566, 2.3522],
|
|
332
|
+
# [40.4168, -3.7038],
|
|
333
333
|
# [41.6488, -0.8891]
|
|
334
334
|
# ]
|
|
335
335
|
# }
|
|
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
|
|
|
12
12
|
|
|
13
13
|
[project]
|
|
14
14
|
name = "scgraph"
|
|
15
|
-
version = "2.4.
|
|
15
|
+
version = "2.4.1"
|
|
16
16
|
description = "Determine an approximate route between two points on earth."
|
|
17
17
|
authors = [
|
|
18
18
|
{name="Connor Makowski", email="conmak@mit.edu"}
|
|
@@ -42,7 +42,7 @@ Low Level: https://connor-makowski.github.io/scgraph/scgraph/core.html
|
|
|
42
42
|
- Grid based graphs
|
|
43
43
|
- Cached shortest path calculations for very fast repetative calculations to or from the same point in a graph.
|
|
44
44
|
- Note: Geographs are not yet supported for this feature
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
|
|
47
47
|
## Setup
|
|
48
48
|
|
|
@@ -58,7 +58,7 @@ pip install scgraph
|
|
|
58
58
|
|
|
59
59
|
## Use with Google Colab
|
|
60
60
|
|
|
61
|
-
- [Getting Started](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/getting_started.ipynb)
|
|
61
|
+
- [Getting Started](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/getting_started.ipynb)
|
|
62
62
|
- [Creating A Multi Path Geojson](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/multi_path_geojson.ipynb)
|
|
63
63
|
- [Modifying A Geograph](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/geograph_modifications.ipynb)
|
|
64
64
|
|
|
@@ -74,9 +74,9 @@ In this case, calculate the shortest maritime path between Shanghai, China and S
|
|
|
74
74
|
# Use a maritime network geograph
|
|
75
75
|
from scgraph.geographs.marnet import marnet_geograph
|
|
76
76
|
|
|
77
|
-
# Get the shortest path between
|
|
77
|
+
# Get the shortest path between
|
|
78
78
|
output = marnet_geograph.get_shortest_path(
|
|
79
|
-
origin_node={"latitude": 31.23,"longitude": 121.47},
|
|
79
|
+
origin_node={"latitude": 31.23,"longitude": 121.47},
|
|
80
80
|
destination_node={"latitude": 32.08,"longitude": -81.09},
|
|
81
81
|
output_units='km'
|
|
82
82
|
)
|
|
@@ -86,8 +86,8 @@ print('Length: ',output['length']) #=> Length: 19596.4653
|
|
|
86
86
|
In the above example, the `output` variable is a dictionary with three keys: `length` and `coordinate_path`.
|
|
87
87
|
|
|
88
88
|
- `length`: The distance between the passed origin and destination when traversing the graph along the shortest path
|
|
89
|
-
- Notes:
|
|
90
|
-
- This will be in the units specified by the `output_units` parameter.
|
|
89
|
+
- Notes:
|
|
90
|
+
- This will be in the units specified by the `output_units` parameter.
|
|
91
91
|
- `output_units` options:
|
|
92
92
|
- `km` (kilometers - default)
|
|
93
93
|
- `m` (meters)
|
|
@@ -134,7 +134,7 @@ For more examples including viewing the output on a map, see the [example notebo
|
|
|
134
134
|
|
|
135
135
|
Example:
|
|
136
136
|
- Create a grid of 20x100 cells.
|
|
137
|
-
- This creates a grid based graph with connections to all 8 neighbors for each grid item.
|
|
137
|
+
- This creates a grid based graph with connections to all 8 neighbors for each grid item.
|
|
138
138
|
- Each grid item has 4 cardinal connections at length 1 and 4 diagonal connections at length sqrt(2)
|
|
139
139
|
- Create a wall from (10,5) to (10,99).
|
|
140
140
|
- This would foce any path to go to the bottom of the graph to get around the wall.
|
|
@@ -162,7 +162,7 @@ output = gridGraph.get_shortest_path(
|
|
|
162
162
|
destination_node={"x": 18, "y": 10},
|
|
163
163
|
# Optional: Specify the output coodinate format (default is 'list_of_dicts)
|
|
164
164
|
output_coordinate_path="list_of_lists",
|
|
165
|
-
# Optional: Cache the origin point spanning_tree for faster calculations on future calls
|
|
165
|
+
# Optional: Cache the origin point spanning_tree for faster calculations on future calls
|
|
166
166
|
cache=True,
|
|
167
167
|
# Optional: Specify the node to cache the spanning tree for (default is the origin node)
|
|
168
168
|
# Note: This first call will be slower, but future calls using this origin node will be substantially faster
|
|
@@ -182,7 +182,7 @@ from scgraph_data.world_railways import world_railways_geograph
|
|
|
182
182
|
|
|
183
183
|
# Get the shortest path between Kalamazoo Michigan and Detroit Michigan by Train
|
|
184
184
|
output = world_railways_geograph.get_shortest_path(
|
|
185
|
-
origin_node={"latitude": 42.29,"longitude": -85.58},
|
|
185
|
+
origin_node={"latitude": 42.29,"longitude": -85.58},
|
|
186
186
|
destination_node={"latitude": 42.33,"longitude": -83.05}
|
|
187
187
|
)
|
|
188
188
|
```
|
|
@@ -195,7 +195,7 @@ from scgraph.utils import get_line_path
|
|
|
195
195
|
|
|
196
196
|
# Get the shortest sea path between Sri Lanka and Somalia
|
|
197
197
|
output = marnet_geograph.get_shortest_path(
|
|
198
|
-
origin_node={"latitude": 7.87,"longitude": 80.77},
|
|
198
|
+
origin_node={"latitude": 7.87,"longitude": 80.77},
|
|
199
199
|
destination_node={"latitude": 5.15,"longitude": 46.20}
|
|
200
200
|
)
|
|
201
201
|
# Write the output to a geojson file
|
|
@@ -211,7 +211,7 @@ You can specify your own custom graphs for direct access to the solving algorith
|
|
|
211
211
|
from scgraph import Graph
|
|
212
212
|
|
|
213
213
|
# Define an arbitrary graph
|
|
214
|
-
# See the graph definitions here:
|
|
214
|
+
# See the graph definitions here:
|
|
215
215
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
216
216
|
graph = [
|
|
217
217
|
{1: 5, 2: 1},
|
|
@@ -236,7 +236,7 @@ You can also use a slightly higher level `GeoGraph` class to work with latitude
|
|
|
236
236
|
from scgraph import GeoGraph
|
|
237
237
|
|
|
238
238
|
# Define nodes
|
|
239
|
-
# See the nodes definitions here:
|
|
239
|
+
# See the nodes definitions here:
|
|
240
240
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
241
241
|
nodes = [
|
|
242
242
|
# London
|
|
@@ -253,7 +253,7 @@ nodes = [
|
|
|
253
253
|
[38.7223, -9.1393]
|
|
254
254
|
]
|
|
255
255
|
# Define a graph
|
|
256
|
-
# See the graph definitions here:
|
|
256
|
+
# See the graph definitions here:
|
|
257
257
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
258
258
|
graph = [
|
|
259
259
|
# From London
|
|
@@ -264,9 +264,9 @@ graph = [
|
|
|
264
264
|
# From Paris
|
|
265
265
|
{
|
|
266
266
|
# To London
|
|
267
|
-
0: 311,
|
|
267
|
+
0: 311,
|
|
268
268
|
# To Berlin
|
|
269
|
-
2: 878,
|
|
269
|
+
2: 878,
|
|
270
270
|
# To Rome
|
|
271
271
|
3: 1439,
|
|
272
272
|
# To Madrid
|
|
@@ -274,7 +274,7 @@ graph = [
|
|
|
274
274
|
},
|
|
275
275
|
# From Berlin
|
|
276
276
|
{
|
|
277
|
-
# To Paris
|
|
277
|
+
# To Paris
|
|
278
278
|
1: 878,
|
|
279
279
|
# To Rome
|
|
280
280
|
3: 1181,
|
|
@@ -325,12 +325,12 @@ output = my_geograph.get_shortest_path(
|
|
|
325
325
|
)
|
|
326
326
|
print(output)
|
|
327
327
|
# {
|
|
328
|
-
# 'length': 1799.4323,
|
|
328
|
+
# 'length': 1799.4323,
|
|
329
329
|
# 'coordinate_path': [
|
|
330
|
-
# [52.4862, -1.8904],
|
|
331
|
-
# [51.5074, -0.1278],
|
|
332
|
-
# [48.8566, 2.3522],
|
|
333
|
-
# [40.4168, -3.7038],
|
|
330
|
+
# [52.4862, -1.8904],
|
|
331
|
+
# [51.5074, -0.1278],
|
|
332
|
+
# [48.8566, 2.3522],
|
|
333
|
+
# [40.4168, -3.7038],
|
|
334
334
|
# [41.6488, -0.8891]
|
|
335
335
|
# ]
|
|
336
336
|
# }
|
|
@@ -356,3 +356,6 @@ Make sure Docker is installed and running on a Unix system (Linux, MacOS, WSL2).
|
|
|
356
356
|
|
|
357
357
|
## Attributions and Thanks
|
|
358
358
|
Originally inspired by [searoute](https://github.com/genthalili/searoute-py) including the use of one of their [datasets](https://github.com/genthalili/searoute-py/blob/main/searoute/data/marnet_densified_v2_old.geojson) that has been modified to work properly with this package."""
|
|
359
|
+
|
|
360
|
+
from .core import Graph, GeoGraph
|
|
361
|
+
from .grid import GridGraph
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scgraph
|
|
3
|
-
Version: 2.4.
|
|
3
|
+
Version: 2.4.1
|
|
4
4
|
Summary: Determine an approximate route between two points on earth.
|
|
5
5
|
Author-email: Connor Makowski <conmak@mit.edu>
|
|
6
6
|
Project-URL: Homepage, https://github.com/connor-makowski/scgraph
|
|
@@ -57,7 +57,7 @@ Low Level: https://connor-makowski.github.io/scgraph/scgraph/core.html
|
|
|
57
57
|
- Grid based graphs
|
|
58
58
|
- Cached shortest path calculations for very fast repetative calculations to or from the same point in a graph.
|
|
59
59
|
- Note: Geographs are not yet supported for this feature
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
|
|
62
62
|
## Setup
|
|
63
63
|
|
|
@@ -73,7 +73,7 @@ pip install scgraph
|
|
|
73
73
|
|
|
74
74
|
## Use with Google Colab
|
|
75
75
|
|
|
76
|
-
- [Getting Started](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/getting_started.ipynb)
|
|
76
|
+
- [Getting Started](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/getting_started.ipynb)
|
|
77
77
|
- [Creating A Multi Path Geojson](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/multi_path_geojson.ipynb)
|
|
78
78
|
- [Modifying A Geograph](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/geograph_modifications.ipynb)
|
|
79
79
|
|
|
@@ -89,9 +89,9 @@ In this case, calculate the shortest maritime path between Shanghai, China and S
|
|
|
89
89
|
# Use a maritime network geograph
|
|
90
90
|
from scgraph.geographs.marnet import marnet_geograph
|
|
91
91
|
|
|
92
|
-
# Get the shortest path between
|
|
92
|
+
# Get the shortest path between
|
|
93
93
|
output = marnet_geograph.get_shortest_path(
|
|
94
|
-
origin_node={"latitude": 31.23,"longitude": 121.47},
|
|
94
|
+
origin_node={"latitude": 31.23,"longitude": 121.47},
|
|
95
95
|
destination_node={"latitude": 32.08,"longitude": -81.09},
|
|
96
96
|
output_units='km'
|
|
97
97
|
)
|
|
@@ -101,8 +101,8 @@ print('Length: ',output['length']) #=> Length: 19596.4653
|
|
|
101
101
|
In the above example, the `output` variable is a dictionary with three keys: `length` and `coordinate_path`.
|
|
102
102
|
|
|
103
103
|
- `length`: The distance between the passed origin and destination when traversing the graph along the shortest path
|
|
104
|
-
- Notes:
|
|
105
|
-
- This will be in the units specified by the `output_units` parameter.
|
|
104
|
+
- Notes:
|
|
105
|
+
- This will be in the units specified by the `output_units` parameter.
|
|
106
106
|
- `output_units` options:
|
|
107
107
|
- `km` (kilometers - default)
|
|
108
108
|
- `m` (meters)
|
|
@@ -149,7 +149,7 @@ For more examples including viewing the output on a map, see the [example notebo
|
|
|
149
149
|
|
|
150
150
|
Example:
|
|
151
151
|
- Create a grid of 20x100 cells.
|
|
152
|
-
- This creates a grid based graph with connections to all 8 neighbors for each grid item.
|
|
152
|
+
- This creates a grid based graph with connections to all 8 neighbors for each grid item.
|
|
153
153
|
- Each grid item has 4 cardinal connections at length 1 and 4 diagonal connections at length sqrt(2)
|
|
154
154
|
- Create a wall from (10,5) to (10,99).
|
|
155
155
|
- This would foce any path to go to the bottom of the graph to get around the wall.
|
|
@@ -177,7 +177,7 @@ output = gridGraph.get_shortest_path(
|
|
|
177
177
|
destination_node={"x": 18, "y": 10},
|
|
178
178
|
# Optional: Specify the output coodinate format (default is 'list_of_dicts)
|
|
179
179
|
output_coordinate_path="list_of_lists",
|
|
180
|
-
# Optional: Cache the origin point spanning_tree for faster calculations on future calls
|
|
180
|
+
# Optional: Cache the origin point spanning_tree for faster calculations on future calls
|
|
181
181
|
cache=True,
|
|
182
182
|
# Optional: Specify the node to cache the spanning tree for (default is the origin node)
|
|
183
183
|
# Note: This first call will be slower, but future calls using this origin node will be substantially faster
|
|
@@ -197,7 +197,7 @@ from scgraph_data.world_railways import world_railways_geograph
|
|
|
197
197
|
|
|
198
198
|
# Get the shortest path between Kalamazoo Michigan and Detroit Michigan by Train
|
|
199
199
|
output = world_railways_geograph.get_shortest_path(
|
|
200
|
-
origin_node={"latitude": 42.29,"longitude": -85.58},
|
|
200
|
+
origin_node={"latitude": 42.29,"longitude": -85.58},
|
|
201
201
|
destination_node={"latitude": 42.33,"longitude": -83.05}
|
|
202
202
|
)
|
|
203
203
|
```
|
|
@@ -210,7 +210,7 @@ from scgraph.utils import get_line_path
|
|
|
210
210
|
|
|
211
211
|
# Get the shortest sea path between Sri Lanka and Somalia
|
|
212
212
|
output = marnet_geograph.get_shortest_path(
|
|
213
|
-
origin_node={"latitude": 7.87,"longitude": 80.77},
|
|
213
|
+
origin_node={"latitude": 7.87,"longitude": 80.77},
|
|
214
214
|
destination_node={"latitude": 5.15,"longitude": 46.20}
|
|
215
215
|
)
|
|
216
216
|
# Write the output to a geojson file
|
|
@@ -226,7 +226,7 @@ You can specify your own custom graphs for direct access to the solving algorith
|
|
|
226
226
|
from scgraph import Graph
|
|
227
227
|
|
|
228
228
|
# Define an arbitrary graph
|
|
229
|
-
# See the graph definitions here:
|
|
229
|
+
# See the graph definitions here:
|
|
230
230
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
231
231
|
graph = [
|
|
232
232
|
{1: 5, 2: 1},
|
|
@@ -251,7 +251,7 @@ You can also use a slightly higher level `GeoGraph` class to work with latitude
|
|
|
251
251
|
from scgraph import GeoGraph
|
|
252
252
|
|
|
253
253
|
# Define nodes
|
|
254
|
-
# See the nodes definitions here:
|
|
254
|
+
# See the nodes definitions here:
|
|
255
255
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
256
256
|
nodes = [
|
|
257
257
|
# London
|
|
@@ -268,7 +268,7 @@ nodes = [
|
|
|
268
268
|
[38.7223, -9.1393]
|
|
269
269
|
]
|
|
270
270
|
# Define a graph
|
|
271
|
-
# See the graph definitions here:
|
|
271
|
+
# See the graph definitions here:
|
|
272
272
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
273
273
|
graph = [
|
|
274
274
|
# From London
|
|
@@ -279,9 +279,9 @@ graph = [
|
|
|
279
279
|
# From Paris
|
|
280
280
|
{
|
|
281
281
|
# To London
|
|
282
|
-
0: 311,
|
|
282
|
+
0: 311,
|
|
283
283
|
# To Berlin
|
|
284
|
-
2: 878,
|
|
284
|
+
2: 878,
|
|
285
285
|
# To Rome
|
|
286
286
|
3: 1439,
|
|
287
287
|
# To Madrid
|
|
@@ -289,7 +289,7 @@ graph = [
|
|
|
289
289
|
},
|
|
290
290
|
# From Berlin
|
|
291
291
|
{
|
|
292
|
-
# To Paris
|
|
292
|
+
# To Paris
|
|
293
293
|
1: 878,
|
|
294
294
|
# To Rome
|
|
295
295
|
3: 1181,
|
|
@@ -340,12 +340,12 @@ output = my_geograph.get_shortest_path(
|
|
|
340
340
|
)
|
|
341
341
|
print(output)
|
|
342
342
|
# {
|
|
343
|
-
# 'length': 1799.4323,
|
|
343
|
+
# 'length': 1799.4323,
|
|
344
344
|
# 'coordinate_path': [
|
|
345
|
-
# [52.4862, -1.8904],
|
|
346
|
-
# [51.5074, -0.1278],
|
|
347
|
-
# [48.8566, 2.3522],
|
|
348
|
-
# [40.4168, -3.7038],
|
|
345
|
+
# [52.4862, -1.8904],
|
|
346
|
+
# [51.5074, -0.1278],
|
|
347
|
+
# [48.8566, 2.3522],
|
|
348
|
+
# [40.4168, -3.7038],
|
|
349
349
|
# [41.6488, -0.8891]
|
|
350
350
|
# ]
|
|
351
351
|
# }
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|