scgraph 2.3.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.3.0/scgraph.egg-info → scgraph-2.4.1}/PKG-INFO +86 -22
- {scgraph-2.3.0 → scgraph-2.4.1}/README.md +83 -20
- {scgraph-2.3.0 → scgraph-2.4.1}/pyproject.toml +1 -1
- scgraph-2.4.1/scgraph/__init__.py +361 -0
- scgraph-2.4.1/scgraph/cache.py +79 -0
- {scgraph-2.3.0 → scgraph-2.4.1}/scgraph/core.py +26 -26
- scgraph-2.4.1/scgraph/grid.py +421 -0
- scgraph-2.4.1/scgraph/helpers/__init__.py +0 -0
- scgraph-2.4.1/scgraph/helpers/shape_mover_utils.py +319 -0
- scgraph-2.4.1/scgraph/spanning.py +123 -0
- {scgraph-2.3.0 → scgraph-2.4.1}/scgraph/utils.py +5 -5
- {scgraph-2.3.0 → scgraph-2.4.1/scgraph.egg-info}/PKG-INFO +86 -22
- {scgraph-2.3.0 → scgraph-2.4.1}/scgraph.egg-info/SOURCES.txt +6 -1
- {scgraph-2.3.0 → scgraph-2.4.1}/setup.cfg +1 -1
- scgraph-2.3.0/scgraph/__init__.py +0 -1
- {scgraph-2.3.0 → scgraph-2.4.1}/LICENSE +0 -0
- {scgraph-2.3.0 → scgraph-2.4.1}/scgraph/geographs/__init__.py +0 -0
- {scgraph-2.3.0 → scgraph-2.4.1}/scgraph/geographs/marnet.py +0 -0
- {scgraph-2.3.0 → scgraph-2.4.1}/scgraph/geographs/north_america_rail.py +0 -0
- {scgraph-2.3.0 → scgraph-2.4.1}/scgraph/geographs/oak_ridge_maritime.py +0 -0
- {scgraph-2.3.0 → scgraph-2.4.1}/scgraph/geographs/us_freeway.py +0 -0
- {scgraph-2.3.0 → scgraph-2.4.1}/scgraph.egg-info/dependency_links.txt +0 -0
- {scgraph-2.3.0 → scgraph-2.4.1}/scgraph.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: scgraph
|
|
3
|
-
Version: 2.
|
|
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
|
|
@@ -12,10 +12,12 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Requires-Python: >=3.10
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
|
+
Dynamic: license-file
|
|
15
16
|
|
|
16
17
|
# scgraph
|
|
17
18
|
[](https://badge.fury.io/py/scgraph)
|
|
18
19
|
[](https://opensource.org/licenses/MIT)
|
|
20
|
+
[](https://pypi.org/project/scgraph/)
|
|
19
21
|
|
|
20
22
|
Supply chain graph package for Python
|
|
21
23
|
|
|
@@ -52,14 +54,16 @@ Low Level: https://connor-makowski.github.io/scgraph/scgraph/core.html
|
|
|
52
54
|
- Antimeridian support
|
|
53
55
|
- Arbitrary start and end points
|
|
54
56
|
- Arbitrary network data sets
|
|
55
|
-
|
|
57
|
+
- Grid based graphs
|
|
58
|
+
- Cached shortest path calculations for very fast repetative calculations to or from the same point in a graph.
|
|
59
|
+
- Note: Geographs are not yet supported for this feature
|
|
56
60
|
|
|
57
61
|
|
|
58
62
|
## Setup
|
|
59
63
|
|
|
60
64
|
Make sure you have Python 3.10.x (or higher) installed on your system. You can download it [here](https://www.python.org/downloads/).
|
|
61
65
|
|
|
62
|
-
Support for python3.6-
|
|
66
|
+
Note: Support for python3.6-python3.9 is available up to version 2.2.0.
|
|
63
67
|
|
|
64
68
|
## Installation
|
|
65
69
|
|
|
@@ -69,7 +73,7 @@ pip install scgraph
|
|
|
69
73
|
|
|
70
74
|
## Use with Google Colab
|
|
71
75
|
|
|
72
|
-
- [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)
|
|
73
77
|
- [Creating A Multi Path Geojson](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/multi_path_geojson.ipynb)
|
|
74
78
|
- [Modifying A Geograph](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/geograph_modifications.ipynb)
|
|
75
79
|
|
|
@@ -85,9 +89,9 @@ In this case, calculate the shortest maritime path between Shanghai, China and S
|
|
|
85
89
|
# Use a maritime network geograph
|
|
86
90
|
from scgraph.geographs.marnet import marnet_geograph
|
|
87
91
|
|
|
88
|
-
# Get the shortest path between
|
|
92
|
+
# Get the shortest path between
|
|
89
93
|
output = marnet_geograph.get_shortest_path(
|
|
90
|
-
origin_node={"latitude": 31.23,"longitude": 121.47},
|
|
94
|
+
origin_node={"latitude": 31.23,"longitude": 121.47},
|
|
91
95
|
destination_node={"latitude": 32.08,"longitude": -81.09},
|
|
92
96
|
output_units='km'
|
|
93
97
|
)
|
|
@@ -97,8 +101,8 @@ print('Length: ',output['length']) #=> Length: 19596.4653
|
|
|
97
101
|
In the above example, the `output` variable is a dictionary with three keys: `length` and `coordinate_path`.
|
|
98
102
|
|
|
99
103
|
- `length`: The distance between the passed origin and destination when traversing the graph along the shortest path
|
|
100
|
-
- Notes:
|
|
101
|
-
- 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.
|
|
102
106
|
- `output_units` options:
|
|
103
107
|
- `km` (kilometers - default)
|
|
104
108
|
- `m` (meters)
|
|
@@ -141,6 +145,49 @@ For more examples including viewing the output on a map, see the [example notebo
|
|
|
141
145
|
- Use: `from scgraph_data.world_highways import world_highways_geograph`
|
|
142
146
|
- See: [scgraph_data](https://github.com/connor-makowski/scgraph_data) for more information and all available geographs.
|
|
143
147
|
|
|
148
|
+
## GridGraph usage
|
|
149
|
+
|
|
150
|
+
Example:
|
|
151
|
+
- Create a grid of 20x100 cells.
|
|
152
|
+
- This creates a grid based graph with connections to all 8 neighbors for each grid item.
|
|
153
|
+
- Each grid item has 4 cardinal connections at length 1 and 4 diagonal connections at length sqrt(2)
|
|
154
|
+
- Create a wall from (10,5) to (10,99).
|
|
155
|
+
- This would foce any path to go to the bottom of the graph to get around the wall.
|
|
156
|
+
- Get the shortest path between (2,10) and (18,10)
|
|
157
|
+
- Note: The length of this path should be 16 without the wall and 20.9704 with the wall.
|
|
158
|
+
|
|
159
|
+
```py
|
|
160
|
+
from scgraph import GridGraph
|
|
161
|
+
|
|
162
|
+
x_size = 20
|
|
163
|
+
y_size = 20
|
|
164
|
+
blocks = [(10, i) for i in range(5, y_size)]
|
|
165
|
+
|
|
166
|
+
# Create the GridGraph object
|
|
167
|
+
gridGraph = GridGraph(
|
|
168
|
+
x_size=x_size,
|
|
169
|
+
y_size=y_size,
|
|
170
|
+
blocks=blocks,
|
|
171
|
+
add_exterior_walls=True,
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
# Solve the shortest path between two points
|
|
175
|
+
output = gridGraph.get_shortest_path(
|
|
176
|
+
origin_node={"x": 2, "y": 10},
|
|
177
|
+
destination_node={"x": 18, "y": 10},
|
|
178
|
+
# Optional: Specify the output coodinate format (default is 'list_of_dicts)
|
|
179
|
+
output_coordinate_path="list_of_lists",
|
|
180
|
+
# Optional: Cache the origin point spanning_tree for faster calculations on future calls
|
|
181
|
+
cache=True,
|
|
182
|
+
# Optional: Specify the node to cache the spanning tree for (default is the origin node)
|
|
183
|
+
# Note: This first call will be slower, but future calls using this origin node will be substantially faster
|
|
184
|
+
cache_for="origin",
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
print(output)
|
|
188
|
+
#=> {'length': 20.9704, 'coordinate_path': [[2, 10], [3, 9], [4, 8], [5, 8], [6, 7], [7, 6], [8, 5], [9, 4], [10, 4], [11, 4], [12, 5], [13, 6], [14, 7], [15, 7], [16, 8], [17, 9], [18, 10]]}
|
|
189
|
+
```
|
|
190
|
+
|
|
144
191
|
## Advanced Usage
|
|
145
192
|
|
|
146
193
|
Using `scgraph_data` geographs:
|
|
@@ -150,7 +197,7 @@ from scgraph_data.world_railways import world_railways_geograph
|
|
|
150
197
|
|
|
151
198
|
# Get the shortest path between Kalamazoo Michigan and Detroit Michigan by Train
|
|
152
199
|
output = world_railways_geograph.get_shortest_path(
|
|
153
|
-
origin_node={"latitude": 42.29,"longitude": -85.58},
|
|
200
|
+
origin_node={"latitude": 42.29,"longitude": -85.58},
|
|
154
201
|
destination_node={"latitude": 42.33,"longitude": -83.05}
|
|
155
202
|
)
|
|
156
203
|
```
|
|
@@ -163,7 +210,7 @@ from scgraph.utils import get_line_path
|
|
|
163
210
|
|
|
164
211
|
# Get the shortest sea path between Sri Lanka and Somalia
|
|
165
212
|
output = marnet_geograph.get_shortest_path(
|
|
166
|
-
origin_node={"latitude": 7.87,"longitude": 80.77},
|
|
213
|
+
origin_node={"latitude": 7.87,"longitude": 80.77},
|
|
167
214
|
destination_node={"latitude": 5.15,"longitude": 46.20}
|
|
168
215
|
)
|
|
169
216
|
# Write the output to a geojson file
|
|
@@ -179,7 +226,7 @@ You can specify your own custom graphs for direct access to the solving algorith
|
|
|
179
226
|
from scgraph import Graph
|
|
180
227
|
|
|
181
228
|
# Define an arbitrary graph
|
|
182
|
-
# See the graph definitions here:
|
|
229
|
+
# See the graph definitions here:
|
|
183
230
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
184
231
|
graph = [
|
|
185
232
|
{1: 5, 2: 1},
|
|
@@ -204,7 +251,7 @@ You can also use a slightly higher level `GeoGraph` class to work with latitude
|
|
|
204
251
|
from scgraph import GeoGraph
|
|
205
252
|
|
|
206
253
|
# Define nodes
|
|
207
|
-
# See the nodes definitions here:
|
|
254
|
+
# See the nodes definitions here:
|
|
208
255
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
209
256
|
nodes = [
|
|
210
257
|
# London
|
|
@@ -221,7 +268,7 @@ nodes = [
|
|
|
221
268
|
[38.7223, -9.1393]
|
|
222
269
|
]
|
|
223
270
|
# Define a graph
|
|
224
|
-
# See the graph definitions here:
|
|
271
|
+
# See the graph definitions here:
|
|
225
272
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
226
273
|
graph = [
|
|
227
274
|
# From London
|
|
@@ -232,9 +279,9 @@ graph = [
|
|
|
232
279
|
# From Paris
|
|
233
280
|
{
|
|
234
281
|
# To London
|
|
235
|
-
0: 311,
|
|
282
|
+
0: 311,
|
|
236
283
|
# To Berlin
|
|
237
|
-
2: 878,
|
|
284
|
+
2: 878,
|
|
238
285
|
# To Rome
|
|
239
286
|
3: 1439,
|
|
240
287
|
# To Madrid
|
|
@@ -242,7 +289,7 @@ graph = [
|
|
|
242
289
|
},
|
|
243
290
|
# From Berlin
|
|
244
291
|
{
|
|
245
|
-
# To Paris
|
|
292
|
+
# To Paris
|
|
246
293
|
1: 878,
|
|
247
294
|
# To Rome
|
|
248
295
|
3: 1181,
|
|
@@ -293,17 +340,34 @@ output = my_geograph.get_shortest_path(
|
|
|
293
340
|
)
|
|
294
341
|
print(output)
|
|
295
342
|
# {
|
|
296
|
-
# 'length': 1799.4323,
|
|
343
|
+
# 'length': 1799.4323,
|
|
297
344
|
# 'coordinate_path': [
|
|
298
|
-
# [52.4862, -1.8904],
|
|
299
|
-
# [51.5074, -0.1278],
|
|
300
|
-
# [48.8566, 2.3522],
|
|
301
|
-
# [40.4168, -3.7038],
|
|
345
|
+
# [52.4862, -1.8904],
|
|
346
|
+
# [51.5074, -0.1278],
|
|
347
|
+
# [48.8566, 2.3522],
|
|
348
|
+
# [40.4168, -3.7038],
|
|
302
349
|
# [41.6488, -0.8891]
|
|
303
350
|
# ]
|
|
304
351
|
# }
|
|
305
352
|
|
|
306
353
|
```
|
|
307
354
|
|
|
355
|
+
# Development
|
|
356
|
+
## Running Tests, Prettifying Code, and Updating Docs
|
|
357
|
+
|
|
358
|
+
Make sure Docker is installed and running on a Unix system (Linux, MacOS, WSL2).
|
|
359
|
+
|
|
360
|
+
- Create a docker container and drop into a shell
|
|
361
|
+
- `./run.sh`
|
|
362
|
+
- Run all tests (see ./utils/test.sh)
|
|
363
|
+
- `./run.sh test`
|
|
364
|
+
- Prettify the code (see ./utils/prettify.sh)
|
|
365
|
+
- `./run.sh prettify`
|
|
366
|
+
- Update the docs (see ./utils/docs.sh)
|
|
367
|
+
- `./run.sh docs`
|
|
368
|
+
|
|
369
|
+
- Note: You can and should modify the `Dockerfile` to test different python versions.
|
|
370
|
+
|
|
371
|
+
|
|
308
372
|
## Attributions and Thanks
|
|
309
373
|
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.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# scgraph
|
|
2
2
|
[](https://badge.fury.io/py/scgraph)
|
|
3
3
|
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://pypi.org/project/scgraph/)
|
|
4
5
|
|
|
5
6
|
Supply chain graph package for Python
|
|
6
7
|
|
|
@@ -37,14 +38,16 @@ Low Level: https://connor-makowski.github.io/scgraph/scgraph/core.html
|
|
|
37
38
|
- Antimeridian support
|
|
38
39
|
- Arbitrary start and end points
|
|
39
40
|
- Arbitrary network data sets
|
|
40
|
-
|
|
41
|
+
- Grid based graphs
|
|
42
|
+
- Cached shortest path calculations for very fast repetative calculations to or from the same point in a graph.
|
|
43
|
+
- Note: Geographs are not yet supported for this feature
|
|
41
44
|
|
|
42
45
|
|
|
43
46
|
## Setup
|
|
44
47
|
|
|
45
48
|
Make sure you have Python 3.10.x (or higher) installed on your system. You can download it [here](https://www.python.org/downloads/).
|
|
46
49
|
|
|
47
|
-
Support for python3.6-
|
|
50
|
+
Note: Support for python3.6-python3.9 is available up to version 2.2.0.
|
|
48
51
|
|
|
49
52
|
## Installation
|
|
50
53
|
|
|
@@ -54,7 +57,7 @@ pip install scgraph
|
|
|
54
57
|
|
|
55
58
|
## Use with Google Colab
|
|
56
59
|
|
|
57
|
-
- [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)
|
|
58
61
|
- [Creating A Multi Path Geojson](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/multi_path_geojson.ipynb)
|
|
59
62
|
- [Modifying A Geograph](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/geograph_modifications.ipynb)
|
|
60
63
|
|
|
@@ -70,9 +73,9 @@ In this case, calculate the shortest maritime path between Shanghai, China and S
|
|
|
70
73
|
# Use a maritime network geograph
|
|
71
74
|
from scgraph.geographs.marnet import marnet_geograph
|
|
72
75
|
|
|
73
|
-
# Get the shortest path between
|
|
76
|
+
# Get the shortest path between
|
|
74
77
|
output = marnet_geograph.get_shortest_path(
|
|
75
|
-
origin_node={"latitude": 31.23,"longitude": 121.47},
|
|
78
|
+
origin_node={"latitude": 31.23,"longitude": 121.47},
|
|
76
79
|
destination_node={"latitude": 32.08,"longitude": -81.09},
|
|
77
80
|
output_units='km'
|
|
78
81
|
)
|
|
@@ -82,8 +85,8 @@ print('Length: ',output['length']) #=> Length: 19596.4653
|
|
|
82
85
|
In the above example, the `output` variable is a dictionary with three keys: `length` and `coordinate_path`.
|
|
83
86
|
|
|
84
87
|
- `length`: The distance between the passed origin and destination when traversing the graph along the shortest path
|
|
85
|
-
- Notes:
|
|
86
|
-
- 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.
|
|
87
90
|
- `output_units` options:
|
|
88
91
|
- `km` (kilometers - default)
|
|
89
92
|
- `m` (meters)
|
|
@@ -126,6 +129,49 @@ For more examples including viewing the output on a map, see the [example notebo
|
|
|
126
129
|
- Use: `from scgraph_data.world_highways import world_highways_geograph`
|
|
127
130
|
- See: [scgraph_data](https://github.com/connor-makowski/scgraph_data) for more information and all available geographs.
|
|
128
131
|
|
|
132
|
+
## GridGraph usage
|
|
133
|
+
|
|
134
|
+
Example:
|
|
135
|
+
- Create a grid of 20x100 cells.
|
|
136
|
+
- This creates a grid based graph with connections to all 8 neighbors for each grid item.
|
|
137
|
+
- Each grid item has 4 cardinal connections at length 1 and 4 diagonal connections at length sqrt(2)
|
|
138
|
+
- Create a wall from (10,5) to (10,99).
|
|
139
|
+
- This would foce any path to go to the bottom of the graph to get around the wall.
|
|
140
|
+
- Get the shortest path between (2,10) and (18,10)
|
|
141
|
+
- Note: The length of this path should be 16 without the wall and 20.9704 with the wall.
|
|
142
|
+
|
|
143
|
+
```py
|
|
144
|
+
from scgraph import GridGraph
|
|
145
|
+
|
|
146
|
+
x_size = 20
|
|
147
|
+
y_size = 20
|
|
148
|
+
blocks = [(10, i) for i in range(5, y_size)]
|
|
149
|
+
|
|
150
|
+
# Create the GridGraph object
|
|
151
|
+
gridGraph = GridGraph(
|
|
152
|
+
x_size=x_size,
|
|
153
|
+
y_size=y_size,
|
|
154
|
+
blocks=blocks,
|
|
155
|
+
add_exterior_walls=True,
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
# Solve the shortest path between two points
|
|
159
|
+
output = gridGraph.get_shortest_path(
|
|
160
|
+
origin_node={"x": 2, "y": 10},
|
|
161
|
+
destination_node={"x": 18, "y": 10},
|
|
162
|
+
# Optional: Specify the output coodinate format (default is 'list_of_dicts)
|
|
163
|
+
output_coordinate_path="list_of_lists",
|
|
164
|
+
# Optional: Cache the origin point spanning_tree for faster calculations on future calls
|
|
165
|
+
cache=True,
|
|
166
|
+
# Optional: Specify the node to cache the spanning tree for (default is the origin node)
|
|
167
|
+
# Note: This first call will be slower, but future calls using this origin node will be substantially faster
|
|
168
|
+
cache_for="origin",
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
print(output)
|
|
172
|
+
#=> {'length': 20.9704, 'coordinate_path': [[2, 10], [3, 9], [4, 8], [5, 8], [6, 7], [7, 6], [8, 5], [9, 4], [10, 4], [11, 4], [12, 5], [13, 6], [14, 7], [15, 7], [16, 8], [17, 9], [18, 10]]}
|
|
173
|
+
```
|
|
174
|
+
|
|
129
175
|
## Advanced Usage
|
|
130
176
|
|
|
131
177
|
Using `scgraph_data` geographs:
|
|
@@ -135,7 +181,7 @@ from scgraph_data.world_railways import world_railways_geograph
|
|
|
135
181
|
|
|
136
182
|
# Get the shortest path between Kalamazoo Michigan and Detroit Michigan by Train
|
|
137
183
|
output = world_railways_geograph.get_shortest_path(
|
|
138
|
-
origin_node={"latitude": 42.29,"longitude": -85.58},
|
|
184
|
+
origin_node={"latitude": 42.29,"longitude": -85.58},
|
|
139
185
|
destination_node={"latitude": 42.33,"longitude": -83.05}
|
|
140
186
|
)
|
|
141
187
|
```
|
|
@@ -148,7 +194,7 @@ from scgraph.utils import get_line_path
|
|
|
148
194
|
|
|
149
195
|
# Get the shortest sea path between Sri Lanka and Somalia
|
|
150
196
|
output = marnet_geograph.get_shortest_path(
|
|
151
|
-
origin_node={"latitude": 7.87,"longitude": 80.77},
|
|
197
|
+
origin_node={"latitude": 7.87,"longitude": 80.77},
|
|
152
198
|
destination_node={"latitude": 5.15,"longitude": 46.20}
|
|
153
199
|
)
|
|
154
200
|
# Write the output to a geojson file
|
|
@@ -164,7 +210,7 @@ You can specify your own custom graphs for direct access to the solving algorith
|
|
|
164
210
|
from scgraph import Graph
|
|
165
211
|
|
|
166
212
|
# Define an arbitrary graph
|
|
167
|
-
# See the graph definitions here:
|
|
213
|
+
# See the graph definitions here:
|
|
168
214
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
169
215
|
graph = [
|
|
170
216
|
{1: 5, 2: 1},
|
|
@@ -189,7 +235,7 @@ You can also use a slightly higher level `GeoGraph` class to work with latitude
|
|
|
189
235
|
from scgraph import GeoGraph
|
|
190
236
|
|
|
191
237
|
# Define nodes
|
|
192
|
-
# See the nodes definitions here:
|
|
238
|
+
# See the nodes definitions here:
|
|
193
239
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
194
240
|
nodes = [
|
|
195
241
|
# London
|
|
@@ -206,7 +252,7 @@ nodes = [
|
|
|
206
252
|
[38.7223, -9.1393]
|
|
207
253
|
]
|
|
208
254
|
# Define a graph
|
|
209
|
-
# See the graph definitions here:
|
|
255
|
+
# See the graph definitions here:
|
|
210
256
|
# https://connor-makowski.github.io/scgraph/scgraph/core.html#GeoGraph
|
|
211
257
|
graph = [
|
|
212
258
|
# From London
|
|
@@ -217,9 +263,9 @@ graph = [
|
|
|
217
263
|
# From Paris
|
|
218
264
|
{
|
|
219
265
|
# To London
|
|
220
|
-
0: 311,
|
|
266
|
+
0: 311,
|
|
221
267
|
# To Berlin
|
|
222
|
-
2: 878,
|
|
268
|
+
2: 878,
|
|
223
269
|
# To Rome
|
|
224
270
|
3: 1439,
|
|
225
271
|
# To Madrid
|
|
@@ -227,7 +273,7 @@ graph = [
|
|
|
227
273
|
},
|
|
228
274
|
# From Berlin
|
|
229
275
|
{
|
|
230
|
-
# To Paris
|
|
276
|
+
# To Paris
|
|
231
277
|
1: 878,
|
|
232
278
|
# To Rome
|
|
233
279
|
3: 1181,
|
|
@@ -278,17 +324,34 @@ output = my_geograph.get_shortest_path(
|
|
|
278
324
|
)
|
|
279
325
|
print(output)
|
|
280
326
|
# {
|
|
281
|
-
# 'length': 1799.4323,
|
|
327
|
+
# 'length': 1799.4323,
|
|
282
328
|
# 'coordinate_path': [
|
|
283
|
-
# [52.4862, -1.8904],
|
|
284
|
-
# [51.5074, -0.1278],
|
|
285
|
-
# [48.8566, 2.3522],
|
|
286
|
-
# [40.4168, -3.7038],
|
|
329
|
+
# [52.4862, -1.8904],
|
|
330
|
+
# [51.5074, -0.1278],
|
|
331
|
+
# [48.8566, 2.3522],
|
|
332
|
+
# [40.4168, -3.7038],
|
|
287
333
|
# [41.6488, -0.8891]
|
|
288
334
|
# ]
|
|
289
335
|
# }
|
|
290
336
|
|
|
291
337
|
```
|
|
292
338
|
|
|
339
|
+
# Development
|
|
340
|
+
## Running Tests, Prettifying Code, and Updating Docs
|
|
341
|
+
|
|
342
|
+
Make sure Docker is installed and running on a Unix system (Linux, MacOS, WSL2).
|
|
343
|
+
|
|
344
|
+
- Create a docker container and drop into a shell
|
|
345
|
+
- `./run.sh`
|
|
346
|
+
- Run all tests (see ./utils/test.sh)
|
|
347
|
+
- `./run.sh test`
|
|
348
|
+
- Prettify the code (see ./utils/prettify.sh)
|
|
349
|
+
- `./run.sh prettify`
|
|
350
|
+
- Update the docs (see ./utils/docs.sh)
|
|
351
|
+
- `./run.sh docs`
|
|
352
|
+
|
|
353
|
+
- Note: You can and should modify the `Dockerfile` to test different python versions.
|
|
354
|
+
|
|
355
|
+
|
|
293
356
|
## Attributions and Thanks
|
|
294
357
|
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.
|
|
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
|
|
|
12
12
|
|
|
13
13
|
[project]
|
|
14
14
|
name = "scgraph"
|
|
15
|
-
version = "2.
|
|
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"}
|