-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from TUDelft-CITG/feature/opentnsim-exercise-2023
Exercise 2023 update.
- Loading branch information
Showing
6 changed files
with
64 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 7 additions & 14 deletions
21
notebooks/Example 13 - Path selection by vessel limits.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import io | ||
import pickle | ||
|
||
import requests | ||
import requests_cache | ||
import shapely.geometry | ||
|
||
# inject caching | ||
requests_cache.install_cache("fis_cache") | ||
|
||
urls = { | ||
"0.2": "https://zenodo.org/record/4578289/files/network_digital_twin_v0.2.pickle", | ||
"0.3": "https://zenodo.org/record/6673604/files/network_digital_twin_v0.3.pickle", | ||
} | ||
|
||
|
||
def load_network(version="0.3"): | ||
"""load the pickle version of the fairway information system network""" | ||
url = urls[version] | ||
resp = requests.get(url) | ||
# convert the response to a file | ||
f = io.BytesIO(resp.content) | ||
|
||
# read the graph | ||
graph = pickle.load(f) | ||
|
||
# convert the edges and nodes geometry to shapely objects | ||
for e in graph.edges: | ||
edge = graph.edges[e] | ||
edge["geometry"] = shapely.geometry.shape(edge["geometry"]) | ||
for n in graph.nodes: | ||
node = graph.nodes[n] | ||
node["geometry"] = shapely.geometry.shape(node["geometry"]) | ||
|
||
return graph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import opentnsim.fis | ||
|
||
|
||
def test_network_v2(): | ||
"""check if we can load the network""" | ||
graph = opentnsim.fis.load_network(version="0.2") | ||
|
||
|
||
def test_network_v3(): | ||
"""check if we can load the network""" | ||
graph = opentnsim.fis.load_network(version="0.3") |